Skip to content

Instantly share code, notes, and snippets.

@frozonfreak
Created December 27, 2014 04:53
Show Gist options
  • Save frozonfreak/45898b806eae42587f77 to your computer and use it in GitHub Desktop.
Save frozonfreak/45898b806eae42587f77 to your computer and use it in GitHub Desktop.
Woocommerce Auto Coupon
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