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 on the tin. Enjoy!

The “You may also like…” section displays on the single product page when “Upsells” are defined for that specific WooCommerce product

PHP Snippet: Edit / Translate “You may also like…” @ Single Product Page

/**
 * @snippet       Translate "You may also like..." - WooCommerce Single Product
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 4.1.1
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */
 
add_filter( 'woocommerce_product_upsells_products_heading', 'bbloomer_translate_may_also_like' );
 
function bbloomer_translate_may_also_like() {
   return 'Customers also purchased...';
}

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

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.

45 thoughts on “WooCommerce: Translate “You may also like…” Text

  1. Thanks for that solution. Easy and perfect text change.

  2. Works like a charm, as always with your snippets ๐Ÿ™‚

  3. In version Version 4.9.1 it should be:

     add_filter( 'woocommerce_product_cross_sells_products_heading', 'bbloomer_translate_may_also_like' );
      
    function bbloomer_translate_may_also_like() {
       return 'Customers also purchased...';
    }
    

    Cheers!

    1. Cross sells are on the Cart page though?

      1. I was looking so much for the cross sells snippet! This was very useful comment above.

        Thank you all.

  4. From WooCommerce 3.0 there is a filter to change this string: ‘woocommerce_product_upsells_products_heading’

    No need for ‘gettext’ filter any more! ‘gettext’ filter is a dangerous one because it is called hundreds of times for each post.
    The filter function can accept 3 parameters, the third is the text ‘domain’ (which would be ‘woocommerce’ for this string). You could check that string before calling str_ireplace().

    I saw this morning that WPBeaches.com has mentioned this snippet. I informed them about the filter too.

    1. Excellent, thanks Damien!

  5. Hi there! I’ve used your snippet on a website I’m working on and it works (almost) great using ‘You may also like&hellip’. If you don’t use “&hellip”, it doesn’t work.
    I say “almost” because something weird happen to me: there is a “;” at the end of the translated sentence whatever I choose to write!! I’ve tried many possibilities but without success. How can I get rid of this ; please?

    Here is the piece of the snippet: $translated = str_ireplace( ‘You may also like&hellip’, ‘MEILLEUR CHOIX POUR VOUS’, $translated );

    Thanks!

    1. The semicolon is part of “&hellip” so you need to include that as well. It’s an HTML symbol

  6. Should this code also work on the cross-sell during in the cart page?
    Or does that require different code?

    1. No, it’s different. You need to target that different string

  7. Hi, how I can hide “You may also likeโ€ฆ” text if products are out of stock?

    Thanks

    1. Hey Mimmo, 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. Please use … to … otherwise this is not working.

      1. It’s in the snippet notes indeed

  9. How does it work if I have a non-English blog? For example in German? Unfortunately the snippet doesn’t work there.

    1. Hello Samuel – did you try to use the string in German instead of “You may also like” inside the snippet?

  10. Thanks, this is very helpful! Still works like a charm as of 07/20/19.

    1. Thanks!

  11. Hi,

    Thanks for the upsell snippet. Is there any snippet to change the text in the cross-sell cart “You may be interested inโ€ฆ”?

    Thanks.
    Alex

  12. Still working on the 7th of August 2018!
    Thank you very much!

    1. Awesome ๐Ÿ™‚

  13. its working still. I tried in latest woocommerce.

  14. Yes ! this worked perfectly for the cross-sells (the related products on product pages), but it doesnt work on UP-SELLS text (which is the same ‘you may be interested in…”

    This is what i did, and breaks my site:

    add_filter('gettext', 'translate_like');
    add_filter('ngettext', 'translate_like');
    function translate_like($translated) {
    $translated = str_ireplace('You may be interested in…', 'Customers Also Bought:', $translated);
    return $translated;
    }
    
    1. Hey Veronica, thank you so much for your comment! Why does the above break your site – what error did you get?

  15. Still going! ๐Ÿ™‚

  16. It is working. ๐Ÿ˜€
    tnx

  17. Hello, I am having the same problem, but even a bit more complicated: I am running a theme (Bridge) with woocommerce mulitilanguage preinstalled. problem is that the text “You may also like..” is automatically translated into dutch. But this translation sucks and I want to change it. Do you have an idea where i can change this?
    Thanks guys!

    1. Thanks for your comment Nathan! In this case, I’d recommend reading this guide from WooThemes, and possibly install the Loco plugin or edit the .po Dutch file: https://docs.woothemes.com/document/woocommerce-localization/. Hope this helps ๐Ÿ™‚

  18. your are awesome!!!! thanks Rodolfo

    1. Thank you Mo! ๐Ÿ™‚

  19. Thanks Rodolfo,

    It’s really annoying that “You may also like” is hard-coded to WooCommerce and hence so difficult to change to something more useful, but your solution above provides a neat work around.

    But just one small problem: The actual text is “You may also like…” (with three full-stops at the end) and so whatever you translate the string into also ends up with three full-stops at the end! I have tried adding the full-stops into the string to be translated, but this breaks it and it doesn’t work at all.

    Any ideas as to how to get rid of the dot dot dot after whatever string I have replaced “You may also like” with please?

    James ๐Ÿ™‚

    1. Hooray, I’ve just answered my own question. The actual text string to be translated is “You may also like…” with the “…” bit being the cause of the dot dot dot at the end.

      To get rid of the dots, the code should therefore be:

      // Change “You may also like” into “Wear with”

      add_filter(‘gettext’, ‘translate_like’);
      add_filter(‘ngettext’, ‘translate_like’);
      function translate_like($translated) {
      $translated = str_ireplace(‘You may also like…’, ‘Wear with’, $translated);
      return $translated;
      }

      James ๐Ÿ™‚

      1. Ok, that didn’t work ๐Ÿ™

        Everywhere I have typed “…” in the above post, change this to “& h e l l i p ;” but without the speech marks and spaces between each letter/symbol.

        Perhaps you can update your code to make this clearer?

        1. Thanks for your feedback James, I will update the snippet now. R

          1. Thanks, but how to translate ‘related products’ string?

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. 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 BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

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