Shipping Tax
-
Hello Forum,
i have added a 19% to the shipping price in the wocoommerce settings. the problem is that the shpping taxes also appearing (see link) when there is no shipping price.
for example:
the customer adding a 0€ free product (with a shipping class) to his cart. as soon as the customer is adding another product to the cart, all shipping costs are set to zero via PHP: $rate->cost = 0. (see code bellow)how can i avoid the 19% taxes when the shipping is set to zero ? Thank you!
function adjust_shipping_rate( $rates ){
global $woocommerce;
global $free_product_id;$cart_counter = 0;
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
$cart_counter += 1;
}$product_ids = array_merge(
wp_list_pluck(WC()->cart->get_cart_contents(), ‘variation_id’),
wp_list_pluck(WC()->cart->get_cart_contents(), ‘product_id’)
);if ( $cart_counter > 1 && in_array($free_product_id, $product_ids)){
foreach ($rates as $rate) {
$rate->cost = 0;
}}
return $rates;
}
add_filter( ‘woocommerce_package_rates’, ‘adjust_shipping_rate’, 50, 1 );`The page I need help with: [log in to see the link]
The topic ‘Shipping Tax’ is closed to new replies.