When you enter a valid VAT number, the EU VAT Assistant sets a flag that tells WooCommerce that the customer is “tax exempt”. When that flag is enabled, WooCommerce removes all taxes from the order (including any 0% VAT). This is by design, it’s how the “tax exemption” works in WooCommerce.
If you need to keep the 0% VAT for tax exempt orders, you will need to write a customisation. The first step would be to disable the logic that enables the VAT exemption set by the EU VAT Assistant, as follows:
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) {
return false;
}, 10, 5);
Then you will have to write a filter to set the VAT to 0% for the “exempt” products, when a valid VAT number is entered. One way to do so would be to write a filter for hook woocommerce_product_get_tax_class
and woocommerce_product_variation_get_tax_class
. In that filter, you can set the VAT rate to 0% against each product.
The resulting logic would then become the following, when a valid VAT number is entered:
1. The VAT exemption is no longer applied.
2. Products that have 0% VAT will stay like that.
3. Products that have a different VAT rate will get a 0% VAT assigned to them.
Should you need assistance implementing the above customisation, please feel free to get in touch. We can review your requirements and prepare an estimate to implement your custom code.