Magento – Magento How to get tax rate for particular country

magento-1.7tax

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);

Best Answer

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.

Related Topic