wc_coupons_enabled()WC 2.5.0

Check if coupons are enabled. Filterable.

Hooks from the function

Return

true|false.

Usage

wc_coupons_enabled();

Examples

0

#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() code WC 9.0.1

function wc_coupons_enabled() {
	return apply_filters( 'woocommerce_coupons_enabled', 'yes' === get_option( 'woocommerce_enable_coupons' ) );
}