Magento 2 | VAT number that is required on checkout , even if, from backend is set as optional or none
Today we have a request from a customer that have a Magento 2 website, wit a commercial theme and some commercial modules.
He come to us because he had a problem with the checkout.
For “Guest” user all it’s right, instead, for registered user VAT Number is always required (even if from backend is set as optional or none ).
The problem, is that, at this moment, the private users can’t registered on the store.
The situation at the moment is that:
In backend ( Stores => Configuration => Customers => Customer Configuration) :
Show VAT Number on Storefront : No
Show Tax/VAT Number : No
In Frontend:
The vat number isn’t showed but is required ( so when i choice a payment methods, and click on proceed, i have an errore “VAT number is required field”).
My solution:
First of all, navigate to Stores => Configuration => Customers => Customer Configuration and switch
Show VAT Number on Storefront : Yes
Show Tax/VAT Number : Optional
Reindex, Clear Cache, Flush Cache, and navigate to frontend, put something in cart, and navigate to checkout.
If all is right, you see the VAT Number field, and, ( even if from backend is set to “optional” ) is required.
Open console and, check which is the name or id of the VAT field.
Let’s navigate to PhpMyAdmin, Select the DB and navigate to “Search” tab.
Here insert as Search value “VAT” and select all table.
In the result, search for “eav_attribute”
Click on it, and after on “edit”.
Change the value “is_required” from “1” to “0”
Reindex, Clear Cache, Flush Cache, and navigate to frontend, put something in cart, and navigate to checkout.
If all is right, now, you can see the VAT number, but is no more required.
Now navigate to the backend, Stores => Configuration => Customers => Customer Configuration and switch
Show VAT Number on Storefront : No
Reindex, Clear Cache, Flush Cache, and navigate to checkout, reload page, and you can see the VAT field no more.
If try to buy something, as a registered user you haven’t no more VAT problem.
That’s all