WooCommerce: Remove or Rename SALE! Badge

Here’s yet another easy WooCommerce PHP snippet if you wish to completely remove / hide or translate / rename the SALE! badge on the homepage, shop page, category pages and single product pages.

Once again, with a few lines of code (and specifically, the “woocommerce_sale_flash” filter) you can achieve anything you want. Enjoy!

Remove SALE badge from WooCommerce Product Archive and Single Product Pages

PHP Snippet #1: Remove Sale! Label From Products – WooCommerce Shop & Single Product Pages

/**
 * @snippet       Remove SALE badge @ Product Archives and Single Product
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    Woo 4.1
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
 
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );

remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );

// ---------------
// IN ALTERNATIVE TO REMOVE_ACTIONS:

add_filter( 'woocommerce_sale_flash', '__return_null' );

PHP Snippet #2: Rename / Translate Sale! Label – WooCommerce Shop & Single Product Pages

/**
 * @snippet       Rename SALE badge @ Product Archives and Single Product
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    Woo 4.1
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_sale_flash', 'bbloomer_rename_sale_badge', 9999 );

function bbloomer_rename_sale_badge() {
   return '<span class="onsale">ON OFFER</span>';
}

// NOTE: PLEASE KEEP THE <SPAN> TAG

Is there a plugin for that?

If you’d love to code but don’t feel 100% confident with PHP, I decided to look for reliable plugins that achieve the same result. As usual, I’ve chosen WooCommerce plugin vendors based on marketplace reputation, dedicated support quality, code cleanliness, long-term reliability and – probably almost as importantly – where the “people behind” the plugin are active supporters of the WordPress ecosystem.

1. WooCustomizer

Sold by: WooCustomizer – Developed by: Zack Viljoen – 14 Day Money Back Guarantee

Editing the “SALE!” badge is one of the features of WooCustomizer, a plugin built for everyone who wants to fully customize their WooCommerce store without coding (e.g. edit buttons, badges, tabs, pages, stock display, checkout fields).

2. YITH WooCommerce Badge Management

Sold by: YITH – Developed by: YITH – 30 Day Money Back Guarantee

On top of displaying custom text badges (free version), you can also create CSS, image and advanced badges, assign product badges to specific products and/or categories, pick the badge position and much more.

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

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.

38 thoughts on “WooCommerce: Remove or Rename SALE! Badge

  1. Hi,
    I only want the sale badge to be removed on single product page (specifically on the product image). How can i accomplish this?

    Thanks,

    Sina

  2. Hi Rodolfo. This code works perfect if I use it on my child theme functions.php file.
    However, I’m trying to use it in a custom plugin but it doesn’t work. Should I have to add some other action?
    Thanks in advance

    1. I’m using understrap theme. I just try the code for Storefront theme in my plugin and it works.

      1. Cool. If you place it in a plugin you’d need some customization maybe

  3. This code doesn’t seem to work if you are displaying using the WooCommerce Blocks, e.g. the block “Products by Category” ? Can anyone else confirm/deny this?

    1. I don’t really use blocks for products, just plain shortcodes

      1. The code works for Astra theme | wordpress | PHP 7 | woocommerce 4.1

        Thanks a lot !

        1. Nice!

  4. I had the badges removed, but have made changes including upgrading to latest Woocommerce and using Code Snippet. I am using variable products (school books Grades 1-8). Buy more than 9 books, get lower price. But once that is added to cart, “Sale” badge appears on product itself and when shown with other products as a related product. Is the code intended to work with variable products? If so, any suggestions? Thanks.

    1. Hi Rob, for default WooCommerce it works no matter the product type. Not sure if you have custom theme or plugins that override that behavior?

  5. Hi Rodolfo; If I had have the woocommerce programming knowledge you have I would be singing right now. I managed to rename and relink the shop and archive pages’ sales badge to ‘View Product’, which when clicked on routes to the single products page.

    I would like to accomplish the same for the storefront homepage but for the life of me I am not able to do that. Do you know what hook I should use for that?

    I would greatly appreciate your guidance.

    Thanks a billion.

    Lode

    1. Hey Lode, 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!

  6. Just used this code (wordpress version 5.2.3), worked perfectly.
    Thanks so much Rodolfo!

    1. Excellent!

  7. Well done mate. Code worked straight away.

    1. Thank you!

  8. it still works awesome and at last thanks.
    wordpress version 5.0.3 as 12/2/2019.

    1. Great!

  9. Rodolfo, this worked perfectly. Thanks!

    1. Awesome 🙂

  10. how to add lable badge for instance new and any custom text without plugins

  11. Hello, Rodolfo!
    First of all thanks for all great job that you do here.

    I have a question. I want to remove a sale flash on a shop page and after adding your snippet to my theme’s functions.php nothing had changed – the sale flash is still there.

    I’m using a Storefront theme.

    The snippet I’ve added:

     remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 ); 

    What might me a problem?

    Thanks

    1. Hello Iryna, thanks for your comment 🙂 I’ve updated the page with a second snippet specific to Storefront theme. Hope this helps

  12. Code works but I wanted to combine it with code provided in your conditional logic page that you linked. I cannot seem to get it to work tho. What I tried was this:

     
    add_action( 'woocommerce_after_single_product_summary', 'bbloomer_single_product_type' );
     
    function bbloomer_single_product_type() {
     
    if( $product->is_type( 'variable' ) ){
     /**
     * @snippet       Remove SALE badge @ Product Archives and Single Product
     * @how-to        Get CustomizeWoo.com FREE
     * @sourcecode    https://businessbloomer.com/?p=17429
     * @author        Rodolfo Melogli
     * @compatible    WooCommerce 3.2.3
     */
     
    remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
    remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
    } 
     
    }
    

    I added this code as one of my snippets. What happened is that the sake flash was still there but the images on all product pages where removed? What I wanted to do was use this logic but on a product type called “smart bundle” that I use a plugin to create. I thought I’d debug by trying a standard product type from Woocommerce and this is the result. Why can’t I combine the code lines like this?

    Thanks in advance!

    1. Hey Niklas, thanks so much for your comment! I think you’re trying to access $product without declaring it first. Try adding this to the beginning of the function (also, please take the comments out and place them outside the PHP, they’re not great there):

      global $product;
      
  13. Is there a way to do this selectively? Where it the sale “icon” doesn’t appear for small discounts like 10-20%? But will appear on discounts of say 50% and more to indicate “Clearance”?

    Thanks, I know this post is old and I may not get a reply.

  14. Yes it works! Thnx.

  15. Hello Rodolfo,

    I placed the above code at the end of my Child Theme’s functions.php file. It gave an overall error poping below message;

    ‘HTTP 500 error
    That’s odd… the website can’t display this page’

    What could have gone wrong?

    1. Tory, thanks for your comment! Not sure… have you pasted the code after “?>” maybe? It should be before that line.

  16. Hi.. I tried your snippet it removes the sale badge only in the single product page.

    Sale badge is still visible on the shop page.

    I dont wanna use css bcoz i am trying to hide the sale badge only for the users who are not logged in

    1. Hey Santhosh thanks for your comment! The only reason one works and the other doesn’t is that your theme is overriding the default WooCommerce functionality – both actions come from WooCommerce code. Take a look through your theme’s functions and see if you need to tweak something in the remove_action 🙂 Hope this helps!

  17. Hi … I read your post about removing the Sale box on woo commerce and put in the code below on my theme’s ccs box and it did not work … am I missing something

    remove_action( ‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_show_product_loop_sale_flash’, 10 );
    remove_action( ‘woocommerce_before_single_product_summary’, ‘woocommerce_show_product_sale_flash’, 10 );
    }

    I very much appreciate your advice. Jan

    1. Hey Jan thanks for your comment 🙂 There is a chance that your theme, Jupiter, is adding custom sale badges and therefore the WooCommerce remove_action won’t work. Can you look through the files of your theme (File Search) for this string “woocommerce_show_product_sale_flash” and let me know what you’ve found?

      1. Jan – you put this in the CSS? It should go in the functions.php file.

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. 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 BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published.