Original code makes all prices set to the same, no matter what the VAT % is. So if a item cost 100$ with 25% VAT, it will cost 100$ with 80% VAT or even 0% VAT.
That works fine, however, some countries I would like to remove the VAT for.
Original code from this answer thread:
add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' );
My code that is not working:
add_filter( 'woocommerce_adjust_non_base_location_prices', 'custom_eu_vat_number_country_codes' );
function custom_eu_vat_number_country_codes( $vat_countries ) {
// Which countries should it be applide to?
$countries = array( 'AX', 'AT', 'BE', 'BA', 'HR', 'CZ', 'DK', 'FI', 'GR', 'HU', 'IS', 'IE', 'IT', 'LU', 'NL', 'PO', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'CH', 'GB');
// Avoiding errors on admin and on other pages
if( is_admin() || WC()->cart->is_empty() )
return $countries;
// Remove field $countries
if (($key = array_search($countries, $vat_countries)) !== false) {
return false;
}
return $vat_countries;
}
What am I doing wrong?