Question

I need to dynamicaly remove tax during checkout for business to business customers in Magento. I have a module which asks for a VAT ID during checkout and checks it against the European Online VAT-ID Validation Service. If the VAT ID is valid, the tax should be removed during checkout.

The module already assigns new customers with valid VAT ID to the according business to business group in Magento. Customers who order for the first time and create their account during that first checkout, get charged VAT (even with valid VAT-ID).

I basically need to know, how this can be done, which methods involved, etc.

Was it helpful?

Solution

I've got a similar setup going on at the moment, what I have done is if the VAT# at checkout is stored in mage_checkout_model_session. The call

Mage::getSingleton('checkout/session')->getQuote()->getCustomerTaxvat()

In my instance is returning the VAT number for me to check elsewhere. Your VAT# validator is certainly setting something similar to this. At this point you can either create a new module to modify the tax, or override the controller with

$x = Mage::getSingleton('where_your_extension/stores_the_value)->getIsVatValid();
if ($x) $this->setTaxValue( 0 );
else //magento sets it automatically

and it will set the tax rate to zero for the remainder of the session. It will work with guests and registered customers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top