Change the Label text for specific Product badges

This topic has 1 reply, 1 voice, and was last updated 2 hours, 4 minutes ago ago by dybwpath

  • Avatar: dybwpath
    dybwpath
    Participant
    October 5, 2024 at 20:45

    I managed to change the Label text for the Product Badge in the Customize > Woocommerce > Shop Elements > Product Badges > Label text

    But I want for a specific product to have a specific text.

    I tried to achieve this with code, but I did not managed to target the label text.

    I used this code, but it didn’t change anything:

    // Change the sales badge text based on the product
    add_filter( ‘woocommerce_sale_flash’, ‘custom_sale_badge_text’, 10, 3 );

    function custom_sale_badge_text( $html, $post, $product ) {
    // Check the product ID
    if ( $product->get_id() === 123 ) { // Replace 123 with the desired product ID
    $html = ‘Special Discount!‘; // Change the badge text
    } elseif ( $product->get_id() === 456 ) { // Another product
    $html = ‘Limited Time Offer!‘; // Different text for another product
    }
    // Add more conditions as needed
    return $html;
    }

    = = =

    I want to signal a problem.

    The Label text it is changed in archive page, but it is not changed on Product page.

    On Product page is the default “Sale” text.

    Content is visible for topic creator and
    support staff only.
  • Viewing 1 results - 1 through 1 (of 1 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.