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!
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"
}
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
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!
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
Works perfectly, must be something else? Do you have a screenshot for me?
Does not work with a new version of woocommerce, any suggestions?
It works, sorry ๐
Awesome-sauce! Thanks so much, your snippets are so freakin useful! Keep it up Rod
Thanks!
This snippet still works – THANK YOU SO MUCH!!
Awesome!
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.
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
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.
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
Still works like a charm.
Excellent, thanks Chris!
There is one catch: woocommerce adds css class like , so coupon code may be revealed !
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 ๐
Tnx Rodolf, the snippets works.
Awesome ๐