I need to add a BEBAT tax when we sell batteries. I'm now trying to figure out how I can tackle this. This code is working fine but for a certain part
function add_tax_bebat() {
$getIp = $_SERVER['REMOTE_ADDR'];
$ipDetails = json_decode( @file_get_contents( "http://ipinfo.io/{$getIp}/json" ) );
$country = $ipDetails->country;
if ( $country =="BE" ){
function return_custom_price($price, $products) {
$args = array(
'category' => array( 'batteries' ),
);
$products = wc_get_products( $args );
$price = ($price+0.99);
return $price;
}
add_filter('woocommerce_get_price', 'return_custom_price', 10, 2);
}
}
add_action ( 'init', 'add_tax_bebat' );
This shows on all products even if they are not in the category.