1

I have the following code that adds a Handling fee to orders with subtotal under $100. I'm trying to make a coupon that will remove the handling fee (or make it $0) that I can give to specific customers, even if their order is under $100. I've made a coupon in Woocommerce and it takes off the $25 from the cart subtotal without changing the Handling. If I don't make a coupon in Woocommerce, I get the "this coupon doesn't exist" message when I try to apply the coupon. Help?

function woo_add_cart_fee() {

    global $woocommerce;

    $subt = $woocommerce->cart->subtotal;



    if ($subt < 100  &&  $coupon_code == "NOHANDLING" ) { 
        $handling = 0;
        $woocommerce->cart->add_fee( __('Handling', 'woocommerce'), $handling );
    }   

    elseif ($subt < 100 ) { 
        $handling = 25;
        $woocommerce->cart->add_fee( __('Handling', 'woocommerce'), $handling );
    }   
}

add_action( 'woocommerce_cart_calculate_fees', 'woo_add_cart_fee' );

Thanks.

Coracle
  • 31
  • 1
  • 3

0 Answers0