Unable to disable Tax Number verification

Created on 19 September 2023, about 1 year ago
Updated 22 February 2024, 10 months ago

It's impossible for me to turn off the automatic tax number verification during checkout

In Profile type - Cliente I deactivated the 'Verify the tax number via external web service' checkbox, however still the the tax number verification is carried out during checkout. I cleaned cache and run cron several times. Im strugling with this several days now and see no solution. How can I disable the Tax number verification?

Further comments:
The tax number verification is annoying for customers as it obliges the customer to include a country code (ES for Spain) before the usual tax number (e.g. ESB99999999 instead of B99999999). Most customers are not used to this and will fail to enter their taxt number correctly. Any common web here expects a 'B99999999' format without 'ES'.

I tried other solutions:
- Define the Tax Number field as plain text in Form Views and Display Views. However this way during checkout I always get 'This value should not be null' error even if I enter a tax number.

- Define a new form field with plain text format. This somehow works but it is shown in both the billing and shipping panes which is not correct, it should only be shown in the billing pane.

None of these solutions is satisfiying. There should be a solution just to turn off the tax number verification but it's not working for me.

Thanks for helping!

🐛 Bug report
Status

Active

Version

2.35

Component

Checkout

Created by

🇪🇸Spain henkpotman

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • 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.

Production build 0.71.5 2024