I'm trying with the code below to set to zero rate the tax when selling to a European Union state an order of value above 150 euro but I can't get it to work. Any idea what I'm doing wrong?
add_filter( 'woocommerce_product_get_tax_class', 'eu_tax_rate_based_on_subtotal', 1, 2 );
function eu_tax_rate_based_on_subtotal( $tax_class, $product ) {
$EU_countries = array('AT','BE','BG','CY','CZ','DE','DK','EE','ES','FI','FR','GR','HR','HU','IE','IT','LT','LU','LV','MT','NL','PL','PT','RO','SE','SI','SK');
if ( in_array( WC()->customer->get_shipping_country(), $EU_countries ) ){
if ( WC()->cart->subtotal >= 150 )
$tax_class = 'zero';
}
return $tax_class;
}