Shopify: List product variations on collection pages

The code below will allow you to display a set of product variations on a Shopify product collection pages.

Set this code in the collections page product loop, or within the liquid snippet that controls the display of products. On line three I’ve specified “Weight” as the option I want to display so on the list page the customer can see that I have 25ml, 50ml, and 100ml product sizes available.

{% for option in product.options %}
  {% if option == 'Weight' %}
    {% assign index = forloop.index0 %}
      {% for variant in product.variants %}
        {{ variant.options[index] }}
      {% endfor %}
    {% endif %}
{% endfor %}

Published by

Keith Greer

Senior PHP and Magento Web Developer in Belfast, Northern Ireland.