Magento disable tax when customer enter vat number on checkout

Magento disable tax when customer enter vat number on checkout

October 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento disable tax when customer enter vat number on checkout

Removing Tax for Belgian Customers Entering VAT Numbers in Magento 1.7

This guide will walk you through the process of removing tax from your Belgian customers’ orders when they enter their VAT numbers during checkout in Magento 1.7.

Understanding the Current Setup

You mentioned that your Magento setup includes two countries—Netherlands and Belgium—both with a standard tax rate of 10%. Currently, the default country is set to Belgium. The issue arises because you want to remove this 10% tax when Belgian customers enter their VAT numbers during checkout.

Why the Tax Rules Approach Didn’t Work

The reason why the tax rules approach didn’t work in your case is that Magento applies taxes based on the customer’s shipping address, not their billing address or entered VAT number. The default shipping country for Belgium will always apply the 10% Belgian rate unless you override it programmatically.

Overriding Tax Calculation at Code Level

To resolve this issue, we need to override the tax calculation process in Magento. This involves modifying the core Mage_Sales_Model_Quote_Address_Total_Tax class and adding a new observer for the sales_model_service_quote_save_total event.

Here’s a step-by-step guide:

  1. Create an Observer

In your custom module, create an observer for the sales_model_service_quote_save_total event. This observer will be triggered whenever a quote is being saved—including during checkout.

<config>
    <global>
        <events>
            <sales_model_service_quote_save_total>
                <observers>
                    <remove_tax_for_belgian_vat_numbers>
                        <type>observer</type>
                        <class>YourCompany_Magento17_Model_Observer</class>
                        <method>applyTaxRulesToQuote</method>
                    </remove_tax_for_belgian_vat_numbers>
                </observers>
            </sales_model_service_quote_save_total>
        </events>
    </global>
</config>
  1. Implement the Observer Method

In your observer class (YourCompany_Magento17_Model_Observer), implement the applyTaxRulesToQuote method:

public function applyTaxRulesToQuote($observer)
{
    $quote = $observer->getQuote();

    // Check if Belgian VAT number is present and valid
    if ($vatNumber = $quote->getBillingAddress()->getVatId()) {
        // Assume a simple VAT validation logic (you may want to integrate with an external API)
        // For this example, we'll consider any 12-digit number as a valid VAT number
        if (preg_match('/^[0-9]{12}$/', $vatNumber)) {
            foreach ($quote->getAllItems() as $item) {
                if ($item->isTaxIncluded()) {
                    // Remove tax amount from the item
                    $item->setTaxAmount(0);
                }
            }

            // Recalculate totals to exclude the removed taxes
            $quote->collectTotals();
        }
    }
}

Conclusion

By following this guide, you should now be able to remove the 10% tax for Belgian customers who enter their VAT numbers during checkout in your Magento 1.7 store.

Remember that this is a custom solution, and it’s always recommended to test thoroughly before deploying it on a live site. If you’re not comfortable with code-level modifications, consider hiring an experienced Magento developer or reaching out to official support channels for assistance.

For more advanced tax configuration strategies and tips for managing VAT numbers in Magento, I recommend checking out the comprehensive guides available at Laravel Company’s Magento Development Resources.

Magento 1 Checkout Extensions Themes

Our network