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.