skip to Main Content

The following works for the Product page but it does not work for the Shop page.

<?php
add_filter('woocommerce_sale_flash', 'woocommerce_custom_sale_text', 10, 3);
function woocommerce_custom_sale_text($text, $post, $_product)
{
    return '<span class="onsale">PUT YOUR TEXT</span>';
}

Please suggest modifications.
Thanks!

2

Answers


  1. I tried your code and it works perfectly for the shop page as well. You may try increasing the priority or it can be a conflict with some other plugin or theme.

    You may also check the following file to confirm it has applied the woocommerce_sale_flash filter

    woocommercetemplatesloopsale-flash.php
    
    Login or Signup to reply.
  2. Use This

    add_filter( 'woocommerce_sale_flash', 'wooc_custom_replace_sale_text' );
    function wooc_custom_replace_sale_text( $html ) {
    return str_replace( __( 'Sale!', 'woocommerce' ), __( 'Your Text', 'woocommerce' ), $html );
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search