Reputation: 290
A project I’m working on allows customers to buy products that have the ability to be VAT exempt (through disability/chronic sickness). I have added an additional step to the checkout process so the customer can easily fill in the VAT exempt form. Once that form has been filled in I need to remove tax from their quote/order.
I have done a fair bit of digging into how I could potentially do this. Below is the code I got so far, however it works but the moment I go through to our payment provider the tax has been reset. Even when I use Check / Money Order payment option.
file: app/code/local/Vat/Exempt/controllers/OnepageController.php
(method: saveExemptAction()
)
$quote = $this->getOnepage()->getQuote();
$quote->setCustomerTaxClassId(6); // Tried forcing a custom tax class id
$quote->setCustomerGroupId(4); //also tried forcing a different customer group...
foreach($quote->getAllItems() as $item){
// Attempt to zero the tax on each item
$item->setTaxAmount(0);
$item->setBaseTaxAmount(0);
//re-calculate & save each item.
$item->calcTaxAmount();
$item->save();
}
$quote->collectTotals()->save();
Any advice would be much appreciated!
Upvotes: 0
Views: 5011
Reputation: 8585
The easiest way would be to change the customer's group to a group that doesn't pay VAT (you can define that in Sales > Tax > Manage Tax Rules).
After they fill up the form you change their group ($customer->setGroup(self::GROUP_EXEMPT_VAT)->save();
) and from this moment they won't pay tax.
Let me know if that would work for your issue and if you need more help.
Upvotes: 1