How can I omit recommendations for certain products?

Themes Templates Developers

By default, if you add the Product widget you'll get a set of product recommendations on every product page. We were recently asked how to omit those product recommendations for a handful of 'standalone' items in the store. One example of this might be if you offer a product that goes with almost everything on the store (say, a power cable or batteries) or a service like installation.

The way to do this is to set up a hidden Collection containing the products for which you don't want recommendations to appear.

Then edit your product.liquid template so that the Better Recommendations widget is not included for products that are a member of this collection.

{% assign in_no_recs_collection = false %}
{% for collection in product.collections %}
  {% if in_no_recs_collection == false and collection.title == 'NoRecommendations' %}
    {% assign in_no_recs_collection = true %}
  {% endif %}
{% endfor %}

{% if in_no_recs_collection == false %}
  {% include 'betterrecs', purpose: 'product' %}
{% endif %}

Note that these products can still appear in the recommendations shown on other product pages. If you want to stop them being recommended you can easily do this with the Excluded Collection setting.

Find us on Shopify