Coupons: the good, the bad and the ugly. WooCommerce coupon codes are great to convert more sales – but sometimes they get users to pause / stop placing the order until they find a coupon code online (you did it too, I know).
One good workaround that the internet giants such as Amazon and eBay have implemented is to hide the coupon form until an email is entered, or alternatively to move the coupon code to the bottom of the Checkout page. This is a very smart move, and gets the user to concentrate on the Cart / Checkout details before entering or searching for a coupon.
So the question is – how to remove the coupon form in the Cart page and how to move the same to the bottom of the Checkout page? Well, as usual, a bit of PHP can help us. Here’s how it’s done!
PHP Snippet 1: Hide Coupon Form @ WooCommerce Cart Page
/**
* @snippet Remove Coupon Form @ WooCommerce Cart
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 6
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_coupons_enabled', 'bbloomer_disable_coupons_cart_page' );
function bbloomer_disable_coupons_cart_page() {
if ( is_cart() ) return false;
return true;
}
PHP Snippet 2: Move Coupon Form @ WooCommerce Checkout Page
/**
* @snippet Remove Coupon Form @ WooCommerce Checkout (Top)
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 6
* @community https://businessbloomer.com/club/
*/
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
/**
* @snippet Display Coupon Form @ WooCommerce Checkout (Bottom)
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 6
* @community https://businessbloomer.com/club/
*/
add_action( 'woocommerce_review_order_after_submit', 'bbloomer_checkout_coupon_below_payment_button' );
function bbloomer_checkout_coupon_below_payment_button() {
echo '<hr>';
woocommerce_checkout_coupon_form();
}
This customization makes the page reload instead of only doing ajax refresh. Is it possible to disable the page reload?
Nico, 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!
A quick solution not needing code is to hide the coupon field through the WooCommerce settings.
In the backend: Go to WooCommerce -> Settings -> General and uncheck “Enable coupons”.
It hides the field from the Cart and Checkout pages.
Thanks Paal!
Hi, I’ve found this solution (it’s not my code), looks like it work good, what do you think?:
If it works for you, it works for us!
I adjusted the code a little in order to hide the coupon box on the cart & checkout if there are no published coupons:
Nice
Hi Rodolfo
I added the move coupon to the cart, and the hide coupon in the checkout and both worked great.
As always, thank you very much!!!
Great!
Regarding hiding it from the cart page, I successfully used the snippet from here:
https://www.tychesoftwares.com/how-to-hide-the-woocommerce-coupon-code-field/
Are there any pitfalls to this? Should I be hiding via CSS instead?
Thank you so much for this website and sharing your knowledge. It’s much appreciated, Rodolfo!
Hi Jodi, if you wish to “move” it, then you can’t use that function because it hides from anywhere in the Cart. If you wish to completely remove it, then yes, that’s ok
Okay, thank you. I think this is okay for now because I’m using discounts that are automatically applied. If I ever have the need to enter a coupon code, hopefully I remember how I hid it π
Nice!
Hi Rodolfo,
I tried to apply your code in my WooCommerce check out & cart page but came in to some issue:
1. in the cart page i see the “coupon code” field twice
2. I managed to hide the “Have a coupon code” line but i didn’t succeed to move it to the payment area
Any idea why?
Thanks,
Gabriel
Could be due to your custom theme. Can you try with Storefront for a moment?
Hi there, Afraid none of the snippets didn’t work on my woocommerce. Maybe this is because of the latest updates or so. I’me newbie to this and look for relocating the coupon form. Any other suggestions?
Where did you place them?
I use the snppet to remove the “Have a coupon” field from the cart page and it worked. I added it to the additional CSS space and it worked. Thanks for this. It saves me a lot of stress.
Cool
If you use this technique you will lose the error message to apply a promo code if someone blankly hits the apply code button. You will need to write a fix for that depending on how you use this.
Ok thank you Stef
Worked like a charm.
Your website has been very resourceful in helping me make some checkout page tweaks.
Thanks Rod,
Thanks Gil!
Is it possible to make it disappear only for a specific product?
Yes, of course
Thank you so much. It worked! from Japan.
Arigato!
Hello, Rodolfo Is there a way to make coupon form work and update with ajax on any other places but cart or checkout page (for example, within off-canvas shopping cart)? I’ve added the form to my cart panel widget by pasting part of your code … so applying the coupons works well, but it redirects me to the cart page immediately. How your snippet can be adapted to work without redirecting and refreshing a page?
Yaroslav, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R
Hi, i believe this will sort out the Ajax bit. It does require some modifying but what this does is bring the scripts that are used on the checkout, onto the cart page.
All credit to the respective owner on stack overflow : https://stackoverflow.com/questions/46736095/move-the-coupon-field-to-the-cart-totals?rq=1
Add this to the cart totals where you want the coupon to go
NICE! Thank you
If the coupon form is removed from Checkout, it’s possible that some users will never see the coupon form.
That’s because in Storefront, hovering over the shopping cart icon displays a menu with two options: View cart or Checkout. If user chooses Checkout, will not see the Shopping Cart page. If that’s the only place where the coupon form appears, a user trying to enter a coupon code will be frustrated.
Good point David π You could force people to pass through the Cart first or find another workaround, anyway this snippet applies only to some businesses while some others won’t need this. Thank you
These snippets worked fine for us and really improved both our cart and checkout pages, keeping users focused on making their purchases rather than trying to find out where they might find discount codes. We only use discount codes for a handful of items and we let people know if they’re eligible for discounts. We only needed a small amount of our own styling and added a piece of text above the coupon box to say ‘If you have been provided a coupon code, please enter it before proceeding to checkout:’. Thank you, we always review your write-ups for helpful tips and appreciate the time you put into them.
Thanks so much Kim π
Hello Rodolfo,
I think this action should work fine to move coupon field
remove_action( ‘woocommerce_before_checkout_form’, ‘woocommerce_checkout_coupon_form’, 10 );
REMARK: Thereβs only one other place to re-add it: below the entire checkout form. This is because it canβt be nested inside of the checkout form without affecting the βPlace Orderβ button. You could add it at the end of the form if desired by then adding this snippet:
add_action( ‘woocommerce_after_checkout_form’, ‘woocommerce_checkout_coupon_form’ );
Hello Fabio π Doesn’t that break the coupon code form JS? I tried in different positions but would have had to revise the WooCommerce JS to also make it work – hence why I just decided to remove it
Hi,
Why don’t use jQuery to move the form?
$( “#checkout_coupon” ).insertAfter( “.where_you_want” );