Skip to content

Instantly share code, notes, and snippets.

@dylanjhunt
Last active August 28, 2020 01:17
Show Gist options
  • Save dylanjhunt/2a8438b5dca61075d294131b55b46681 to your computer and use it in GitHub Desktop.
Save dylanjhunt/2a8438b5dca61075d294131b55b46681 to your computer and use it in GitHub Desktop.
Filter by size in stock Shopify step 2
{% assign sizes = '' %}
{% assign outofstock = false %}
{% for tag in current_tags %}
{% if tag == 'XS' or tag == 'S' or tag == 'M' or tag == 'L' or tag == 'XL' %}
{% assign outofstock = true %}
{% endif %}
{% endfor %}
{% for variant in product.variants %}
{% if variant.available %}
{% assign sizes = sizes | append: variant.options[1] | append: ' ' %}
{% if current_tags contains variant.options[1] %}
{% assign outofstock = false %}
{% endif %}
{% endif %}
{% endfor %}
{% if outofstock == false %}
<!-- INSERT THE PRODUCT GRID HERE -->
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment