Created
February 28, 2015 02:41
-
-
Save bobbiejwilson/c5b5d36e763f68338c4f to your computer and use it in GitHub Desktop.
Woocommerce Auto Coupon
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