Changing a text from a Woocommerce 3rd party plugin Changing a text from a Woocommerce 3rd party plugin wordpress wordpress

Changing a text from a Woocommerce 3rd party plugin


I see you've already accepted an answer, but you asked about putting this into a function, so here's how. Filter gettext accepts 3 parameters gettext Hook

// Change text strings and make sure you're only on the specic text domainfunction dd_change_text_strings( $translated_text, $text, $domain ) {    switch ( $translated_text ) {        case 'Product added!' :            // Make sure you're only using the phrase in the specific text domain you want.            if ($domain == 'yith-woocommerce-wishlist'){                $translated_text = __( 'Something Else','your_text_domain');            } else {                // otherwise use the default text, in case Product addded! is used somewhere else in another text domain                 // This is optional                $translated_text = __( 'Product added!', $domain);            }            break;    }    return $translated_text;}add_filter( 'gettext', 'dd_change_text_strings', 20, 3 );

Me personally... I would rather add a few lines of code than have an entire plugin (which probably adds scripts and css overhead to my site) to do what this little snippet can do.


Since the string is already wrapped into the function __($string, $domain), you can easily translate it without using any code or editing your functions.php.All you need is a translator plugin (I suggest using Loco Translate).

  • Install the plugin
  • After installation go to "Loco Translate" > "Plugins" using the left column menu on WP dashboard
  • You will see a list of plugins currently installed on your website, select the one you use to manage WooCommerce Whislists
  • Then select your language from the list, or click on "New language" if your language isn't there (and insert the language settings if you are creating a new one)
  • Select the string you want to translate, and put the translation in the bottom text-area
  • Save