Add the following code to product-template.liquid, put the code at the bottom of the file:
<script type="application/json" id="VariantJson-{{ section.id }}">
[
{% for variant in product.variants %}
{
"incoming": {{ variant.incoming | default: false | json }},
"next_incoming_date": {{ variant.next_incoming_date | date: format: 'month_day_year' | json }},
"inventory_policy": {{ variant.inventory_policy | json }},
"inventory_quantity": {{ variant.inventory_quantity | json }}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
</script>
Then add the following code to theme.js, search _initVariants: function() {this, above it:
addVariantInfo: function() {
if (!this.productSingleObject || !this.settings.stockSetting) {
return;
}
var variantInfo = JSON.parse(
$('#VariantJson-' + this.settings.sectionId).html()
);
for (var i = 0; i < variantInfo.length; i++) {
$.extend(this.productSingleObject.variants[i], variantInfo[i]);
}
},
This will not cause a variable error.
Subject | Author | Latest Post |
---|---|---|
Subject | Author | Posted |
---|---|---|
59m ago | ||
an hour ago | ||
yesterday | ||
yesterday | ||
yesterday |
User | Count |
---|---|
88 | |
61 | |
61 | |
56 | |
37 |