Created
March 11, 2020 11:28
-
-
Save pavr0m/03f8c7612fdf11dd0359cffe96b554ec to your computer and use it in GitHub Desktop.
WooCommerce. Add coupon.
This file contains 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
/** | |
* Add coupon automatically: disabled | |
*/ | |
add_action('woocommerce_before_checkout_form', 'preorder_coupon'); | |
function preorder_coupon() { | |
if ( in_array( 'discount', WC()->cart->get_applied_coupons() ) ) { | |
return; | |
} else { | |
WC()->cart->apply_coupon('discount'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment