WooCommerce: How to Translate / Rename Any String

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.

 * @snippet       Translate a String in WooCommerce (English to English)
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 4.5
 * @community     https://businessbloomer.com/club/
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;


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 if 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 Spanish)
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 4.6
 * @community     https://businessbloomer.com/club/
add_filter( 'gettext', 'bbloomer_translate_woocommerce_strings', 999, 3 );
function bbloomer_translate_woocommerce_strings( $translated, $untranslated, $domain ) {

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

      switch ( $untranslated ) {

         case 'Sale!' :

            $translated = 'Rebaja!';

         case 'Product Description' :

            $translated = 'Descripciรณn del producto';

         // ETC

   return $translated;


How to Find The Correct WooCommerce String

Sometimes the code above does not work because you’ve selected the wrong string of text. It’s not as straight forward as it seems, because “frontend” strings (the ones you see on the website as a user) might differ from “backend” ones (the ones inside the code).

For this reason, you should always be familiar with the WooCommerce PHP files and search for the string before applying the snippet above. Here are some examples of the CORRECT strings you should translate:

// an easy one to translate
'Pay for order'

// a weird one, note the %s placeholder for product name
// on the frontend you would see the product name...
// ...but on the backend you see this:
'Sorry, "%s" is no longer in stock so this order cannot be paid for. We apologize for any inconvenience caused.'

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Translate “You may also like…” Text
    Apparently, since WooCommerce 4.1, there is now an easy way to edit the “You may also like…” WooCommerce string thanks to a brand new “PHP filter”. Kudos to Damien Carbery for reporting this new method. So, as usual, simply copy/paste the snippet below in your child theme’s functions.php and it will do what it says […]
  • WooCommerce: Rename “Tags” Label @ Single Product Page
    A #CustomizeWoo student reached out for premium support in regard to “WooCommerce taxonomies”. The question was: How do I change the label “tag” into something else, for example “brand”? Well, this is how it’s done! Please note that this does not change the “tag” permalinks (URL, slug, etc), but only the “Tags” label on the […]
  • WooCommerce: Translate “Shipping” @ Cart Totals
    The cart totals table cell title “Shipping” or “Shipping and Handling” appears also on the checkout page. So, what if you wish to “translate” this string from English to “better” English or completely customize it? Thankfully there’s a quick 4 lines snippet for you. Enjoy!
  • WooCommerce: Translate / Rename Content @ Order Emails
    WooCommerce order emails customization is possibly the most wanted feature for WooCommerce store owners and developers right now. It is very difficult to edit the default templates and it’s no surprise there are many email customizer plugins out there. We’ve already seen how to add content to specific WooCommerce emails, how to add custom email […]
  • WooCommerce: Top Multilingual Plugins
    I have spoken about the need to internationalize your WooCommerce store before. There are all-in-one, country-based plugins that let you ensure your store is ready for a specific countryโ€™s audience (e.g. Germany, Japan, Brazil, Italy and the Czech Republic).  But this isnโ€™t exactly the right type of plugin for the merchant who is trying to service […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

192 thoughts on “WooCommerce: How to Translate / Rename Any String

  1. Hi,

    I cannot get these text changed that are in the wp_terms table:

    I tried loco translate and your snippet, but both without succes. And i need to change it, because i want to use it in a filter on the frontend.

    Please check the screenshots:

    Any ideas? Many thanks

    1. Hello Bram, are you sure they come from WooCommerce and not a third party (filter) plugin? Maybe the error is there. Otherwise, please share the code you used (as well as telling me what widget you’re using there) and I’ll take a look

  2. Works as expected in December 2022 ๐Ÿ™‚ Thank you!

  3. Perfect, thank you!

  4. Works perfectly to change a translated string!

  5. Working on the other cases but, not being able to make it work for string ‘has been added to your cart.’ Referred to Woocommerce the string is ‘%s has been added to your cart.’ found on $added_text = ….
    Here is my code for the switch case

            switch ($translated) {
                case 'View cart':
                    $translated = 'View Reservation';
                case 'Your cart is currently empty.':
                    $translated = 'Your reservation is currently empty';
                case '%s has been added to your cart.':
                    $translated = '%s has been added to your reservation.';
                case 'Update cart':
                    $translated = 'Update Reservation';

    Does not work for added to your cart

    1. add_filter('wc_add_to_cart_message', function ($message, $product_id) {
          $message = sprintf('%s has been added to your reservation.', get_the_title($product_id));
          return $message;
      }, 10, 2);

      this filter worked for the text

  6. Hi there,
    Thanks for your post. I tried to translate the Text above the Billing form, but the text doesn’t change at all. We’re using a German WooCommerce system. Is there anything wrong with the code?

    add_filter( 'gettext', 'bbloomer_translate_woocommerce_strings', 999, 3 );
    function bbloomer_translate_woocommerce_strings( $translated, $untranslated, $domain ) {
       if ( ! is_admin() && 'woocommerce' === $domain ) {
          switch ( $untranslated ) {
             case 'Billing details' :
                $translated = 'Ihre Rechnungsdaten';
       return $translated;
    1. Works for me. Try disabling all plugins but Woo and see if it works, so that you can find out which plugin is causing this problem by reactivating them one by one

  7. Thank you! For your great tutorial. There is a reason why after installed woocommerce I try to change the language in italian in general setting of my website and after save the language cames back in english

    1. No idea! Try changing the language of your user instead

      1. Hello Rodolfo, i want to ask a question.

        I need to translate woocommerce’s default pagination url structure “page”


        How can i change this structure to something else like “category/child-category/new-pagination/7/”

        I would be very happy if you could help with this. Thank you, have a nice day.

        1. Hi Mehmet, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  8. Amazing, Thank You!

  9. I used your snippet “Add Privacy Policy Checkbox @ Checkout” and want to translate the text that this snippet returns to Spanish (in other words, I want to translate the “I’ve read and accept the Privacy Policy’ and the “Please acknowledge the Privacy Policy”). Can I use this snippet to translate the texts from the other snippet?

    1. Hey Carmen, thanks for your comment! In order to make a string translatable you have to wrap it in a __() function: https://codex.wordpress.org/I18n_for_WordPress_Developers#Translatable_strings – hope this helps ๐Ÿ™‚

  10. I am trying to replace “View Cart”, “Out of Stock” and “Featured” in a Kalium Shop Theme (child of Kalium theme) to Catalan (other texts are correctly translated) but your snippet doesn’t work.

    Main WP language is Catalan and I use:

     * @snippet       Translate a String in WooCommerce
     * @sourcecode    https://businessbloomer.com/?p=162
     * @author        Rodolfo Melogli
     * @compatible    WooCommerce 3.5.4
     * @community     https://businessbloomer.com/club/
    add_filter( 'gettext', 'bbloomer_translate_woocommerce_strings', 999, 3 );
    function bbloomer_translate_woocommerce_strings( $translated, $untranslated, $domain ) {
       if ( ! is_admin() && 'woocommerce' === $domain ) {
          switch ( $untranslated) {
             case 'View Cart' :
                $translated = 'Veure Cistella';
             case 'Out of Stock' :
                $translated = 'Esgotat';
             // ETC
       return $translated;
    1. The last } is on its place in the functions.php, I just lost it when I did copy-paste from my file to my comment.

      1. Are they Woo strings or Kalium strings maybe?

  11. like a charm, thank you so much

    1. Yay

  12. WordPress Version: 5.5.1
    Woocommerce Version: 4.5.2
    Did not work for Billing Address Text on Checkout page

    1. Share your code please

  13. Hi Rodolfo,

    Unfortunately the snippet isn’t working for the “customer reviews” text. Is there any other solution for that?

    Thank you

    1. It works, you just need to find the correct string

      1. Yeah, this was the string I needed:

        %s customer review

        . Thanks!

        1. Awesome

  14. gettext() not work for me!
    I need rename label “Dimensions (in)” in Shipping tab of Product Data.

    1. I find it!
      $text = ‘Dimensions (%s)’;

      1. Nice

  15. Great article.
    One question however,
    what if I would like the translated to be linked to a page or something?…how do you go about that??

    1. This is for text strings only. But you can try to put some a href HTML inside the translated string, not sure if that’d work though

  16. Bonjour Rodolfo,

    Landed here from Google’s quest for my question โ€“ from ‘n Product’ to ‘n Object,’ woocommerce changed text.

    I’m trying to create restaurant online order menu. So, they tried to change the ‘Package’ text to ‘Object’ but no luck on the Shop page. And without success I tried process above. I appreciate your support.

    1. Hi there, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  17. When I add the snippet the goal is achieved: The Dutch word “Uitverkocht” becomes “Wachtlijst”. However all other translations in WooCommerce (and in the backend) switch back to English. All the buttons turn to English for example. When I remove the snippet the store is completely in Dutch again, but the word I wanted to translate: uitverkocht to wachtlijst, is now back to uitverkocht again. I’m sure it’s a simple mistake I make, I just don’t see it. I would very much appreciate your help.

    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 'Uitverkocht' :
                $untranslated = 'Wachtlijst';
       return $translated;
    1. Should be $translated = ‘Wachtlijst’;

  18. Thaaaaanks for the code my friend!!! Helped a tonnn

    1. Nice!

      1. Darn it. Wish I could say that …..

        Here’s what I used, and it’s not working somehow.

         * @snippet       Translate a String in WooCommerce (English to English)
         * @how-to        Get CustomizeWoo.com FREE
         * @author        Rodolfo Melogli
         * @compatible    WooCommerce 4.0
         * @community     https://businessbloomer.com/club/
        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 'Item' :
                    $translated = 'toodet';
                 case 'Items' :
                    $translated = 'tooted';
                 // ETC
           return $translated;

        This is the url in question.


        The word “ITEM” should be translated into “TOODET”

        Loco translate has not been helpful either, that’s how I ended up with your solution, only to find that it doesn’t work for me….

        1. In this case, the function that generates that/those string/s is in the admin, so you have to remove the !is_admin() check

          1. Thanks a lot! Somehow, that does not work either…. ๐Ÿ™

            1. OK, so I got it to work finally with the following code added to what I ‘borrowed’ from you.

               //add_filter( 'gettext', 'bbloomer_translate_woocommerce_strings', 999, 3 );
              function bbloomer_translate_woocommerce_strings( $translated, $untranslated, $domain ) {
                 if ( 'woocommerce' === $domain ) {
                    switch ( $translated) {
                       case 'item' :
                          $translated = 'toodet';
                       case 'items' :
                          $translated = 'tooted';
                       // ETC
                 return $translated;
              add_filter('ngettext_with_context', 'change_woocommerce_item_text', 20, 6);
              function change_woocommerce_item_text($translation, $single, $plural, $number, $context, $domain ) {
                  if ($domain == 'Divi') {
              		if ($translation == '%1$s Item') { return '%1$s toodet'; }
              		if ($translation == '%1$s Items') { return '%1$s tooted'; }
                  return $translation;

              Works like a charm! And just wanted to share.


              1. Ah good

  19. Hi Rodolfo,

    Landed here from Google search for my query – woocommerce change text from ‘n Product’ to ‘n Item’.

    I’m trying to build an online ordering menu for restaurant. So, tried to change the text ‘Product’ to ‘Item’ but no luck in Shop page. I even tried above method without a success. I would appreciate your help.

    Thank you for your contribution.


    1. Hey Hum, it could be a theme or a third party plugin string, and also there might be more than that (singular/plural). This snippet must work, but you need to do more work to make it function in this case

      1. Hey there, I am actually also building an online shop for a restaurant in these dire times! And I tried to change You may also like… to Wine Pairing but no change on the website. Looking now whether it might be a theme thing.


  20. Hi Rodolfo,

    Does it works with the colum title text in woocommerce orders page? I’m talking about the “Billing” string in my site (the only word that it’s left in translation): https://i.gyazo.com/0ef910abdf088a0f1fd1851c3ebb15b0.png

    Thanks a lot!

    1. It should, but it’s not always 100% reliable

  21. Thank you for posting this filter Rodolfo. I used it to translate the “Description” tab label to “More Info” in the product description display. Your filter was smart enough to NOT translate the word “Description” if the word falls within part of the product description.

    However the filter didn’t work to change the word “Sold” in the sold out badge, to “Sold Out.” Maybe that’s a different scope.

    1. Hey Carol ๐Ÿ™‚ Yes, you’ll need to see how the string is “coded” inside that plugin, maybe it’s “Sold!” instead or something like that

  22. Thank you very much, Rodolfo! So much easier than yet another plugin!

    1. Ah! Thank you!

  23. Great article, thank you. Your suggestion is perfect.

    1. Thanks!

  24. thanks bro… It works…
    Hope to get more useful tutorials from you…

    1. Great!

  25. Hi Rodolfo,

    Thanks for these tutorials. I’ve already managed to translate the up-sell and related products titles so thanks for that. Now I have two questions.

    1. I’m doing something wrong when trying to translate the cross-sell text ‘You may be interested in’ (Or in Dutch ‘Je bent misschien ook geรฏnteresseerd in’ to ‘Maak de look compleet’.

    2. How to remove the three dots from cross sell and up-sell titles

    This is the php snippet I use for the cross sell text. I’ve tried translating from original Woocommerce English to Dutch and from Dutch to Dutch.

    Hopefully you can pinpoint the problem I’m missing.

    1. Hi Christian, take a look at https://businessbloomer.com/woocommerce-change-may-also-like-text/ – as you can see you have to target the full string, and some times this comes with the 3 dots attached to it (hellip in HTML)

  26. Works like a dream – thank you so much for this

    1. Excellent

  27. Thank you very much for this awesome and easy code ๐Ÿ™‚

    1. Welcome!

  28. hi,

    every single tip or how-to i’ve tested actually works. and although some may be technical, you clearly know how to explain and break down processes, codes or integration. and for being roaming boards and tech pages for years, i can tell you it’s a rare thing. many thanks for sharing.

    i’m having a bit of a bug with the woocommerce connection page, a php-warning-hook-line-286 error. could you check it out and tell me if you can fix it, and at what cost?

    1. Hello John, thanks so much for your comment! Yes, this is definitely possible – if you’d like to get a quote, feel free to contact me here

  29. This worked great. Thank’s!

    1. Awesome!

  30. Hello Mr Rodolfo.

    Thanks for share your code.
    I was using your great snippet to change some lines in checkout

    But second line is not working for my case.

    // Town-city >> Localidad / Ciudad > Departamento // OK
    $translated = str_ireplace( ‘LOCALIDAD / CIUDAD’, ‘DEPARTAMENTO’, $translated );

    // State / County > Regiรณn / Provincia > Ciudad ///// Not working โ–ฒ
    $translated = str_ireplace( ‘REGIร“N / PROVINCIA’, ‘CIUDAD’, $translated );

    I think error is because of “ร“” letter.. I dont know what to do..


    1. Hi Andrew, try to find the file where the string is generated from, and copy/paste it. Maybe that’ll work

  31. Hi Rodolfo, thank you for the code snippet, however Iโ€™m working with the plugin โ€œDeposits For WooCommerceโ€, where some strings seemingly donโ€™t want to be translated. Iโ€™ve tried multiple solutions (including yours) but none of them seem to be working. Understandably, I donโ€™t want to edit the text in the plugin itself as those edits get deleted when thereโ€™s a new update. The text is as follows:

    <ul class="deposit-options">
                <?php if( isset( $default_selection ) && 'yes' == $default_selection ): ?>
                        <input type="radio" name="wcd_option" value="enable" id="wcd-pay-deposit" checked>
                        <label for="wcd-pay-deposit"> Pay Deposit </label>
                        <input type="radio" name="wcd_option" value="disable" id="wcd-pay-full">
                        <label for="wcd-pay-full"> Pay Full Amount </label>
                <?php else: ?>
                        <input type="radio" name="wcd_option" value="enable" id="wcd-pay-deposit" >
                        <label for="wcd-pay-deposit"> Pay Deposit </label>
                        <input type="radio" name="wcd_option" value="disable" id="wcd-pay-full" checked>
                        <label for="wcd-pay-full"> Pay Full Amount </label>
                <?php endif; ?>

    I want to change both instances of โ€œPay Depositโ€ and โ€œPay Full Amountโ€. Is there anything in this code snippet that prevents users to override the translation?

    1. Hey Jordy, they seem to have a space before and after the string, so maybe you need to include that in the translation – give it a go

  32. Hi Rodolfo, thank you for the code snippet, however I’m working with the plugin “Deposits For WooCommerce”, where some strings seemingly don’t want to be translated. I’ve tried multiple solutions (including yours) but none of them seem to be working. Understandably, I don’t want to edit the text in the plugin itself as those edits get deleted when there’s a new update. The text is as follows:

    Pay Deposit

    Pay Full Amount

    Pay Deposit

    Pay Full Amount

    I want to change both instances of “Pay Deposit” and “Pay Full Amount”. Is there anything in this code snippet that prevents users to override the translation?

    1. Excuse me, I forgot to read the policy on writing code, I’ll post my question again but with the wrap. You may delete this comment

  33. I also translates the admin text. For example if i want to translate price word then it translate price word in product column in dashboard. Then I use

    if(!is_admin() || is_checkout() || is_cart()) but it generates error. Error :

    Fatal error: Uncaught Error: Maximum function nesting level of ‘256’ reached, aborting!
    Error: Maximum function nesting level of ‘256’ reached, aborting!

    1. Hello Zakir, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

    2. thanks for your hint, not sure why it did not work in your case but it works for me. Hope you’ve worked it out.

  34. Hello
    perfect Snippet – thxs
    but seems not working with special characters – like accent characters in french (รฉ, ร , รจโ€ฆ)
    how can i do this ?
    thxs for your help

    1. Not sure!

  35. this is a life saver, thank you very much

    1. Thanks!

  36. Hello Rodolfo,
    Your hints, tips and snippets have been a great help but I can not get this one to work, I have the latest versions of WordPress and Woocommerce and use the Deli theme. If I put it directly in the functions.php file it breaks the site, using the Themes Customisations plugin it has no effect at all!

    1. Hello Terry, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom troubleshooting work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  37. Brilliant, thanks! ๐Ÿ˜€

    1. You’re welcome!

  38. This didn’t wok form me on the attribute text

    1. Hello Chris, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  39. Rodolfo, you are my god now ๐Ÿ™‚

    1. Cheers!

  40. Thanks man, I was breaking head here with the plugin WooCommerce Subscription, which changes the button at the checkout.

    1. You’re welcome!

  41. Wonderful, simple and useful, it’s for the site and for the emails. One of the most useful codes I’ve ever seen, from my heart, thank you! Success always! Brazil and Italy love you!

    1. Thanks!

  42. Great Snippet! Works easily!

    Is there any way to translate strings only at specific urls?

    1. Hi Chris, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  43. Thanks Rodolfo,

    great snipet and so easy to use ๐Ÿ™‚

    1. Thanks!

  44. Finally, a snippet that worked. THANK YOU!

    1. Awesome!

  45. Thank you so so much!!! WooCommerce’s Spanish translation is pretty decent, but a couple of sentences are left in English and it was driving me crazy. I had looked up everything and finally your snippet solved it. THANK YOU!

    1. Excellent ๐Ÿ™‚

  46. Hey, so glad I found your blog! Worked perfectly fine for translating Wishlist, but did not work for 2 other translations – hover text – in the menu (Account / Register). Any idea what could be done different to make it work?
    Thanks a ton!

    1. Hello Betti, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  47. Hi. But returned error. (1 passed in / var / www / … on line 288 and exactly 3 expected in) on WordPress 5.1 and WooCommerce 3.5.5

    add_filter( ‘gettext’, ‘theme_translate_woocommerce_strings’, 999, 3 );

    Thank you. I solved my problems

    1. Exactly, thank you Fabiano!

  48. Rodolfo: thanks very much for your snippet.

    It didnโ€™t work in my system environment: WordPress: 4.9.9, WooCommerce: 3.5.4, Theme: DIVI.

    I kept the original functions.php of DIVI unchanged and created a new functions.php inside my DIVI child-theme. This functions.php (in first instance) contained your code โ€“ result: PHP-errors:

    Fatal error: Uncaught ArgumentCountError: Too few arguments to function bbloomer_translate_woocommerce_strings()

    So have made the following change to fulfill the (new) requirements for arguments:
    add_filter( ‘gettext’, ‘avistastudios_translate_woocommerce_strings’, 20, 3 );

    Afterwards it worked like a charm.

    1. Sorry Stefan, this has now been fixed (added “3” in the add_filter call as priority)

  49. This seems to cause an error when copied as is…

    Uncaught ArgumentCountError: Too few arguments to function bbloomer_translate_woocommerce_strings(), 1 passed in wp-includes/class-wp-hook.php on line 288 and exactly 3 expected in wp-content/themes/nzebike/functions.php:608

    1. Sorry Moi, this has now been fixed (added “3” in the add_filter call as priority)

  50. Hello,

    this worked just fine but today I had an Ocean WP theme update and of course, all my translations are gone, but when I want to add them back, it is not working and there are these errors:

    Uncaught ArgumentCountError: Too few arguments to function bbloomer_translate_woocommerce_strings(), 1 passed in wp-includes/class-wp-hook.php on line 288 and exactly 3 expected in wp-content/themes/oceanwp/functions.php:948
    Stack trace:
    #0 wp-includes/class-wp-hook.php(288): bbloomer_translate_woocommerce_strings(‘Top Bar’)
    #1 wp-includes/plugin.php(203): WP_Hook->apply_filters(‘Top Bar’, Array)
    #2 wp-includes/l10n.php(182): apply_filters(‘gettext’, ‘Top Bar’, ‘Top Bar’, ‘oceanwp’)
    #3 wp-includes/l10n.php(283): translate(‘Top Bar’, ‘oceanwp’)
    #4 wp-content/themes/oceanwp/functions.php(270): esc_html__(‘Top Bar’, ‘oceanwp’)
    #5 wp-includes/class-wp-hook.php(286): OCEANWP_Theme_Class::theme_setup(”)
    #6 wp-includes/class-wp-hook.php(310): WP_Hook

    Thank you for your reply. I am really miserable. ๐Ÿ™

    1. Sorry Petra, this has now been fixed (added “3” in the add_filter call as priority)

  51. Thanks for this amazing snippet. I used this snippet for wpml. I dont like wpml string translate, because it make slow website. And I couldnt translate wordpress site title and tagline without this plugin. This snippet helped to me do it ๐Ÿ˜€

    1. Awesome! I’m not a big fan of WPML either ๐Ÿ™‚

  52. Thank you ๐Ÿ™‚

    1. You’re welcome!

  53. still works

    1. Excellent ๐Ÿ™‚

  54. How do I update this to only affect a certain text domain?

    1. Hey Jon, thanks for your comment. You can pass $domain to the function as well: https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext

  55. Hi Rodolfo,
    Thx for the snippet. Works great on my site.
    I am using loco translate but for some reason it simply won’t translate my Single Product Pages, which is where this code comes in very handy.

    However, I am also trying to translate the product meta strings (“tags”, and “category”), but this code doesn’t work for that.

    1. Thank you Richard ๐Ÿ™‚ It should work… try with: https://businessbloomer.com/woocommerce-rename-tag-taxonomy/

  56. Does this snippet also work for the WC emails? To translate ‘Subtotal’, ‘Shipping’, ‘Payment method’ etc. On the website this strings are already translated, but in the emails they are still in English.

    1. Hello Kevin, yes it should. Let me know

  57. It works perfectly! thank you so much!!!!

    1. Great ๐Ÿ™‚

  58. Hi Rodolfo,
    I had problems with the standard product filters in Spanish , They were only translated for the half. And everything in the MO and PO files was translated.. Did not know where to search anymore. But your wonderful snippet did the trick. 3 strings on a row.. tada!
    Nice side affect was that the string “products” was everywhere, on the site translated to “Tutorials” And that is what I am selling! ๐Ÿ™‚

    Thank you very much for all your effort!

    1. Awesome, thank you so much Ella ๐Ÿ™‚

  59. The snippet worked for me. However, I replaced ‘bbloomer’ with my initials and it broke the entire site. I then spent 2 hours thinking what went wrong. ๐Ÿ™‚

    1. ๐Ÿ˜€ hope you sorted that out Yavor!

  60. Not worked for me.. Inserted into functions.php, but simply not translated string for me. Im not sure if is theme related or something else, but not worked. This is code i inserted:

    add_filter( 'gettext', 'bbloomer_translate_woocommerce_strings', 999 );
    function bbloomer_translate_woocommerce_strings( $translated ) {
    // STRING 1
    $translated = str_ireplace( 'Follow Us', 'SUIVEZ-NOUS', $translated );
    return $translated;

    to translate string into footer widget..

    1. Hey Dean, thanks so much for your comment! Unfortunately this looks like custom troubleshooting work and I cannot help here via the blog comments. Thanks a lot for your understanding! ~R

  61. Hi Rodolfo,

    Great support!
    A simple question: How do I translate a specific text string in the login page?
    Thank you very much in advance.

    Regards Erik

    1. Hey Erik, this snippet should work! What have you tried so far?

  62. Hi! can somebody post just a simple example how to add a second string to the code, I dont have a clue how to achieve this with switch statement …

    1. Hey Rob, I just updated the snippet for you ๐Ÿ™‚

  63. Hi Rodolfo

    Brilliant simple solution to all the others i’ve used in the past.

    Do have a question, i have ‘Cart’ to change to ‘Booking’ in my secondary header, the text changes onload but then changes back to ‘Cart’ as soon at the entire page loads.

    The menu item is added by the theme options itself if that’s of any issue

    It’s an odd one!

    1. i answered my own problem!

      1. Ahah excellent ๐Ÿ™‚

  64. Hi Rodolfo,
    I tried your code, but it doesn’t work for me… I pasted it in fuctions.php along with the code below to translate the shop and checkout. Any ideas why? I am trying to translate the page in English and Spanish.

    function get_woocommerce_shop_polylang() {
    return pll_get_post(get_option(‘woocommerce_shop_page_id’ ) );
    add_filter(‘woocommerce_get_shop_page_id’, “get_woocommerce_shop_polylang”);

    function get_woocommerce_checkout_polylang() {
    return pll_get_post(get_option(‘woocommerce_checkout_page_id’ ) );
    add_filter(‘woocommerce_checkout_page_id’, “get_woocommerce_checkout_polylang”);

    Thank you for your help!

    1. Hey Paloma! If you’re using Polylang you don’t need this snippet as well – it should be sufficient!

  65. Once more a great help! Thanks. However it does not seem to work with special characters. if I put the german word “Wรคhle” the whole phrase just disapears completly. “Wahle” works fine.
    Any idea how to work around that?

    1. Hey Luise, thanks for your comment. I’m not 100% sure here. Maybe give https://wordpress.org/plugins/say-what/ plugin a go.

  66. Hi Rodolfo Melogli,

    I tried your code ( 4-02-2018 ) & it didn’t work, put that in child theme’s functions.php.

    trying to convert ( VAT Inc. ) to German.

    hope you could help.

    Thanks in Advance

    1. Hey K, I take you managed to work this out ๐Ÿ™‚

  67. Thank you!

    I have tried everything and wasted around 1 day trying to fix this problem.

    And yet, your simple code works!

  68. Thank you so much! works like a charm.

  69. Thank you!! This saved me a lot of time digging through my theme.

  70. It worked on all of the woo commerce. But it is not translating the Tax Names. Say If I have a tax name “GST Handling Fee” and I want to change it to ‘HST Expedition Fee’. It is not working.

    1. Hey Dev, thanks for your comment! You can do that from the WooCommerce Tax settings ๐Ÿ™‚

    1. Ah, thank you ๐Ÿ™‚

  71. Hi Rodolfo,

    Thank you for all the cool videos.

    I have a multilingual Woocommerce site (4 languages). I use polylang, Hyyan WooCommerce Polylang Integration and Loco Translate to manage the different languages.

    I would like to completely change the text of the Woocommerce emails (for example the one for a new user).
    This would involve changing the customer-new-account.php template file and all the related strings in the .po files.

    What would be the best approach to do this especially considering that the plugin could be updated in the future?

    1. Massimo, my snippet is to be used for a string or 2, not for a full translation. Your translation plugins should allow you to translate emails as well, so maybe take a look at their “PRO” version, maybe this is not included in the freemium

  72. Just what I needed! A big thank you for that! ๐Ÿ™‚
    Works excellent!

  73. This saved me some trouble with translating some mystical plugin parts, thank you.
    But the thing about is, it searches for ALL strings on your website, not considering the context at all. Let say you I want translate one word like the preposition “of”. Now, the letters “of” may appear in hundreds of words on the website – like ” loft” or “soft” etc. They will all be replaced, which is of course not desirable.
    How can I possibly prevent this unwanted translations?

    Best regards and thanks!

    1. Filip, thanks for your comment! Yes, you should use this snippet very carefully… Instead of translating “of”, which is way too generic, you should for example translate “bag OF strawberries”, which is unique ๐Ÿ™‚

  74. Hey,
    i used this code several times before and it worked,
    but now i’m using woocommerce subscription plugin,
    and it did not work,
    I want to translate: year, week, day.
    any other possible way ?
    here is my code:

    add_filter(‘gettext’, ‘translate_reply’);
    add_filter(‘ngettext’, ‘translate_reply’);
    function translate_reply($translated) {
    $translated = str_ireplace(‘year’, ‘ืฉื ื”’, $translated);
    return $translated;

    1. Hey Itayko, not sure here ๐Ÿ™‚ Unfortunately I cannot provide custom work here via the blog comments.

  75. Hi!
    The code works well. But I’m wondering how to use it only on English version of my site (home language is Polish). I’m having troubles with Loco Translate and WPML costs $$$ ๐Ÿ™‚
    I have created additional custom tab on single product page (thanks to your youtube tutorial!) like this:

    $tabs[‘my_custom_tab’] = array( “title” => __( ‘Karta katalogowa’, ‘woocommerce’ ),

    and I want “Karta katalogowa” to be translated to “Datasheet” when I’m on English version of my site.
    Can I base on other automatic translation and wrap your above translation code in somethig like “if description_tab name is “Description” -> translate, else -> do not translate.
    What do you think? How to refer to other tab title?

    Thanks ๐Ÿ™‚

    1. Hey Jacek, thanks for your comment ๐Ÿ™‚

      Once you create the string, you can definitely use a translation plugin such as SayWhat, Polylang or other to target that in your own language.

      This snippet is to translate something in a one-language website ๐Ÿ™‚

  76. Great! It worked and was real easy! Much appreciated

    1. Awesome! Thanks Arthur ๐Ÿ™‚

  77. Hi. This code break whole page when applied to functions.php

    1. Hey Adam, thanks for your comment! This snippet works, I use it on many websites – so maybe you made a syntax error. What error do you get if you enable wp_debug?

  78. Thanks! !

  79. Hi i tried this and it worked just perfectly, question is; Can i edit more than 1 string if yes, how can i do that?

    1. Excellent, thanks Ifeanyi! Yes, that is possible with basic PHP – look into the SWITCH CASE PHP documentation and you should figure a way to achieve what you need ๐Ÿ™‚ Hope this helps!

  80. Works perfectly, thank you Rodolfo!

    1. Cool, cheers for the feedback Noelle ๐Ÿ™‚

  81. Hi Rodolfo,
    Sorry to bother you again, you pointed me to this article after answering my query/comment on the Woocommerce Emails Visual Hooks page.
    Can I translate more than one string, i.e) from two different Woocommerce Emails within the same function or do I need to repeat your snippet from above for each translation string?

    1. Yes, definitely. You can add the PHP “switch / case” inside the function and have a list of phrases (cases) with their relative translations. I can’t provide this here as this is custom work but hopefully I’ve sent you in the right direction ๐Ÿ™‚

      1. Hi,

        Sorry to bother you again. I’m trying to change the text for the completed order email when the customer has chosen the ‘Collect In Store’ shipping option in the cart.
        Is this possible with string translation or is there a different approach?.

        1. Hey Andy, yes, it should be possible. Have you tried it yet?

          1. No because I dont know how to specify/target the collect in store shipping option.

            1. You’ll have to search for that string through the files (with NotePad++ or similar for example), and then use the exact PHP string they use in the snippet ๐Ÿ™‚

              1. I’m not sure your understanding the question. The string I would want to customize is in the Completed Order Email, this string “Hi there. Your recent order on %s has been completed. Your order details are shown below for your reference:”

                But I want to change this string specifically for when a customer has bought something via Collect in Store. So when the admin marks it as complete, a custom completed order email is sent to that customer.

                1. Gotcha ๐Ÿ™‚ Yes, this is possible of course – but unfortunately this is custom development work and I cannot provide this solution on the blog right now.

                  If you would like to get a quote for the fix, feel free to get in touch. Thanks for your understanding!


  82. This way was working previously. On latest WooCommerce it does not work anymore. Any suggestions? Thank you.

    1. Fansi, thanks for your feedback ๐Ÿ™‚ This is a WordPress filter, so I find it strange it’s related to WooCommerce latest update. Can you check again and let me know? Thank you!

  83. doesnt work for me. Why is this?

    1. Mira, thanks for your feedback. What string are you trying to translate, can you tell me the link of your website page?

  84. Very nice – I wander if there is much performance issue translating this way or some other reason editing the po would be better..

    1. Yes, of course. I would recommend to translate max 10 strings or the PHP could slow down your website. Above 10 strings I would choose the “po” method! Thanks for your feedback!

Questions? Feedback? Customization? Leave your comment now!

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *