Magento: How to calculate tax programmatically

This is how to calculate tax on a given price and product programmatically in Magento.


$priceInclTax=Mage::helper('tax')->getPrice($product,$price);

You can get $price from $product using


$price=$product->getFinalPrice();

You can get price the way you want, it can be custom price or any number you want to calculate tax on, but you need to pass the $product which should be a valid product object.