wc_coupons_enabled()
Checks if coupons are enabled. Checks the option woocommerce_enable_coupons === 'yes'.
Hooks from the function
Returns
true|false.
Usage
wc_coupons_enabled();
Examples
#1 Check if the coupons are included in the store
Part of the code from file cart.php:
<?php if ( wc_coupons_enabled() ) { ?>
<div class="coupon">
<label for="coupon_code"><?php esc_html_e( 'Coupon:', 'woocommerce' ); ?></label>
<input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" />
<button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>"><?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?></button>
<?php do_action( 'woocommerce_cart_coupon' ); ?>
</div>
<?php } ?>
Changelog
| Since 2.5.0 | Introduced. |
wc_coupons_enabled() wc coupons enabled code WC 10.3.3
function wc_coupons_enabled() {
return apply_filters( 'woocommerce_coupons_enabled', 'yes' === get_option( 'woocommerce_enable_coupons' ) );
}