I am working on a WooCommerce site. When I apply a coupon on the checkout page, it automatically applies to the tax as well.
I only want the coupon code to apply to the cart total. I have searched through google for a related hook or plugin, but can not find a working solution.
This is my current code hook in my functions.php
, but it doesn't work as expected.
add_action('woocommerce_product_tax_class', 'set_tax_class');
function set_tax_class () {
if (!empty($woocommerce->cart->applied_coupons)){
$tax_class = 'gratuty';
}
return $tax_class;
}
I have also tried the woocommerce_cart_calculate_fees
hook too, but it did not work.
Which hook should I use to update cart, when coupon is applied, without changing the tax?