Created
April 13, 2015 23:43
-
-
Save michaelgiles/c8d75a2a807e8638f07a to your computer and use it in GitHub Desktop.
Woo Another Coupon Code Snippet
This file contains hidden or 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_action( 'woocommerce_before_cart', 'apply_matched_coupons' ); | |
function apply_matched_coupons() { | |
global $woocommerce; | |
$coupon_code = '10percent'; // your coupon code here | |
if ( $woocommerce->cart->has_discount( $coupon_code ) ) return; | |
if ( $woocommerce->cart->cart_contents_total >= 500 ) { | |
$woocommerce->cart->add_discount( $coupon_code ); | |
$woocommerce->show_messages(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment