Created
January 23, 2018 21:34
-
-
Save shreyans94/c2b99d03b2c57696fb4627f2b0a8c3ca to your computer and use it in GitHub Desktop.
Coupon Restriction option in WooCommerce Smart COD Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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