I want to forbid VAT numbers from specified EU countries

This requires version 1.11.26 or later of the plugin.

If you want to not allow valid (according to the EU) VAT number from certain countries, you can do this using the following code fragment (but adapt it according to the country code that you wish to use; the example below will forbid VAT numbers everywhere except Ireland, IE):

add_filter('wc_eu_vat_check_vat_number_country', 'my_wc_eu_vat_check_vat_number_country', 10, 2);

function my_wc_eu_vat_check_vat_number_country($allowed_country, $country) {
  // If it is not Ireland, then forbid it
  if ('IE' != $country) return false;
  // Otherwise, let the existing value pass through
  return $allowed_country;

Note that you will like want to also change the message shown. The default is “You cannot use a VAT number since your country (%s) is outside of the EU.”. The code fragment below changes the message to make it more appropriate for our example above:

add_filter('wc_eu_vat_disallowed_country_message', 'my_wc_eu_vat_disallowed_country_message', 10, 2);
function my_wc_eu_vat_disallowed_country_message($error, $country) {
  return sprintf(__('You cannot use a VAT number for this country (%s) - we only accept them from Ireland.', 'woocommerce-eu-vat-compliance'), $country);

Posted in: WooCommerce EU/UK VAT Compliance