Create conditional code for tax filter
Budget: €18 – €36 EUR
Hello!
I have a product tax filter from github, it is "woocommerce experimental" :
add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' );
I'd like to remove this filter when the shopper delivery country is outside EU.
I found this code:
add_action( 'woocommerce_cart_calculate_fees', 'same_price_for_eu' );
function same_price_for_eu(){
$countries = new WC_Countries();
$eu_countries = $countries->get_european_union_countries();
if ( in_array( WC()->customer->get_shipping_country(), $eu_countries) ){
add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false');
} else {
remove_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false');
}
}
But it doesnt work as expected, it is not stable. Please fix this code so it is 100% stable and works as intended.
I have a product tax filter from github, it is "woocommerce experimental" :
add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' );
I'd like to remove this filter when the shopper delivery country is outside EU.
I found this code:
add_action( 'woocommerce_cart_calculate_fees', 'same_price_for_eu' );
function same_price_for_eu(){
$countries = new WC_Countries();
$eu_countries = $countries->get_european_union_countries();
if ( in_array( WC()->customer->get_shipping_country(), $eu_countries) ){
add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false');
} else {
remove_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false');
}
}
But it doesnt work as expected, it is not stable. Please fix this code so it is 100% stable and works as intended.