Posted on

WooCommerce: Remove SALE! Badge Everywhere

Here’s yet another WooCommerce simple PHP snippet if you wish to completely remove / hide the SALE! badges on the homepage, shop page, category pages and single product pages. Once again, wit a few lines of code you can achieve anything you want!

Remove SALE badge from WooCommerce Product Archive and Single Product Pages

PHP Snippet #1: Remove Sale Label on Products – WooCommerce


/**
 * @snippet       Remove SALE badge @ Product Archives and Single Product
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/?p=17429
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.4.5
 */

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 );

PHP Snippet #2: Storefront Theme: Remove Sale Label on Products – WooCommerce


/**
 * @snippet       Storefront: Remove SALE badge @ Product Archives
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @sourcecode    https://businessbloomer.com/?p=17429
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.4.5
 */

add_action( 'wp', 'bbloomer_remove_storefront_actions' );

function bbloomer_remove_storefront_actions() {
   remove_action( 'woocommerce_after_shop_loop_item_title',      'woocommerce_show_product_loop_sale_flash', 6 );
}

“I don’t code – is there a reliable plugin for that?”

As many readers would love to code but don’t feel 100% confident with it, I decided to look for a reliable plugin that achieves the same (or even better) result.

In this case, I recommend the YITH WooCommerce Badge Management plugin. 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.

But in case you wish to code, keep reading 🙂

Where to add this code?

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

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.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free videos, tutorials and tips!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP
  • woocommerce-customize-shop-page-PHP
  • woocommerce-advanced-customization
  • how-to-edit-woocommerce-cart
  • woocommerce-customize-checkout-page-PHP
  • woocommerce-email-customization
  • woocommerce-conditional-logic

Rodolfo Melogli

Author, WooCommerce expert, WordCamp speaker and Internet marketer, Rodolfo Melogli has worked as a WooCommerce freelancer since 2011. He helps entrepreneurs and developers overcome their WooCommerce nightmares :) Rodolfo is the organiser of WordCamp Dublin, the Dublin WooCommerce Meetup, the Dublin Ecommerce Meetup and the Dublin WordPress Meetup. He enjoys interacting with people, travelling and chasing tennis & soccer balls. Of course, he loves pizza too.

15 thoughts on “WooCommerce: Remove SALE! Badge Everywhere

  1. 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

  2. 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        Watch tutorial @ https://businessbloomer.com/?p=19055
     * @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;
      
  3. 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.

  4. Yes it works! Thnx.

  5. 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.

  6. 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!

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

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

Questions? Feedback? Support? Leave your Comment Now!
If you're writing code, please wrap it between: [php] code_here [/php]

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.