New Shopify Certification now available: Liquid Storefronts for Theme Developers

Expanse Theme - Update metafield variant on Shopify product

3 0 0


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="{{}}" {% if == %} 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 %}
{%- 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) {

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

Replies 0 (0)