Skip to content

Instantly share code, notes, and snippets.

@bobbiejwilson
Created February 28, 2015 02:41
Show Gist options
  • Save bobbiejwilson/c5b5d36e763f68338c4f to your computer and use it in GitHub Desktop.
Save bobbiejwilson/c5b5d36e763f68338c4f 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