Skip to content

Instantly share code, notes, and snippets.

@seoindex
Created January 12, 2017 11:30
Show Gist options
  • Save seoindex/3e3f215138586261c097f4a697a48bad to your computer and use it in GitHub Desktop.
Save seoindex/3e3f215138586261c097f4a697a48bad to your computer and use it in GitHub Desktop.
Woocommerce - Applicare sconto in modo automatico
add_action( 'woocommerce_before_cart', 'apply_matched_coupons' ); function apply_matched_coupons() { global $woocommerce; $coupon_code = '10percento'; // titolo del coupon if ( $woocommerce->cart->has_discount( $coupon_code ) ) return; if ( $woocommerce->cart->cart_contents_total >= 500 ) { // valore minimo del carrello $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