Skip to content

Instantly share code, notes, and snippets.

@shreyans94
Created January 23, 2018 21:34
Show Gist options
  • Save shreyans94/c2b99d03b2c57696fb4627f2b0a8c3ca to your computer and use it in GitHub Desktop.
Save shreyans94/c2b99d03b2c57696fb4627f2b0a8c3ca to your computer and use it in GitHub Desktop.
Coupon Restriction option in WooCommerce Smart COD Plugin
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(
'hi5',
'pre2'
);
if( array_intersect( $restricted_coupons, $applied_coupons ) ) {
$is_cod_available = false;
}
return $is_cod_available;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment