I am trying to display the metafields assigned to the product variants. It has five size and five colors. I have assigned “single line text” type metafield only to small size of five color. When I print it by this code:
{% for variant in product.variants %}
{% if variant.metafields.custom.variant_color %}
{{ variant.metafields.custom.variant_color }}
{% endif %}
{% endfor %}
then it is displaying all the fields. I want to display one by one whenever I click a on a color. Also I haven’t assigned the data to other sizes but it still showing on all the sizes when clicked. Need Help.
I tried this, it is now displaying the first field ‘coral’ on coral color but not changing when I select other size or color. I tried doing js as well but it’s not working. Can you help me with that?