Change Related products Description in WooCommerce

I am trying my hand at small WooCommerce customizations in a development/testing environment setting in order to learn more about this e-Commerce solution and ultimately put my PHP skills to use. In this article, I am exploring 2 different ways to change the ‘Related products’ wording description on the Single Product page to something else of your choosing. Learn something new with me!

This article and many to follow, are part of a series of articles I am writing and sharing as I learn new concepts when I learn them. I think of it as a duty in sharing the things I learn as a self-taught developer. We all need to support one another as we continue to learn and grow. #buildinpublic #learninpublic #indiehackers #developer

The Newsletter for PHP and MySQL Developers

Receive a copy of my ebook, “10 MySQL Tips For Everyone”, absolutely free when you subscribe to the OpenLampTech newsletter.

Image by 200 Degrees from Pixabay 

Some things you must be aware of before we start:

  • While I am well-versed in PHP, I am just starting to learn to use it in a WooCommerce-specific way.
  • I am using a child theme (the default Storefront theme with minimal customization) in a development/testing environment.
  • I am placing all customization PHP code in the child theme functions.php file in order for theme updates to not overwrite and remove said changes.
  • I am using Local by Flywheel for local WordPress development and absolutely love it!
Backstory and article inspiration

I’ve been searching and reading in WooCommerce Facebook groups, specific requests shop owners are asking about in those forums and attempting to implement them in a mock setup environment. This practice helps me better prepare for real-world scenario’s.

I saw one such recent post inquiring about how to change the ‘Related products‘ heading description to something else entirely. I learned about 2 different ways to accomplish this.

But…

I don’t necessarily know or can say that either of these solutions is the best practice for localization (language translation). Keep that in mind.


WooCommerce Single Product page default verbiage

If there are some related products then by default, for that section of the Single Product page, we have the “Related products” wording:

This might be a little bland for your tastes and can easily be changed to some other wording or phrase.

WooCommerce edit default Related products description: Use add_filter() hook

Using an add_filter() hook, you can target the woocommerce_product_related_products_heading hook, implementing your own callback function and return value:

WooCommerce edit default Related products description: Edit child theme template file

In your_child_theme/woocommerce/single-product/related.php file, change the $heading variable in the if( $related_products ) conditional:

Note: If you use this option, you are now responsible for updating the copy of this theme template file in your child theme should any updates be applied to the parent theme template file.

All that said, this is not likely the best solution for maintainability reasons.

But, it does work.

If you see any mistakes or corrections needed in the code, please share them freely in the comments.


Thank you for reading this post. Please share it with someone else who would enjoy it as well.




Josh Otwell has a passion to grow as a PHP Developer, SQL expert, and technical blogger/writer.

Disclaimer: The majority of examples in this post, are performed in a personal development/learning workstation environment and should not be considered production quality or ready. Your particular goals and needs may vary. Like always, just because you can do something doesn’t mean you should. My opinions are my own.

More ways I can help

Disclosure: Some of this blog post’s services and product links are affiliate links. At no additional cost to you, should you make a purchase by clicking through one of them, I will receive a commission.

The Newsletter for PHP and MySQL Developers

Receive a copy of my ebook, “10 MySQL Tips For Everyone”, absolutely free when you subscribe to the OpenLampTech newsletter.


πŸ“° Get your brand, product, or service the attention it needs with affordable classified ad placement in the OpenLampTech newsletter. Thank you for your support!


Hey thanks for commenting! Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.