There are times you don’t want to translate the whole installation of WooCommerce just for renaming one short string. There are times you need to rename a label or a little thing and don’t feel like installing a bloated translation plugin.

It doesn’t matter whether you want to rename a string in the original language (English, usually), or change the default translated string in a different language. Either way, and thankfully, there’s a little PHP snippet that will work for you instantly. Enjoy!

Translate a single string in WooCommerce/WordPress

PHP Snippet: How to Translate or Rename a Single String of Text (WooCommerce Plugin)

Please note that the ‘woocommerce’ === $domain part in the below snippet gives you exclusive access to WooCommerce plugin strings. With that line, you can’t translate strings generated by your theme or other plugins. Feel free to remove it, but be careful because you may end up translating a lot of additional stuff that maybe you didn’t really want to.

Also, the ! is_admin() check is making sure that translation is only executing on the frontend, so the WordPress dashboard will be excluded. This is a good performance trick, also.

Finally, please note the difference between $translated and $untranslated: if you run a store in English language, you can use any of the two because $translated = $untranslated.

On the other hand, if you run a mono-lingual store in a language that is not English, $translated should be the string in your language while $untranslated is the original string in English – which means that is you want to do a renaming from Spanish to Spanish, you should use $untranslated. Kinda complex to explain, so I recommend trial/error.

 * @snippet       Translate a String in WooCommerce (English to English)
 * @how-to        Get FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 4.0
 * @donate $9
add_filter( 'gettext', 'bbloomer_translate_woocommerce_strings', 999, 3 );
function bbloomer_translate_woocommerce_strings( $translated, $untranslated, $domain ) {

   if ( ! is_admin() && 'woocommerce' === $domain ) {

      switch ( $translated) {

         case 'Sale!' :

            $translated = 'On Offer';

         case 'Product Description' :

            $translated = 'Product Specifications';

         // ETC

   return $translated;


Leave a Reply