WooCommerce adds sale badge to the items that are on sale, means product sale price is lower than the actual price. By default WooCommerce, Sale badge text is 'Sale!' You can replace 'On Sale' text with your text, sale badge design will inherit from your theme style. The WooCommerce Customizer Plugin. Once you install and activate the free plugin, you will find a customizer tab in your WooCommerce settings. How to Change the Cart Button Text on Your WooCommerce Shop Page. First off, you have options to change the cart button text on the four types of products.
WooCommerce - hide the coupon form on the cart or checkout page, but leave coupons enabled for use with plugins like Smart Coupons and URL Coupons
wc-hide-coupons-cart-checkout.php
<?php |
// hide coupon field on cart page |
functionhide_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 |
functionhide_coupon_field_on_checkout( $enabled ) { |
if ( is_checkout() ) { |
$enabled=false; |
} |
return$enabled; |
} |
add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_checkout' ); |
commented Aug 22, 2015
where do I add this? |
commented Sep 28, 2015
In your function.php (in theme folder) |
commented May 13, 2016 • edited
edited
Anyone see a hook for hiding it from a specific user role? I have Pro MUA as a user role and I need to hide the coupon from them. I added the following but it's not working `function woo_get_user_role() { global $current_user; $user_roles = $current_user->roles; $user_role = array_shift($user_roles); return $user_role; } function hide_coupon_field_on_cart( $enabled ) { if(woo_get_user_role() 'pro_mua_customer' && is_cart() || is_checkout() ) { $enabled = false; } return $enabled; } add_filter( 'woocommerce_coupons_enabled', 'hide_coupon_field_on_cart' );` |
commented Jan 19, 2017 • edited
edited
Works a treat! Just make sure to remove the first line <?php from this code snippet if it's already in your functions.php file. You want to paste this code snipper just before the last line of the functions file which should be ?> |
commented Aug 16, 2017
Thanks ;) |
commented Aug 29, 2017 • edited
edited
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? |
commented Oct 19, 2017
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? |
commented Oct 25, 2017
Ah, very nice piece of code. Thanks! |
![Custom Custom](/uploads/1/2/4/9/124905882/856572275.png)
commented Dec 12, 2017
Very Nice code |
commented Jan 8, 2018
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 |
commented Jan 25, 2018
thanks |
commented May 12, 2018
thank you. works great on checkout! |
commented May 29, 2018
Thanks - this still works with Woocommerce 3.4 and Wordpress 4.9.6 :) |
commented Nov 3, 2018 • edited
edited
What if my checkout and cart on the same page, and i want hide it only on checkout? what code i can use? |
commented May 15, 2019
@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 ); } |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
So, I thought I could change this with tried with applying
this was CSS and it didn't work, So I started to find where it was on the php's
I have a wordpress set up so i went on to
cart.php
and coupon.php
I'm not used to the php environment at all, so I got dizzy after looking at the % $ symbols after 30 minutes skimming all the content.
I'm currently only trying to find how to change this placeholder text, and unable to do so.
Thanks
user23425581,76311 gold badge1212 silver badges2828 bronze badges
bartbart
2 Answers
Lets say in coupon.php you have the following :
Change the
placeholder='<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>'
: Where you see your placeholder text here , thats where you change it.
YlamaYlama
The preferred method for changing text in WooCommerce or any plugin for that matter is to use the gettext filter. It better to use a filter rather than edit the templates because templates can be changed when WooCommerce is updated. Place the following code in your functions.php file for a more future proof solution.
Andrew SchultzAndrew Schultz2,71622 gold badges99 silver badges3131 bronze badges