21

I am trying to remove the "Have a coupon" section that sits at the top of a Woocommerce checkout page (/checkout).

I would like to keep the coupon section on the Cart page, so I can't completely disable coupons, but would like it removed on the checkout page.

Any help would be greatly appreciated.

Wes Asbell
  • 273
  • 1
  • 4
  • 8

2 Answers2

47
remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); 

Put this in your functions.php and this should do it.

Reigel Gallarde
  • 64,198
  • 21
  • 121
  • 139
13

There is two way one is already given in this question by Reigel.

If it is not working below is another code:

function hide_coupon_field_on_cart( $enabled ) {
if ( is_checkout() ) {
    $enabled = false;
}
return $enabled;
}
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' );
Akshay Shah
  • 3,391
  • 2
  • 20
  • 33
  • This is clever but it does require more processing than Reigel's. So I have up-voted his. – Kodaloid Sep 14 '17 at 11:58
  • True i have given you another option that is it not for upvote i am giving the answers – Akshay Shah Sep 14 '17 at 11:59
  • Thanks. For some reason the other answer did not work for me. – imlokesh Oct 05 '18 at 13:59
  • 2
    Less code: `function hide_coupon_field_on_cart( $enabled ) { return !is_checkout(); }` – Artyom Fedosov Apr 27 '19 at 09:01
  • Thanks for the alternate answer, yours worked for me – Kolawole Emmanuel Izzy May 24 '19 at 15:33
  • 1
    This indeed means more computations, but also allows to use other conditions, for example, i'm using this if a coupon was registered before the checkout page. ``` function hide_coupon_field_on_cart($enabled) { global $woocommerce; $applied_coupons = $woocommerce->cart->get_applied_coupons(); if (is_checkout() && !empty($applied_coupons)) { $enabled = false; } return $enabled; } ``` Thanks – Ido_f Apr 03 '20 at 16:00
  • The first solution didn't work for me, this one (the second) work like a charm thanks ! – G.Lebret Jun 30 '22 at 22:28