Skip to content

Instantly share code, notes, and snippets.

@DanWebb
Created May 2, 2015 08:20
Show Gist options
  • Save DanWebb/6e28c5e0fed783f0698e to your computer and use it in GitHub Desktop.
Save DanWebb/6e28c5e0fed783f0698e to your computer and use it in GitHub Desktop.
Get whether some (but not all) of the variants products are out of stock
{% assign some_stock = false %}
{% assign out_of_stock = 0 %}
{% for variant in product.variants %}
{% if variant.available == false %}
{% assign out_of_stock = out_of_stock | plus: 1 %}
{% endif %}
{% endfor %}
{% if product.variants.size != out_of_stock and out_of_stock > 0 %}
{% assign some_stock = true %}
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment