Magento How to get tax rate for particular country
-
16-10-2019 - |
Question
I am trying to get tax rate for particular country for example for India I used following code but it returns 0
$taxClassId = $_product->getTaxClassId();
$country = 'IN';
$TaxRequest = new Varien_Object();
$TaxRequest->setCountryId( $country );
$TaxRequest->setStore( Mage::app()->getStore() );
$TaxRequest->setCustomerClassId( $taxClassId );
$taxCalculationModel = Mage::getSingleton('tax/calculation');
$rate = $taxCalculationModel->getRate($TaxRequest);
Solution
First of all check if your taxes are set as they should and the rules are applied. During the checkout do you see the right taxes?
Then you can debug by looking at Mage_Tax_Model_Calculation::getRate()
, first lines of code are:
if (!$request->getCountryId() || !$request->getCustomerClassId() || !$request->getProductClassId()) {
return 0;
}
Then dig deeper if this is OK.
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange