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
- Log into your WordPress site and access the Dashboard as the admin user.
- 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.
- 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' );
- This is the outcome:
- 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; }
- Open the Customizer and click Additional CSS, as shown in the screenshot below:
- 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:
- Log into your WordPress site and access the Dashboard as the admin user.
- 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.
- 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
Steps to Replace the Sale Badge Text with an Image in the WooCommerce Storefront Theme
Here are the steps that you need to follow:
- Log into your WordPress site and access the Dashboard as the admin user.
- 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.
- 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; }
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.
Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
Similar Articles
- How to Add Submenu to Custom Post Type Menu in WordPress
- How to Use WooCommerce Product Attributes Step by Step [Complete Guide]
- How to Hide Category WooCommerce Storefront Theme
- How to Change Font Size WooCommerce Storefront Theme
- How to Customize Storefront Checkout Page
- How to Remove Cart Page WooCommerce Storefront Theme
- How to Change Storefront Theme Order of Products
- How to Add GTIN Numbers On Products In WooCommerce
- How to Turn off Next Product Tabs In WooCommerce Storefront
- How to Change Storefront Number of Products Per Row
- How to Hide Mobile Footer From Storefront WooCommerce
- How to Remove Related Products WooCommerce Storefront Theme
- How to Hide Tags In Storefront Theme WooCommerce
- How to Add Categories to WooCommerce Products
- How to Remove Cart from Storefront Theme Header
- How to Hide All Products From Shop Page in WooCommerce
- How to Change Products per Page WooCommerce Storefront Theme
- Hide or Remove the Quantity Field from WooCommerce Product Page
- How to Change Storefront Theme Product Page Tabs Colors