How to Remove or Rename Sale Badge WooCommerce Storefront

Storefront Remove or Rename Sale Badge

WooCommerce allows you to offer discounts on the products of your choice. WooCommerce automatically adds a Sale badge to the products.

The intention is to attract the attention of visitors to your store.

Storefront Remove or Rename Sale Badge

However, there are instances when you want to offer a discounted product straight away without attracting the user’s attention. Additionally, you might want to customize the sale badge to make it look attractive.

In this article, I will show you how to remove and rename the sale badge. Moreover, I will share how you can replace the sale badge with an image.

Steps to Completely Remove the Sale Badge from Products in the WooCommerce Storefront Theme

  1. Log into your WordPress site and access the Dashboard as the admin user.
  2. From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file to remove the sale badge from products.
  3. Add the following code to the functions.php file of the Storefront theme.
/**

 *          Remove SALE badge @ Product Archives and Single Product

*/

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' );
  1. This is the outcome:remove on sale badge
  2. Alternatively, you can use CSS to achieve the same result. You can add the CSS snippet using the WordPress Customizer.
.woocommerce span.onsale{

display:none;

}
  1. Open the Customizer and click Additional CSS, as shown in the screenshot below:remove on sale badge using CSS
  2. The sale badge will now be hidden from the shop and product pages. You can click on the Publish button to save the changes.

Steps to Rename the Sale Badge on the WooCommerce Storefront Theme and Single Product Pages

Here are the steps that you need to follow:

  1. Log into your WordPress site and access the Dashboard as the admin user.
  2. From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file to rename the sale badge.
  3. Add the following code to the functions.php file of the Storefront theme.
/**

*       Rename SALE badge @ Product Archives and Single Product

*/

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

function njengah_rename_sale_badge() {

return '<span class="onsale">ON OFFER</span>';

}

// NOTE: PLEASE KEEP THE <SPAN> TAG
  1. This is the outcome:rename sale badge

Steps to Replace the Sale Badge Text with an Image in the WooCommerce Storefront Theme

Here are the steps that you need to follow:

  1. Log into your WordPress site and access the Dashboard as the admin user.
  2. From the Dashboard menu, click on Appearance Menu > Theme Editor Menu. When the Theme Editor page is opened, look for the theme functions file to replace the sale badge text with an image.
  3. Add the following code to the functions.php file of the Storefront theme.
add_filter('woocommerce_sale_flash', 'njengah_custom_sales_badge');

function njengah_custom_sales_badge() {

$img = '<img width="100px" height="100px" src=" http://127.0.0.1/wordpress/wp-content/uploads/2020/10/sale-tag.png"></img>';

return $img;

}
  1. This is the outcome:replace sale badge with image

Conclusion

Sale Badges in your WooCommerce store are a great way to attract the attention of potential customers.

It may work well for some store owners, but some might consider it unnecessary.

This post has shared ways to remove the WooCommerce sale badge using a code snippet and CSS. Moreover, I have shared how you can replace the sale badge text with an image.

However, if you are not comfortable handling code, I recommend that you use plugins like YITH Badge Management Plugin or WooCommerce Advanced Product Labels.

Similar Articles