How to hide “Sale-Flash” from Products on your WooCommerce store?

Clark has a WooCommerce store, in which he has offered discounts on some of the products. By default, the discounted price is shown with the regular price stricken out, and with Sale-flash, as shown in the screenshot below.

Further, Clark wants to hide the Sale-flash.

Here’s how Clark can hide the Sale-Flash  from Products:

The following code snippet is to be added to hide the Sale-Flash from all the products. This code snippet works only for discounts (or price adjustments) made using Dynamic Pricing and Discounts Plugin for WooCommerce or WooCommerce Catalog Mode, Wholesale & Role Based Pricing plugins.

Add the code snippet to the functions.php file of your website theme.

// Display woocommerce_sale_flash only when there is sale price 
add_filter( 'woocommerce_sale_flash', 'filter_woocommerce_sale_flash', 10, 3 ); 
function filter_woocommerce_sale_flash( $span_class_onsale_esc_html_sale_woocommerce_span, 
$post, $product ) {
return $product->get_sale_price() ? $span_class_onsale_esc_html_sale_woocommerce_span : ''; 
};

If you wish to hide the sale flash completely from your WooCommerce store, regardless of any plugin, use the following code snippet.

//Remove woocommerce_sale_flash completely
 add_filter('woocommerce_sale_flash', 'woo_custom_hide_sales_flash');
 function woo_custom_hide_sales_flash()
 {
 return false;
 }

Tip: The above code snippet can also be added if you are offering products at the sale price for a long period of time, and do not want the sale-flash for such a long period. Or, the sale-flash does not match your website theme or any other such case where you wish to hide sale-flash.

Here’s how Clark’s shop will look after the code snippet is added.

 

For any queries, feel free to contact our support team.

Leave a Reply