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    WooCommerce 7
 * @community     https://businessbloomer.com/club/
 */
 
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 USE THIS ONLY

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    WooCommerce 7
 * @community     https://businessbloomer.com/club/
 */

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 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 Visual Hook Guide: Single Product Page
    Here’s a visual hook guide for the WooCommerce Single Product Page. This is part of my “Visual Hook Guide Series“, through which you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can copy/paste). If you like this guide and it’s helpful to you, let me know in the comments! […]
  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • WooCommerce Visual Hook Guide: Archive / Shop / Cat Pages
    I’ve created a visual HTML hook guide for the WooCommerce Archive Page (which is the same page for the Shop, Category, Tag pages). This visual guide belongs to my “Visual Hook Guide Series“, that I’ve put together so that you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can […]
  • WooCommerce: Hide Prices on the Shop & Category Pages
    Interesting WooCommerce customization here. A client of mine asked me to hide/remove prices from the shop page and category pages as she wanted to drive more customers to the single product pages (i.e. increasing the click-through rate). As usual, a simple PHP snippet does the trick. I never recommend to use CSS to “hide” prices, […]

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

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.

    1. Hey Chan, thanks for your comment! I suggest you take a look at “conditional logic”: https://businessbloomer.com/conditional-logic-woocommerce-tutorial/ and https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/. Let me know πŸ™‚

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