Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Hide Coupon Field After a Coupon is Applied in WooCommerce?

Implementing this feature is indeed a practical way to restrict the application of multiple coupons during the checkout process. This code will hide the coupon field on both the cart and checkout pages after a coupon is applied, effectively preventing customers from utilizing multiple coupons within a single transaction.

function ts_disable_coupon_field($enabled) {
    if (is_object(WC()->cart) && WC()->cart->applied_coupons) {
        if (is_cart() || is_checkout()) {
            $enabled = false;
        }
    }
    return $enabled;
}

add_filter('woocommerce_coupons_enabled', 'ts_disable_coupon_field');

Output

The output shows that, whenever a coupon is applied, the code tends to remove the coupon fields from both the cart and checkout pages. Thus restricting customers from applying an additional coupon or discount.

How to Hide Coupon Field After a Coupon is Applied in WooCommerce? - Tyche Softwares

The following output shows that the coupon field is removed on the checkout page as well.

How to Hide Coupon Field After a Coupon is Applied in WooCommerce? - Tyche Softwares

The below output shows that the coupon field is not hidden when the code is not implemented. And by default, it allows as many coupons to be applied as well.

How to Hide Coupon Field After a Coupon is Applied in WooCommerce? - Tyche Softwares

In the same way, the coupon field is not hidden in the checkout page too as shown below.

How to Hide Coupon Field After a Coupon is Applied in WooCommerce? - Tyche Softwares


In the same way as above, you can also disable coupon fied when a bogo buy one get one is offered in WooCommerce.

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

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x