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
 * @community     https://businessbloomer.com/club/
 */
 
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 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 Visual Hook Guide: Single Product Page
    Here’s a visual hook guide for the WooCommerce Single Product Page. This is part of my “Visual Hook Guide Series“, through which you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can copy/paste). If you like this guide and it’s helpful to you, let me know in the comments! […]
  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • 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 […]
  • WooCommerce: Add Custom Field to Product Variations
    Adding and displaying custom fields on WooCommerce products is quite simple. For example, you can add a “RRP/MSRP” field to a product, or maybe use ACF and display its value on the single product page. Easy, yes. Unfortunately, the above only applies to “simple” products without variations (or the parent product if it’s a variable […]

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

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

  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? 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 *