0

We display product prices including tax in our catalog and our "Default Tax Destination Calculation" is none.
Most of our customers are guests (so not registered) and based on their IP we guess their destination country and trigger Mage_Checkout_CartController::estimatePostAction() with it in case there isn't a country already set manually via the "Get a Quote" button on the cart page (which triggers the same function but with the country and address the guest entered manually in the "Estimate shipping and tax" form).

This approach causes the Cart to show the correct taxes (even on the guest's first visit when the IP guess was correct). However it doesn't affect the catalog prices. Those are always shown with including 0% tax for the guest. That also applies when the guest manually triggered a quote and even when he completed an order.

Now the question is, how can we achieve that the guests directly see the catalog prices including the tax based on their estimated country (note that we are based in Europe so all tax rules are only country specific and state or postal code is irrelevant) just like registered users always see the correct taxes based on their default registered address directly in the catalog?
Any approach via configuration or programmatically is welcome!

1 Answer 1

1

Magento Stackexchange seems a little dead these days...

However, once you've found a good class to extend, this is actually very easy. We now have chosen Mage_Tax_Model_Calculation which we extend in an custom extension. Here we override getRateRequest where we basically just added this code right before the return $request (note that 4 is the ID of our international store):

    $storeId = Mage::app()->getStore()->getId();
    if ($storeId == 4 && ($basedOn == "default" || !$address->getCountryId())) {
        $geoIP = Mage::getSingleton('geoip/country'); //this is the Sandfox GeoIP extension
        $countryCode = $geoIP->getCountry();
        if ($countryCode == "EU") $countryCode = "FR"; //default to FR if code is EU
        $request->setCountryId($countryCode);
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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