WooCommerce: Edit “You may also like…” Heading @ Single Product Page

Since WooCommerce 4.1, there is now an easy way to edit the “You may also like…” WooCommerce string that appears on the Single Product Page, 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: Reword / Translate “You may also like…” Title @ Single Product Page

/**
 * @snippet       Translate "You may also like..." - Woo Single Product
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 9
 * @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

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

47 thoughts on “WooCommerce: Edit “You may also like…” Heading @ Single Product Page

  1. The new way is to use the Woocommerce filter hook: ‘woocommerce_product_cross_sells_products_heading’

    1. Appreciate that, but your filter is for the cross-sells section on the Cart page. Mine is still working, and it’s for the Single Product Page

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

  3. Works like a charm, as always with your snippets πŸ™‚

  4. 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.

  5. 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!

  6. 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

  7. 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

  8. 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!

  9. Please use … to … otherwise this is not working.

      1. It’s in the snippet notes indeed

  10. 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?

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

    1. Thanks!

  12. 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

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

    1. Awesome πŸ™‚

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

  15. 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?

  16. Still going! πŸ™‚

  17. It is working. πŸ˜€
    tnx

  18. 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 πŸ™‚

  19. your are awesome!!!! thanks Rodolfo

  20. 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 *