Support » Plugin: WooCommerce EU VAT Assistant » VAT input in Checkout Shipping Fields

  • Resolved dtacer

    (@dtacer)


    Hi,

    it’s possible to move VAT field to shipping fields area on checkout page? We have shipping fields required and billing optional.

    Thank you

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

    (@daigo75)

    The VAT number field is added using a filter attached to the hook woocommerce_checkout_fields. You can write your own custom filter and modify the list of fields as you need. In your specific case, you could remove the field from the billing fields and add it to the shipping fields, and it should appear in that section.

    You can refer to the official WooCommerce documentation for an example of how to implement such filter: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

    Please be aware that the EU VAT Assistant was designed primarily for digital products, which don’t have a shipping element. Due to that, the plugin takes the billing country into account to validate the VAT number entered on the checkout page. Moving the field to the shipping section won’t change this behaviour.

    If you wish to validate the enter VAT number based on the shipping country, you can write a filter for hook wc_aelia_euva_set_customer_vat_exemption_country and return the shipping country entered at checkout. That value will then be used for the validation.

    Thread Starter dtacer

    (@dtacer)

    Hi,

    thank you. We have VAT and country field in billing and shipping section. It’s possible to make validation if user fill shipping details we take shipping country and shipping vat, if user fill shipping and billing details we take billing country and billing vat?

    Plugin Author Diego

    (@daigo75)

    As explained, the EU VAT Assistant doesn’t take into account the shipping country, because it’s not designed for that purpose. You will have to implement your own custom filter to decide if you wish to replace the billing country with the shipping country during the validation. See filter wc_aelia_euva_set_customer_vat_exemption_country, mentioned earlier:

    add_filter('wc_aelia_euva_set_customer_vat_exemption_country', function($vat_country) {
      if(<YOUR CUSTOM LOGIC>) {
        $vat_country = <FETCH SHIPPING COUNTRY>;
      }
      return $vat_country;
    });

    Also, keep in mind that the EU VAT Assistant doesn’t support multiple VAT number fields on the checkout page. The validation logic is based on the assumption that a transaction can only have one VAT number, having multiple fields is not a supported scenario.

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