-
-
Save maxrice/8550827 to your computer and use it in GitHub Desktop.
<?php | |
// hide coupon field on cart page | |
function hide_coupon_field_on_cart( $enabled ) { | |
if ( is_cart() ) { | |
$enabled = false; | |
} | |
return $enabled; | |
} | |
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' ); | |
// hide coupon field on checkout page | |
function hide_coupon_field_on_checkout( $enabled ) { | |
if ( is_checkout() ) { | |
$enabled = false; | |
} | |
return $enabled; | |
} | |
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_checkout' ); |
just want to ask to be sure: It would be best to create a child theme for woocommerce for the cart and/or checkout pages and then put this code in the functions.php of those themes, correct?
Ah, very nice piece of code. Thanks! 👍
Very Nice code
Hello, i have a question. i configured a rule on my woocomerce->coupon (for example apply a coupon discount when min spend is 27$). Now when I want to pay the bill, always appear: do you have any coupon? please enter the code....... Then i only want that this message appear only when the bill is >27$. How can i do it?
Thanks
thanks
thank you. works great on checkout!
Thanks - this still works with Woocommerce 3.4 and Wordpress 4.9.6 :)
What if my checkout and cart on the same page, and i want hide it only on checkout? what code i can use?
@TGurgen, use
function hide_coupon_field_on_cart( $enabled ) { if ( is_cart() ) { $enabled = false; } return $enabled; } add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' );
And
add_action( 'woocommerce_before_checkout_form', 'remove_checkout_coupon_form', 9 ); function remove_checkout_coupon_form(){ remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); }
@KoolPal, sorry, can you tell, how can i hide it, if i want to remove coupon field only after the cart and the cart and checkout is on the same page?
Works great as of Jan. 2020!
I have woocommerce site running woocommerce memberships and I am trying to disable to coupon entry box in both the cart and checkout for members only. Non members should still see the coupon entry box and be able to use coupons, but people with a membership should not see it at all.I want to do this with a code snippet. Anyone can help me ?
Works perfectly. Kudos
Say I'd like to hide it only when I already have a coupon applied. Can that be done editing this code?
Gracias! Funciona perfecto en feb. 2023
I have a problem. I've placed this code and everything seems to work fine.
But when I add a product with a discount coupon through URL Coupons to the Cart, the "Remove" link stops working (The one that removes the coupon from the product). In the checkout page the "Remove" link works fine.
What can happen? Does anyone have any help, please?