Reputation: 1221
I have magento 1.7 site and i'm tiring to remove that tax from customers if they enter an tax number on checkout page.
i have two countries Netherlands and Belgium for tax rules both have 10% taxes.the default country is Belgium.
i need to remove the tax adding when Belgium customer enter there vat number on checkout page.
i tired using tax rules but no luck.
anyone have idea about how to do that using magento backend or using code level.any answers i appreciated. thank you
Upvotes: 1
Views: 2466
Reputation: 2125
Over ride Magento's Tax Model getRate() function is how we did something similar.
class My_Module_Model_Tax_Calculation extends Mage_Tax_Model_Calculation
{
public function getRate($request)
{
if (!$request->getCountryId() || !$request->getCustomerClassId() || !$request->getProductClassId()) {
return 0;
}
$country_id = $request->getCountryId();
if ($country_id == 'BE' && $this->getCustomer() && $this->getCustomer()->getTaxvat()) {
return 0;
}
$cacheKey = $this->_getRequestCacheKey($request);
if (!isset($this->_rateCache[$cacheKey])) {
$this->unsRateValue();
$this->unsCalculationProcess();
$this->unsEventModuleId();
Mage::dispatchEvent('tax_rate_data_fetch', array('request'=>$request));
if (!$this->hasRateValue()) {
$rateInfo = $this->_getResource()->getRateInfo($request);
$this->setCalculationProcess($rateInfo['process']);
$this->setRateValue($rateInfo['value']);
} else {
$this->setCalculationProcess($this->_formCalculationProcess());
}
$this->_rateCache[$cacheKey] = $this->getRateValue();
$this->_rateCalculationProcess[$cacheKey] = $this->getCalculationProcess();
}
return $this->_rateCache[$cacheKey];
}
}
Upvotes: 3