Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
I have setup variant metafield that I would like to change depending on the variant selected. I am running Dawn 2.0 and can get the dynamic PRODUCT metafields to show - but I can't get it to dynamically change when a product has multiple variants.
Any posts I have found regarding this topic is very confusing and I even have coding experience. However, I don't know JS or liquid that well. Can someone help me with telling me exactly what code to copy and paste into what area in the Dawn 2.0 theme?
Here is the code I want to work and dynamically update when a certain variant is selected:
-------------------
{%- if product.metafields.my_fields.case_size.value >0 -%}
<p>Case Size: {{ product.metafields.my_fields.case_size.value }} x {{product.metafields.my_fields.container_volume | metafield_text }}/
{{product.metafields.my_fields.container_type.value }}
</p>
{%- else -%}
<p>Product not sold in cases</p>
{%- endif -%}
-------------------
Any help you can provide would be greatly appreciated!
Hi,
Very likely the variable is a string so the best way to check if it got a value is this:
{% if product.metafields.my_fields.case_size.value != null and product.metafields.my_fields.case_size.value != "" %}
Hope it helps.
Cheers,
Gonkas
User | RANK |
---|---|
225 | |
102 | |
92 | |
57 | |
43 |