Skip to content

Instantly share code, notes, and snippets.

@michaelgiles
Created April 13, 2015 23:43
Show Gist options
  • Save michaelgiles/c8d75a2a807e8638f07a to your computer and use it in GitHub Desktop.
Save michaelgiles/c8d75a2a807e8638f07a to your computer and use it in GitHub Desktop.
Woo Another Coupon Code Snippet
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