Magento: How to calculate tax programmatically

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


You can get $price from $product using


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.