Support » Plugin: WooCommerce EU VAT Assistant » Disable field validation feedback

  • Is it possible to disable the field validation feedback and not styling it when the VAT is not validated on VIES?

    There are situations when the VAT is valid (just not VIES valid), because it’s from a non-company, or it’s of the same country, and we still need to get it for invoicing proposes.

    If the field turns red, the client will think something is wrong, when it might be just ok.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Diego

    (@daigo75)

    Hi Marco,
    The validation of VAT number is designed to rely exclusively on the VIES service. If that service says “not valid”, then the number is effectively not valid for the purpose of the plugin.

    If you wish to consider as valid some numbers that the VIES service doesn’t handle, you can do that with a customisation.

    PHP

    
    add_filter('wc_aelia_euva_eu_vat_number_raw_validation_result', function($validation_result, $country, $vat_number) {
      // Alter the validation result as you need
      return $validation_result;
    }, 10, 3);
    
    add_filter(''wc_aelia_eu_vat_assistant_customer_vat_exemption', function($customer_vat_exemption, $vat_country, $vat_number, $vat_number_validated, raw_vat_validation_response) {
      // Set $customer_vat_exemption to true or false
      $customer_vat_exemption
    }, 10, 5);
    

    JavaScript

    jQuery(document).on('wc_aelia_euva_eu_vat_number_validation_complete', function(ev, response) {
      // The response variable contains the validation response.
      // You can remove the "invalid" CSS by calling
      // jQuery('#vat_number').removeClass('woocommerce-invalid');
    });
    

    Hi there @daigo75

    I understand when you say the “the number is effectively not valid for the purpose of the plugin”, and I agree.

    The problem is that, in Portugal and I guess other countries, it’s quite common to ask for the VAT number for the invoice, even if there’s not VAT exemption to apply, because it’s a company of the same country or a non-business client.

    So it’s quite normal that we use this plugin to fetch the VAT number for both situations, B2B inside EU, or not. It’s just that it feels a little odd, for the client, to get a red border on a field when he’s inserting his own existant and valid VAT number that just so happens not to be eligible for a VAT exemption.

    I would recommend, if not a visible plugin option, at least implement a WordPress filter to avoid the CSS part of the validation. Of course, the PHP part, and metadata (valid / not valid) should stay the same.

    Plugin Author Diego

    (@daigo75)

    As indicated earlier, the CSS is added via JavaScript, so there isn’t a filter for that. Instead, there is an event triggered after the validation.

    The script I sent earlier can be used instead of a filter, it can remove the “not valid” CSS based on your specific conditions.

    Thanks. I did it already.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.