Hi,
I created a variant metafield that tell the portions of an item. It is showing in the product page, the problem is that it doesn’t change when choosing another variant except when I reload the page. :
Here is the JS code I added, but it is still not working :
/**
* This callback is called whenever the variant changes and allows to update data about the active variant
*/
}, {
key: "_onVariantChanged",
value: function _onVariantChanged(previousVariant, newVariant) {
// 6th: Portions
this._updatePortions(newVariant, previousVariant); // 7th: store availability
Later on
/**
* Update the Portions
*/
}, {
key: "_updatePortions",
value: function _updatePortions(newVariant) {
if (!this.options['showPortions'] || !newVariant) {
return;
}
var productPortions = this.element.querySelector('.ProductMeta__Portions');
if (productPortions && newVariant['portions']) {
productPortions.innerText = newVariant['portions'];
}
}
Can somebody help me?
Thank you!