Woocommerce – Change labels New or Discounted
Woocommerce It has become one of the most used components to set up an online store on WordPress. This popular plugin has a large community as well as a multitude of templates and additional elements that allow any online store to be molded to practically most common scenarios and needs..
As on many occasions, when new versions of the plugin appear, We find that not all the strings are translated, or if they are, They use other words that are not the ones we would like to appear and we must search between the lines of code to replace a text string or, start editing translation files and spend some time making a simple modification of the literal to change. In this article, we show them How to change the text of the product featured flag in Woocommerce in a simple way.
Default, When you brand a product the literal appears “FEATURED”. In our case we want to mark it as “NUEVO”.
To make the changes, Nothing is simpler than entering our functions.php file and adding the following code at the end
function wc_custom_replace_sale_text( $html ) {
return str_replace( 'Featured', '¡Nuevo!', $html );
}
add_filter( 'woocommerce_sale_flash', 'wc_custom_replace_sale_text' );
This piece of code, filters and replaces the searched string before “show it” on screen.
So easy and fast.