WooCommerce: Hide Coupon Code @ Cart & Checkout Page

When you apply a coupon code programmatically, for example, you may want to hide the coupon code on the cart and checkout page so that the code stays private and cannot be shared with others.

This solution will basically remove the coupon code (e.g. “VWXYZ”) from the “Coupon: VWXYZ” string that appears in the Cart and Checkout totals. Enjoy!

woocommerce-hide-coupon-code-cart-page
WooCommerce: hide coupon codes on the cart page

PHP Snippet: Hide Coupon Code from WooCommerce Cart and Checkout Totals

/**
* @snippet       Hide Coupon Code - WooCommerce Cart & Checkout
* @how-to        Get CustomizeWoo.com FREE
* @author        Rodolfo Melogli
* @compatible    WooCommerce 7
* @community     https://businessbloomer.com/club/
*/

add_filter( 'woocommerce_cart_totals_coupon_label', 'bbloomer_hide_coupon_code', 9999, 2 );

function bbloomer_hide_coupon_code( $label, $coupon ) {
   return __( 'Coupon', 'woocommerce' ); // Basically "Coupon: VWXYZ" becomes "Coupon"
}

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: How to Fix the “Cart is Empty” Issue
    For some reason, sometimes you add products to cart but the cart page stays empty (even if you can clearly see the cart widget has products in it for example). But don’t worry – it may just be a simple cache issue (and if you don’t know what cache is that’s no problem either) or […]
  • WooCommerce: Remaining $$$ to Get Free Shipping Notification @ Cart
    This is a very cool snippet that many of you should use to increase your average order value. Ecommerce customers who are near the “free shipping” threshold will try to add more products to the cart in order to qualify for free shipping. It’s pure psychology. So, here’s how we show a simple message on […]
  • WooCommerce: Disable Payment Method If Product Category @ Cart
    Today we take a look at the WooCommerce Checkout and specifically at how to disable a payment gateway (e.g. PayPal) if a specific product category is in the Cart. There are two tasks to code in this case: (1) based on all the products in the Cart, calculate the list of product categories in the […]
  • WooCommerce: Cart and Checkout on the Same Page
    This is your ultimate guide – complete with shortcodes, snippets and workarounds – to completely skip the Cart page and have both cart table and checkout form on the same (Checkout) page. But first… why’d you want to do this? Well, if you sell high ticket products (i.e. on average, you sell no more than […]
  • WooCommerce: Add Privacy Policy Checkbox @ Checkout
    Here’s a snippet regarding the checkout page. If you’ve been affected by GDPR, you will know you now need users to give you Privacy Policy consent. Or, you might need customer to acknowledge special shipping requirements for example. So, how do we display an additional tick box on the Checkout page (together with the existing […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

20 thoughts on “WooCommerce: Hide Coupon Code @ Cart & Checkout Page

  1. Thanks a lot for all these snippets!!!
    One question, right now we have the rows as :
    – PRODUCT
    – SUBTOTAL
    – COUPON
    Is there a simple trick to get:
    – PRODUCT
    – COUPON
    – SUBTOTAL
    Which from my perspective would be much more logical…
    Thanks a lot

    1. Hello Manuel, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  2. Hi Thanks for the snippet. I tried it, but it didn’t work. I used the code snippets plugins for it, maybe that is why? Or has Woocommerce changed too mucht by now? Would you test the snippet please?

    Thanks, I have learned a lot from your site! Elisabeth

    1. Works perfectly, must be something else? Do you have a screenshot for me?

  3. Does not work with a new version of woocommerce, any suggestions?

    1. It works, sorry ๐Ÿ™‚

  4. Awesome-sauce! Thanks so much, your snippets are so freakin useful! Keep it up Rod

    1. Thanks!

  5. This snippet still works – THANK YOU SO MUCH!!

    1. Awesome!

  6. I am doing checkout on the same page as cart and this code did not work for me. I want to know how I can just remove coupon area from the cart area and not from the check out page.

    1. Amir, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  7. Hey Rodolfo, Thank you for all this excellent post about WooCommerceโ€”I use like 20 of your snippets and counting! I have a question related to this post: how can I change the [Remove] text at the end of the line? Maybe with gettext. I searched for an hour now and nobody have written about this on the wide internet.

    1. Hey Peter, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  8. Still works like a charm.

    1. Excellent, thanks Chris!

  9. There is one catch: woocommerce adds css class like , so coupon code may be revealed !

    1. Thanks for your comment Jurasjo, you’re absolutely correct, I just found that out. Hopefully customers are not advanced enough to think if they “Inspect” via Google Chrome they can get the coupon code. Either way, I’m sure there is some additional PHP that can be added to hide the CSS class as well ๐Ÿ™‚

  10. Tnx Rodolf, the snippets works.

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *