Good Day,
i am struggling with the following: I am using the Prestige Theme and want to show the available sizes below the items.
Item1 S M XL XXL |
Item2 52 54 56 |
|---|
Item3 UNI |
|---|
See the link below
I have found some solutions, but it only said/works with sizes. As I have worked with differed wording in the first “Size” field (Option1 Name): such as Size, Waist, etc.
So:
| Option1 Name | Option1 Value |
|---|
May someone share the code for me and where to place it. Or show me a documentation how to do that.
A lot of code has to be pasted into: **product-grid-item.liquid (**which I don’t find)
{% assign sizes = '' %}
{% for variant in product.variants %}
{% if variant.available %}
{% assign sizes = sizes | append: variant.options[0] | append: '_' %}
{% endif %}
{% endfor %}
{% assign sizesArr = sizes | split: '_' | uniq %}
{% for size in sizesArr %}
{{ size }}
{% endfor %}
This I have found.
May someone assist me?
Thank you
Edit.
This code works, but, is there a term I can insert in shopify to display all values I inserted into Option1 Name? Or Do I have to put in all values by hand?
{%- assign avail_variants = '' -%}
{%- for variant in product.variants -%}
{%- if variant.available -%}
{%- assign avail_variants = avail_variants | append:', ' | append: variant.title | downcase -%}
{%- endif -%}
{%- endfor -%}
{%- capture product_sizes -%}
{%- for option in product.options_with_values -%}
{%- assign downcase_option = option.name | downcase -%}
{%- if downcase_option == 'size' -%}
{%- for value in option.values -%}
{%- assign downcase_value = value | downcase -%}
{%- if avail_variants contains downcase_value -%}
- {{ value }}
{%- else -%}
- {{ value }}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endfor -%}
{%- endcapture -%}
{%- if product_sizes != blank -%}
{{ product_sizes }}
{%- endif -%}