For an US webshop, I need to remove taxes from a quote item for some customers. I can't use groups because there are in use for a loyalty program. I have added a customer attribute names "is_tax_exempt".

I have rewritten the following Model : Mage_Tax_Model_Sales_Total_Quote_Tax

In the _aggregateTaxPerRate() function I have modified the code like this :

$customer_id = Mage::getSingleton('customer/session')->getId();
$customer = Mage::getModel("customer/customer")->load($customer_id);

if($customer->getIsTaxExempt() == 1)
    $item->setTaxAmount(max(0, $rowTax));
    $item->setBaseTaxAmount(max(0, $baseRowTax));

I have tested this code, it's working : tax_amount and base_tax_amount are setted to zero in the database.

My problem is : the price for the cart is wrong.

There is one item in the cart with price : 100$. The cart price is like :

Subtotal : $100.00

Grand Total Excl. Tax : $100.00

Tax : $6.50

Grand Total Incl. Tax : $106.50

I need to get Tax : 0 and Grand Total Incl/ tax : 0.

I have used the following configuration for tax parameters : http://www.magentocommerce.com/knowledge-base/entry/ce18-and-ee113-tax-config-us

How to do this ? Thank you in advance.

1 Answer 1


I've managed to solve my problem by following this thread : Modify tax rate on cart quote items and recalculate

I have added an Observer to the event sales_quote_collect_totals_before.

And here is the content of my observer, very simple :

public function removetax($observer)
    $customer_id = Mage::getSingleton('customer/session')->getId();
    $customer = Mage::getModel("customer/customer")->load($customer_id);

    if($customer->getIsTaxExempt() == 1)
        $items = $observer->getEvent()->getQuote()->getAllVisibleItems();
        foreach($items as $item)

Explanation : I load the current customer object in order to access the is_tax_exempt attribute. If customer is tax exempt, I grab the current cart content and for each item, I set the product tax class to 0. It is mandatory to not save the product or the item. The aim here is to set a value for the following calculation, not to save it in the database. Tax classes need to stay to the initial value in the db.

So by setting the tax class for this event, the following calculation will use the information setted in the observer. This seems to be a very clean method to achieve my first problem.

  • How to remove tax if we have set catalog prices including tax? Commented Apr 11, 2015 at 6:58
  • I'm not sure it is possible : you will have to modify the price, but adding a tax is not the same as removing it. The rate will be different. The best thing to do in your case should be to edit your catalog to exclude tax from base price. Commented Apr 13, 2015 at 8:23

Your Answer

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

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