Remove tax during checkout in Magento

Remove tax during checkout in Magento

August 16, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Remove tax during checkout in Magento

Removing Tax During Checkout in Magento for VAT Exempt Products

Removing tax from an order during checkout can be a complex task in Magento, especially when dealing with payment provider integrations that reset the tax amount. In this post, we’ll provide a step-by-step guide to successfully remove tax from orders based on customer exemptions while ensuring your code remains stable and maintainable.

Understanding the Current Approach

The current code attempts to set the tax class ID and customer group ID to bypass the standard Magento tax calculation rules. However, it falls short in two key areas:

  1. Limited control over taxation: Setting the tax class ID or customer group doesn’t guarantee that all items will be exempt from tax, especially if multiple tax rates are applied at the product level.

  2. Payment provider interference: Payment providers often reset the order data before processing the payment, which causes the manually set tax amounts to revert back to their original values.

The Optimal Solution: Custom Tax Calculation

To overcome these challenges, we’ll implement a custom tax calculation model. This approach allows us to control the taxation process completely, ensuring that the tax is removed regardless of any external interference from payment providers or Magento’s built-in rules.

Step 1: Create a Custom Tax Model

Create a new PHP file in your custom module, for example, app/code/local/Vat/Exempt/Model/Tax/Custom.php:

class Vat_Exempt_Model_Tax_Custom extends Mage_Tax_Model_Calculation
{
    // Override the calculateTax method to remove tax from exempt orders
    public function calculateTax($price, $percent, $rounding=0)
    {
        if ($this->isVatExemptOrder()) {
            return 0;
        }

        return parent::calculateTax($price, $percent, $rounding);
    }

    // Check if the current quote is VAT exempt
    private function isVatExemptOrder()
    {
        // Implement your logic here to determine if the order should be tax-exempt
        // For example, you can check a custom flag or attribute in the quote object

        return false; // Replace this with your actual exemption condition
    }
}

Step 2: Configure Magento to Use the Custom Tax Model

Update your configuration file at app/code/local/Vat/Exempt/etc/config.xml to tell Magento to use our custom tax model:

<config>
    <global>
        <tax>
            <calculation>
                <model>vat_exempt_tax_custom</model>
            </calculation>
        </tax>
    </global>
</config>

Step 3: Implement the Exemption Logic

In your VAT exemption form (located in app/code/local/Vat/Exempt/controllers/OnepageController.php), update the save action to set a custom attribute on the quote object when an exemption is submitted:

public function saveExemptAction()
{
    // ... existing code ...

    if ($form->isValid()) {
        $quote = $this->getOnepage()->getQuote();

        // Set a custom flag indicating that the order should be tax-exempt
        $quote->setData('vat_exempt', 1);

        // ... continue with your existing logic to save the form data ...
    }

    // ... remaining code ...
}

Step 4: Verify the Custom Tax Calculation

After implementing these changes, verify that the custom tax calculation is working as expected by placing an order through the frontend. The new total should reflect the correct subtotal without any added tax.

Conclusion

Removing tax from Magento orders requires a strategic approach to ensure stability and accuracy in the taxation process. By implementing a custom tax model, we gain full control over the tax calculations, allowing us to handle VAT exemptions effectively regardless of external factors or Magento’s built-in rules.

Remember that customizing the core tax calculation model should be done with care, as it may affect other areas of your site. Ensure you thoroughly test this solution in a development environment before deploying it to production.

For more advanced techniques and best practices in Magento customization, consider exploring our comprehensive guides at Laravel Company’s Magento Development Resources.

Checkout Catalog Database Extensions

Our network