Last active
March 10, 2017 13:20
-
-
Save marcosnakamine/13b8b3ede57de49cec9530bcb5328e76 to your computer and use it in GitHub Desktop.
WooCommerce - Apply automatic discount 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
<?php | |
add_action( 'woocommerce_before_cart', 'apply_auto_coupons' ); | |
function apply_auto_coupons() { | |
if ( WC()->cart->get_cart_contents_count() >= 6 && !in_array( 'COUPON_CODE', WC()->cart->applied_coupons ) ) { | |
WC()->cart->add_discount( 'COUPON_CODE' ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment