1
votes

I'm using Shopify as my eCommerce platform. My customer has some products that are related to each other. But don't think of a typical related products system, basically these products have parts, and those individual parts can be reordered separate from the product itself.

The client wants to list all the parts for a given product on the product page. The parts are each cataloged as an individual product themselves. The parts have a "part" tag to identify them as a part, and they have a "part:handle" tag to identify which product they are associated with.

On the product page I attempted to do something like this:

{% for product in collection.products %}
    product
{% endfor %}

I know this code will not do what I'm ultimately trying to do, but I tried it just to see if I could access collection data on the product page. It doesn't work. But it does work on the COLLECTION page. Is there any way to access collection data while on the product page? Do I need to use the Shopify API for this? Can anyone provide an example? Thanks!

1

1 Answers

1
votes

You can use the global collections object to access collection info from any page.

Here's an example from the Shopify documentation that iterates over products in the "frontpage" collection:

{% for product in collections.frontpage.products %}
  {{ product.title }}
{% endfor %}

The liquid object collections contains a list of all of the collections in a shop.