Question

It's fairly well-known that (at least in 1.11 EE / 1.6 CE) you can bypass tax rates by utilizing a Zip + 4 (in USA) zipcode. I have tried to add a wildcard to the end of the 5-digit tax rate definition (which in my opinion should have worked) but that proved fruitless.

I found a suggestion to apply a core patch here which involved something to the effect of:

"app/code/core/Mage/Tax/Model/Resource/Calculation.php"

line 235 replace:

 $postcode = $request->getPostcode();

with

 $postcode = substr($request->getPostcode(),0,5);

Copying this to a local/Mage wouldn't be the end of the world - and would save us tax headaches. But I'm not a fan of that method.

How do you work around this issue?

Was it helpful?

Solution

My preferred solution would be to create a new module called MyCompany_TaxCalculationZipFix, override and extend the Mage_Tax_Model_Resource_Calculation class with your own model with a method that looks something like this:

protected function _getRates($request)
{
    $postcode = substr($request->getPostcode(),0,5);

    $request->setPostcode($postcode);

    return parent::_getRates($request);
}

(code not tested)

This way you won't need to copy the whole method over to your own model so most of the logic will stay in core; when Magento upgrades that model in a new release, you are not overriding most of the logic and there is a higher chance that things will keep working (although you will still need to test this of course).

Also, I'm not sure if changing the request will effect other code that uses that request object. you'll need to test that as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top