Search the site:

Home Blog How to Hide the WooCommerce Coupon code field

How to Hide the WooCommerce Coupon code field

Offering coupons to the customers on the WooCommerce store is a great way to offer rewards or discounts.

But, sometimes customers get used to the coupon codes in such a way that they continuously look whether any coupons are been offered on the store. Which may result in customers waiting until the offers are offered at the stored or search for the competitor’s plugin or find any coupon code offered from the affiliates. Which in turn would affect the sales on the store.

We shall take a look at three different ways to hide the coupon code which are as follows:

1) Disable coupon code completely on your WooCommerce store.
2) Hide on the cart page and display on the checkout page.
3) Hide on the checkout page and display on the cart page.

Incase you want to hide the coupon code field based on specific products or product categories, we’ve written about it it extensively here.

1) Disable coupon code completely on your WooCommerce store

The store owner can disable the discount coupon code field completely on the cart and the checkout page, if they do not want to offer any rewards or offers on the store by disabling the ‘Enable the use of coupon codes’ checkbox in the WooCommerce->Settings->General tab.

Here is the screenshot of the setting:

2) Hide the coupon code field on the WooCommerce Cart page

If the store owner wants to hide the coupon code field only on the cart page and display it on the checkout page then the below code snippet can be used to achieve this requirement.

The below code snippet is to be placed in the functions.php file of the currently active child theme (if exists) or in the parent theme.

3) Hide the coupon code field on the WooCommerce Checkout page

Sometimes store owners want to hide the coupon code field only on the checkout page and display it on the cart page. This requirement can be achieved by placing the below code snippet in the functions.php file of the currently active child theme (if exists) or in the parent theme.

Following one of the above three methods, the store owner can hide/disable the coupon code field on the cart page and/or on the checkout page.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
872 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Alvina Recent comment authors

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
newest oldest
Notify of
Alvina
Guest
Alvina

Thank you for sharing this tutorial. I am having an error while adding coupon code as my code is not working. I have seen this code in this tutorial https://www.cloudways.com/blog/create-woocommerce-coupon-code/ and I have almost implemented the same. When I am adding coupon it’s saying not valid. Please let me know what is the issue?

add_action( ‘woocommerce_before_cart’, ‘sh_coupons_matched’ );
function sh_coupons_matched() {
global $woocommerce;
$sh_coupon = ‘OnlineShop’;
if ( $woocommerce->cart->has_discount( $sh_coupon ) ) return;
foreach ( $woocommerce->cart->cart_contents as $key => $values ) {
$autocoupon = array( 65 );
if( in_array( $values[‘product_id’], $autocoupon ) ) {
$woocommerce->cart->add_discount( $cw_coupon );
wc_print_notices();
}
}
}

from purchased

Subscribe Now