• Hi,

    I use “hand-picked products” block which is in the core of Woocomerce v6.9.4 on WordPress 6.0.2. My plugin utlizes woocommerce_sale_flash filter hook to update “Sale” label (adds discount percentage to label).
    Although this hook works in shop or product archive pages it is not called in hand-picked products block.
    Is there a way to call a hook or do something else to customize Sale label in the product listing blocks?

    Thanks.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @kaanb

    Thanks for reaching out!

    I understand that the woocommerce_sale_flash filter hook to update the “Sale” label is not working when using the Hand-Picked Products block.

    I was able to replicate the scenario on my test site.

    On the shop page:

    Image Link: https://snipboard.io/4cIyCu.jpg

    On another page using the Hand-Picked Block:

    Image Link: https://snipboard.io/Vlnj7U.jpg

    Meanwhile, can you please share here the code for us to check this further?

    Thread Starter OldCoffeeMan

    (@kaanb)

    Hi @xue28

    Thanks for your reply. Yes, woocommerce_sale_flash hook does not work in Hand-picked Products block.

    The code snippet is below and I attach two screen shots for shop page which displays modified label via hook correctly and Hand-picked Products Block wihich does not call hook and does not display modified label for the same product.

    function go_custom_sale_label( $label, $post, $product ){
        
        error_log("Original sale label is $label");
        return  '<span class="onsale">X% Discount</span>';     //Simplified for demo purposes
        
    }
    
    add_filter( 'woocommerce_sale_flash', 'go_custom_sale_label', 10, 3 );

    Shop Page
    https://prnt.sc/_HsvvLmeuHHP

    Hand-picked Block
    https://prnt.sc/9OJYXT9tLWfC

    Thanks for your help,

    • This reply was modified 2 years, 5 months ago by OldCoffeeMan.
    • This reply was modified 2 years, 5 months ago by OldCoffeeMan.
    • This reply was modified 2 years, 5 months ago by OldCoffeeMan.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hook does not work for changing Sale label in Hand-picked products block?’ is closed to new replies.