Magento - Don't charge tax for shipping

Magento - Don't charge tax for shipping

August 26, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - Don't charge tax for shipping

Stop Charging Tax on Shipping Costs in Magento

If you’re running an e-commerce store on Magento, you might find yourself in a situation where you want to exclude the shipping cost from tax calculations. By default, Magento includes the flat rate shipping fee in the total amount subject to tax. However, it’s easy to modify this behavior by adjusting some settings and adding a little bit of custom code.

Understanding the Default Tax Calculation

Before we dive into the solution, let’s understand how Magento calculates taxes:

  1. Taxable Amount: This includes the base price of all products in an order.
  2. Shipping Cost: By default, any flat rate shipping fee is added to this taxable amount.

How to Exclude Shipping from Tax Calculation

To stop charging tax on your flat rate shipping cost, you need to make two changes:

  1. Disable Tax Calculation for Shipping in the Admin Panel

    • Log into your Magento admin panel.
    • Navigate to Stores > Configuration > Sales > Tax.
    • Under the Tax calculation settings based on section, set ‘Apply Customer Tax’ and ‘Apply Discount Tax or Fixed Tax’ to ‘No’.
    • Click Save Config.
  2. Add Custom Code to Exclude Shipping from Taxable Amount

Even after disabling tax for shipping in the admin panel, Magento still includes flat rate shipping fees in the total taxable amount by default. To completely exclude this:

  • Navigate to your Magento root directory via FTP or SFTP.

  • Open the file app/code/core/Mage/Tax/Model/Calculation.php.

    • Warning: This is a core file and modifying it directly can cause issues during future upgrades. It’s recommended to create an extension for this change.
  • Look for the function getShippingAmount around line 690.

  • Replace the existing code with the following:

public function getShippingAmount($request)
{
    if ($this->_shippingPrice === null) {
        $quote = Mage::getSingleton('checkout/session')->getQuote();
        foreach($quote->getAllAddresses() as $address){
            if($address->getShippingDescription()){
                $this->_shippingPrice = $address->getShippingAmount();
            }
        }
    }

    return $this->_shippingPrice;
}

This code retrieves the shipping amount from the quote object directly, effectively excluding it from tax calculations.

Testing Your Changes

After making these changes:

  1. Clear your Magento cache.
  2. Create a new order and verify that tax is not applied to your flat rate shipping cost.

By following these steps, you should now have successfully excluded your flat rate shipping fee from the total taxable amount in Magento. This ensures customers are only charged taxes on their product prices.

For more advanced customizations like this, consider checking out our guide on Creating a Custom Tax Extension for Magento to ensure your store remains upgrade-friendly and maintainable.

Remember, it’s always a good idea to test changes in a staging environment before deploying them to your live site. Happy selling!

Catalog Admin Configuration Orders

Our network