• Resolved mayank29gupta

    (@mayank29gupta)


    I want to disable cash on delivery on applying the coupons. In the code below, I have to add the details of each coupon separately to make it work. Could somebody tell a way to modify this code so it may work on each discount coupon available on my website.

     add_filter( 'wc_smart_cod_available', 'cod_restrict_coupons' );
    
    function cod_restrict_coupons( $is_cod_available ) {
    	global $woocommerce;
    	$applied_coupons = $woocommerce->cart->applied_coupons;
    	
    	// add the coupon codes you want
    	// to restrict in this array
    
    	$restricted_coupons = array(
    		'myfirst',
    		'online15',
    		'prepaid10',
    		'nicholassparks',
    		'booker',
    		'kidsbooks',
    		'wintersale',
    		'offer15'
    		
    	);
    	
    	if( array_intersect( $restricted_coupons, $applied_coupons ) ) {
    		$is_cod_available = false;
    	}
    	
    	return $is_cod_available;
    	
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to Disable Cash On delivery on applying coupons’ is closed to new replies.