I've created a way to filter products in my Shopify shop by size on any given collection page. However, it only works when size is the only variant.
For my shop that's fine, but since I've open sourced the filter, I'd like it to work for just one variant even when there are more than one variants.
The trouble seems to be that a line like {% for variant in product.variants %}
works for just one present variant (e.g. size), but I cannot seem to pass a size argument such as {% for variant in product.variants.size %}
.
I even tried the recommended variant.option1
(i.e. {% for variant in product.variants.size.option %}
) but to no avail.
Is there some way of outputting just an array of the size variants even when there are multiple variants for a product?
Also, found this similar question, but it was not similar enough to provide a solution for my use case.
product.variants.size
will return number of product variants total only. – Minh Bui