Skip to content

Instantly share code, notes, and snippets.

@joe-dempsey
Last active September 28, 2022 16:12
Show Gist options
  • Save joe-dempsey/dd361351452a0114b3fca2dca28e8763 to your computer and use it in GitHub Desktop.
Save joe-dempsey/dd361351452a0114b3fca2dca28e8763 to your computer and use it in GitHub Desktop.
Shopify loops (useful for debugging)
looping variants:
{% for variant in product.variants %}
<p>{{ variant.title }}</p>
{% endfor %}
... more coming soon...
{% for variant in product.variants %}
{% if variant.available %}
{% if variant.title contains "size" %}
<li>{{ variant }}</li>
{% endif %}
{% else %}
<li class="disable">{{ variant.option2 }}</li>
{% endif %}
{% endfor %}
<p>options loop: {{ product.options | join: ', ' }}</p>
{% for option in product.options %}
{{ option }}
{% endfor %}
{% for option in product.options %}
{% if option == 'Color' %}
Color: {{ product.variants.first.options[forloop.index0] }}
{% endif %}
{% endfor %}
{% for option in product.options %}
{% if option contains 'Size' or option contains 'size' or option contains 'Sizes' or option contains 'sizes' %}
<p class="product-size">{{ product.variants.options[forloop.index0] }}</p>
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment