WooCommerce: Move / Remove Coupon Form @ Cart & Checkout

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!

Here’s how to move the coupon form to the bottom of the WooCommerce Checkout page. You also find a quick snippet for removing the same from the WooCommerce Cart page.

PHP Snippet 1: Hide Coupon Form @ WooCommerce Cart Page

/**
 * @snippet       Remove Coupon Form @ WooCommerce Cart
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @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        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @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        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @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();
}

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: “You Only Need $$$ to Get Free Shipping!” @ 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. Here’s how we show a simple message on 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: 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: 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

37 thoughts on “WooCommerce: Move / Remove Coupon Form @ Cart & Checkout

  1. 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.

  2. Hi, I’ve found this solution (it’s not my code), looks like it work good, what do you think?:

    remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 );
    add_action( 'woocommerce_review_order_after_order_total', 'woocommerce_checkout_coupon_form_custom' );
    function woocommerce_checkout_coupon_form_custom() {
        echo '<tr class="coupon-form"><td colspan="2">';
        
        wc_get_template(
            'checkout/form-coupon.php',
            array(
                'checkout' => WC()->checkout(),
            )
        );
        echo '</tr></td>';
    }
    
    1. If it works for you, it works for us!

  3. I adjusted the code a little in order to hide the coupon box on the cart & checkout if there are no published coupons:

    // Hide Coupon Field on Cart if no Published Coupons
    function bse_disable_coupon_field_on_cart( $enabled ) {
    	$count_posts = wp_count_posts( 'shop_coupon' )->publish;
    	if ( is_cart() && $count_posts == '0' ) {
    		$enabled = false;
    	}
    	return $enabled;
    }
    add_filter( 'woocommerce_coupons_enabled', 'bse_disable_coupon_field_on_cart' );
    
    // Hide Coupon Field on Checkout if no Published Coupons
    function bse_disable_coupon_field_on_checkout( $enabled ) {
    	$count_posts = wp_count_posts( 'shop_coupon' )->publish;
    	if ( is_checkout() && $count_posts == '0' ) {
    		$enabled = false;
    	}
    	return $enabled;
    }
    add_filter( 'woocommerce_coupons_enabled', 'bse_disable_coupon_field_on_checkout' );
    
  4. 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!!!

    1. Great!

  5. 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!

    1. 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

      1. 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 🙂

        1. Nice!

  6. 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

    1. Could be due to your custom theme. Can you try with Storefront for a moment?

  7. 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?

    1. Where did you place them?

  8. 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.

    1. Cool

  9. 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.

    1. Ok thank you Stef

  10. Worked like a charm.
    Your website has been very resourceful in helping me make some checkout page tweaks.
    Thanks Rod,

    1. Thanks Gil!

  11. Is it possible to make it disappear only for a specific product?

    1. Yes, of course

  12. Thank you so much. It worked! from Japan.

    1. Arigato!

  13. 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?

    1. 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

    2. 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

      wc_get_template( 'checkout/form-coupon.php', array( 'checkout' => WC()->checkout() ) );
      
      
       
      
      // Add the checkout scripts to cart in order for Ajax to work
      function enqueue_woo_scripts() {
      
          if( is_cart() ) {
              if( ! wp_script_is( 'wc-checkout', 'enqueued' ) )
                  wp_enqueue_script( 'wc-checkout' );
          }
      }
      add_action( 'wp_enqueue_scripts', 'enqueue_woo_scripts' ); 
      1. NICE! Thank you

  14. 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.

    1. 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

  15. 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.

    1. Thanks so much Kim 🙂

  16. 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’ );

    1. 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

    2. Hi,
      Why don’t use jQuery to move the form?

      $( “#checkout_coupon” ).insertAfter( “.where_you_want” );

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 *