Expanse Theme - Update metafield variant on Shopify product

Expanse Theme - Update metafield variant on Shopify product

mpaule1004
Visitor
3 0 0

Hello,

I got this variant Dimension and Cubage, I already display the variant on single product, but the problem when I select other variation, the page need to refresh before its change the information

here is my code
{% for variant in product.variants %}
<div class="variant__description" data-variant-id="{{variant.id}}" {% if product.selected_or_first_available_variant.id == variant.id %} style="display: block;" {% endif %}>
{% if variant.metafields.custom.variant_size %}
<p><span class="font-body-bold">Dimension:</span>{{ variant.metafields.custom.variant_size }}</p>
{% endif %}
{% if variant.metafields.custom.variant_cubage %}
<p><span class="font-body-bold">Cubage:</span>{{ variant.metafields.custom.variant_cubage }}</p>
{% endif %}
</div>
{%- endfor -%}

anyone can help how to update variant when I click for example I have 2ft, 3ft and 4ft. I just check theme.js
and found this in Unit price change, I'm just new and studying the Expanse Theme.

_updateUnitPrice: function(variant) {
if (this.currentVariant && variant.unit_price === this.currentVariant.unit_price) {
return;
}

this.container.dispatchEvent(new CustomEvent('variantUnitPriceChange', {
detail: {
variant: variant
}
}));
},


Replies 0 (0)