A frequently requested feature on product pages is a “related products” section, which lists promo items relevant to the product. While many third-party apps offer this functionality, at Slicedbread, we first consider whether it can be built directly within the theme to avoid adding another app.
Although apps are essential to Shopify and provide valuable features, they can also increase costs and impact store performance. For cross-sell sections, Shopify’s built-in recommendations object offers an effective solution.
The full spec can be found at https://shopify.dev/docs/themes/liquid/reference/objects/recommendations.
Here is our standard product page

Below this we want to add a new “related products” section so that we can automatically recommend other products to the customer.
This is the code you need:
|
{% if recommendations.performed %} |
The recommendations object is central to this process and includes three key properties. The recommendations.products property lists all products related to the current product, as determined by Shopify’s algorithm. You do not need to manage these criteria, as Shopify handles them automatically.
The recommendations.product_count property returns the number of related products, which we use to display the related products section only when at least one related product exists.
The recommendations.performed property confirms that recommendations have been generated, ensuring the subsequent code runs only when necessary.
With that code added our product now generates the related products section that we want.

There we have it! A related products section built using the tools provided by Shopify and not an app in sight.