Last active
July 6, 2017 09:36
-
-
Save bradleysa/3cc0b5cf1d5d287a9ef5 to your computer and use it in GitHub Desktop.
WooCommerce: Check if Coupon Already Applied
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 | |
/** | |
* WooCommerce: Hide 'Coupon form' on checkout page if a coupon was already applied in the cart | |
* Add to theme functions.php file or Code Snippets plugin | |
*/ | |
add_filter( 'woocommerce_coupons_enabled', 'woocommerce_coupons_enabled_checkout' ); | |
function woocommerce_coupons_enabled_checkout( $coupons_enabled ) { | |
global $woocommerce; | |
if ( ! empty( $woocommerce->cart->applied_coupons ) ) { | |
return false; | |
} | |
return $coupons_enabled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stack Overflow: WooCommerce check if coupon already applied?
http://stackoverflow.com/questions/17626814/woocommerce-check-if-coupon-already-applied