- Issue created by @henkpotman
- 🇪🇸Spain henkpotman
After further testing I noticed that the verification actually is disabled when unchecking the checkbox. However even if disabled, for European tax number it still requires the country code ('ES' for Spain) before the taxnumber. Without the ES the tax number is rejected.
Is there a way that the ES prefix is not requested? Local people are not used to indicate the country code before the tax number. This is the same for all european countries.
- 🇪🇸Spain henkpotman
I managed to modify the EuropeanUnionVat.php in commerce/modeles/tax/scr/Plugin/Commerce/TaxNumberType.
Line 35:
public function validate($tax_number) {
$patterns = $this->getValidationPatterns();
$prefix = substr($tax_number, 0, 2);
if (!isset($patterns[$prefix])) {
return FALSE;
}
$number = substr($tax_number, 2);
if (!preg_match('/^' . $patterns[$prefix] . '$/', $number)) {
return FALSE;
}return TRUE;
}Modified into:
public function validate($tax_number) {
$patterns = $this->getValidationPatterns();
$prefix = substr($tax_number, 0, 2);
$number = substr($tax_number, 0);
if (!preg_match('/^' . $patterns['ES'] . '$/', $number)) {
return FALSE;
}return TRUE;
}It's working fine when entering local Spanish tax numbers (without ES prefix) with VIES verification turned off. It just checks the length and structure.
This might be useful for stores selling in one country only.
Same problem for Italy. Did you find another solutions?
I don't want to modify that file.Thank you,
Luca- 🇪🇸Spain henkpotman
The modification I did in #4 is working fine, the site is online now since 3 months and there have been no issues.
I'm working on another site now where I will need to accept VAT numbers from three different countries. I will look into this matter again next month to see how to do this.
- 🇪🇸Spain henkpotman
For another website where I need to accept VAT numbers from three different countries (Spain, Portugal and Andorra) I decided to completely cancel the taxnumber verification by modifying the EuropeanUnionVat.php in commerce/modeles/tax/scr/Plugin/Commerce/TaxNumberType.
Line 35:
public function validate($tax_number) {
$patterns = $this->getValidationPatterns();
$prefix = substr($tax_number, 0, 2);
if (!isset($patterns[$prefix])) {
return FALSE;
}
$number = substr($tax_number, 2);
if (!preg_match('/^' . $patterns[$prefix] . '$/', $number)) {
return FALSE;
}return TRUE;
}Modified into:
public function validate($tax_number) {
return TRUE;
}The taxnumber verification is now always returning TRUE independently of the taxnumber format. This website is substituting a previous website that has been operative 15 years without taxnumber verification and I never had any problems.
I thinks it's very important to let customers enter their tax number in the format they prefer (without country code, also some will put space or dash between letters and numbers) without getting an error message that might lead to a missed sale. Any wrong taxnumber you can correct later in your accounting but in my experience this is occurring very rarely.