Learn how you can be able to hide coupon field in WooCommerce, from either cart page or both cart page and checkout page.
There are two ways you can archive it:
- Use of code snippet,
- Use of WooCommerce setting.
Plugin used to add code:
Use Code snippet plugin to add the code:
Attached is a YouTube tutorial explaining how to achieve it.
Use of WooCommerce setting:
- Login to WordPress dashboard,
- Hover on WooCommerce button and select setting,
- On setting, there is an option to enable coupon
- To enable, coupon to you site, tick on the box,
- To disable the coupon to your site, untick box.
Use of WooCommerce php code snippet.
You can disable the coupon code field in cart page using snippet.
Use the attached code snippet below:
/**
* Author: Thiarara
* Version: 1.1
* licence: Free GPL
* Topic: Woo Remove coupon code feild in the cart
* Email support: contact@thiarara.co.ke
**/
function woo_remove_coupon_code_cart_field( $enabled ) {
if ( is_cart() ) {
$enabled = false;
}
return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'woo_remove_coupon_code_cart_field' );
copy and past the code.
You can disable the coupon code field in checkout page using snippet.
/*
* Author: Thiarara
* Version: 1.1
* licence: Free GPL
* Topic: Hide coupon field on checkout page
* Email support: contact@thiarara.co.ke
**/
// hide coupon field on checkout page
function Woo_hide_coupon_field_on_woocommerce_checkout( $enabled ) {
if ( is_checkout() ) {
$enabled = false;
}
return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'woo_hide_coupon_field_on_woocommerce_checkout' );
copy and past the code.
You may also like: WooCommerce Maximum and Minimum order quantity snippet.