Magento – VAT validation for Not-Logged-in Customers or Guests

magento-1.9taxvalidationvat

I'm working on this requirement from my EU client. We are on Magento 1.9.1
We have set up VAT validation and auto-group change based for valid and invalid VAT IDs and its working fine.

Now the twist is, we want to validate VAT for customers who are not logged in and move them to a customer group say "Not-Logged-in-Valid-VAT"

Is it possible to assign guest to a customer group since guest is not actually a full customer entity ? Is it possible to replicate the concept of Not-Logged-in customer group ?

Best Answer

Putting no customer in a customer group doesn't make sense at all :-)

But the whole VAT thing afaik is based on the customer group and what you might do is, fake this.

Save the VAT to the session, validate it beforehand. Then when the check is done, make sure that Mage::getSingleton('customer/session')->getCustomerGroup() returns your desired value. Either by rewriting it, or better by setting the customer group. But I'm not sure, whether there is always an empty customer object, which can be misused.

Good luck. Tell me how it works, I think I have to do the same soon.