Answers for "wc disable multiple add more than one coupon"

0

wc disable multiple add more than one coupon

add_action( 'woocommerce_before_calculate_totals', 'one_applied_coupon_only', 10, 1 );
function one_applied_coupon_only( $cart ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

    if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )
        return;

    // For more than 1 applied coupons only
    if (  sizeof($cart->get_applied_coupons()) > 1 && $coupons = $cart->get_applied_coupons() ){
        // Remove the first applied coupon keeping only the last appield coupon
        $cart->remove_coupon( reset($coupons) );
    }
}
Posted by: Guest on August-19-2021

Code answers related to "wc disable multiple add more than one coupon"

Browse Popular Code Answers by Language