Have your say in Community Polls: What was/is your greatest motivation to start your own business?

The displayed variant metafield doesn't match the selected variant

The displayed variant metafield doesn't match the selected variant

Justie
Visitor
2 0 1

Hello,

 

I'm using the Dawn theme and I'm trying to add some informations on the product page when a variant is selected.

I've created some metafield for my variants.

I've added a custom liquid block on my product page but it always shows the same metafield.

It's doesn't change according to the selected variant.

 

Here is the custom liquid I've used :

<h3>
{% for variant in product.variants %}
{% if variant.metafields.custom.size.value != blank %}
{% if product.selected_or_first_available_variant.id == variant.id %}
{{ variant.metafields.custom.size }}
{% endif %}
{% endif %}
{% endfor %}
</h3>

 

How to display only the metafield of the selected variant ?

Thank you in advance for any help.

Replies 0 (0)