Skip to content

Instantly share code, notes, and snippets.

@pavr0m
Created March 11, 2020 11:28
Show Gist options
  • Save pavr0m/03f8c7612fdf11dd0359cffe96b554ec to your computer and use it in GitHub Desktop.
Save pavr0m/03f8c7612fdf11dd0359cffe96b554ec to your computer and use it in GitHub Desktop.
WooCommerce. Add coupon.
/**
* 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