Display on Product Page: All of the Product's Collections *From a Specific Linklist*

TrueloveSeeds
New Member
2 0 0

Hello all - 

I am trying to take this code (provided by @Alex135 here: RESOLVED-Display-Collection-on-Product-Page) but alter it so that it displays ALL associated collections (not just the first).

 

{% assign custom_collection_linklist = 'changetolinklisthandle' %}

{% assign product_collections = product.collections | map:'handle' %}
{% for link in linklists[custom_collection_linklist].links %}
  {% if link.type == 'collection_link' and product_collections contains link.object.handle %}
    {% assign product_collection = link.object %}
    {% break %}
  {% endif %}
{% endfor %}

{% if product_collection %}
  This product is part of the following collections: {{ product_collection.title | link_to: product_collection.url }}.
{% endif %}

 

 

If the product is part of more than one collection from the linklist, I'd like them to be comma-separated.

Thanks!

0 Likes