2

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?

4

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.

  • This is certainly a possibility. However, calling setPostcode would possibly override the user-input value which may have some bearing on how shipping is handled. Thanks. – philwinkle Feb 8 '13 at 3:12
  • Ah yeah of course.. you could always just copy the whole method and just change the local postcode variable, edit: Or change the request back to what it was at the end of your method – Erfan Feb 8 '13 at 3:15
  • It seems that this is really the only solution available. Thanks. – philwinkle Feb 10 '13 at 20:36
  • @Erfan Does it work for the already registered customers with Zip + 4 (in USA) zipcode? – Mukesh Jun 9 '16 at 16:56
  • yes, it works. I tested it. – Mukesh Jun 10 '16 at 16:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.