Magento: How to calculate tax programmatically

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


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

You can get $price from $product using


  1.  $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.

2 thoughts on “Magento: How to calculate tax programmatically


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

    This is how you get price with tax. BUT this is NOT how you calculate tax!!! Magento calculates tax for you based on your magento shop settings

Leave a Reply

Your email address will not be published.

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.