Plugin Author
Diego
(@daigo75)
Hi Christian,
The EU VAT Assistant provides a hook called wc_aelia_eu_vat_assistant_show_vat_field
. If you write a filter for that hook, you can return false
when the VAT number should not be displayed, and it won’t appear on the checkout page.
Note
If you show or hide the VAT field, and the cart contents change while the checkout page is open (e.g. if the customer adds products from another tab), the VAT field will stay as it is. This is because the field is displayed when the page is loade. The checkout page can refresh some sections using Ajax, and the billing section, where the VAT field is located, is not amongst them. Refreshing the checkout page would update the VAT field too.
If you need to handle the condition in which the cart could change while the checkout page stays open, then you might want to use a different approach, and show/hide the VAT field using JavaScript. That’s more complex, as you would have to intercept the “checkout refresh” event, determine what the cart contents are, then show or hide the VAT number on the checkout page accordingly.
Should you need assistance implementing this customisation, please feel free to contact us (https://aelia.co/contact). We can review your requirements and prepare an estimate to implement a solution for you.
Plugin Author
Diego
(@daigo75)
Update
Filter wc_aelia_eu_vat_assistant_show_vat_field
has now been replaced by wc_aelia_eu_vat_assistant_show_checkout_field_vat_number
. It can be used the same way (example below).
add_filter('wc_aelia_eu_vat_assistant_show_checkout_field_vat_number', function($show_field, $is_field_required) {
// Set $show_field to true or false, depending on your custom
// conditions
return $show_field;
}, 10, 2);