The behaviour you describe is by design. The “VAT required” option means “always required”, not “required only if there would be VAT to pay”. The purpose of that option is to enforce B2B transactions. That is, customers are not allowed to complete an order without providing a valid VAT number, which is used to identify them as businesses, whether there would be VAT to pay or not.
There isn’t a check on the cart content to determine if the cart total is greater than zero, nor to determine if no tax is applicable, because that’s not what the “VAT required” option is for.
If the VAT number is “not always required”, then you can do it as follows:
– Set the VAT number field as optional. This will prevent the JavaScript on the checkout page from requiring it.
– Implement your own custom logic to determine if the field should be required, by writing a filter for the wc_aelia_euva_order_is_eu_vat_number_required
hook.
In your filter, you can do what you like to decide if the VAT number should be required, and return true
or false
, as needed. The field will remain optional on the frontend, then your custom logic will kick in when the customer tries to complete the checkout, eventually telling him that the VAT number is required.
If you need help implementing the customisation, you can use our contact form to get in touch. We will review your specifications and get back to you with an estimate for the implementation.