0
votes

I have a shopify store with new, used and refurbished amplifiers & speakers. This condition is stored in a manual collection (four of them). The others collections being automated. I would like to display the condition of the product on the product page or the products list. So basically I need to get all the collections and filter to display one of the four : If the product belongs to collection "used" display collection "used" If the product belongs to collection "new" display collection "new" etc...

The closest to what I want to do has been made trough this code :

{% assign product_collection = product.collections.first %}

{% if product_collection %}

This product is part of my {{ product_collection.title | link_to: product_collection.url }} Collection

{% endif %}

Found here : https://community.shopify.com/c/Shopify-Design/RESOLVED-Display-Collection-on-Product-Page/td-p/230899

With this I am not able to filter on the four collections.

I have spent the day on this...If somebody can help, that would save my day :)

1

1 Answers

0
votes

You can add all collections(title or handle value) on the product-grid-item.liquid.

<div class= "grid-item 
    {% for product_collection in product.collections %}
        {{product_collection.title | handle }} 
    {% endfor %}
">
...
</div>

And then you can filter them with JavaScript on the frontend. Hope this could help you