Created
August 1, 2018 14:56
-
-
Save sweethoneycode/8b049e96bf0ea8b9d88afee405eaac21 to your computer and use it in GitHub Desktop.
Product-template.liquid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<br> | |
<div class="custom-avail-field"> | |
{% if current_variant.available %} | |
{{ 'products.product.remaining' | t }}: <span id="inventoryQuantity">{{ current_variant.inventory_quantity }}</span> | |
{% endif %} | |
</div> | |
<div class="custom-avail-field"> | |
{% if current_variant.available %} | |
Weight: <span id="inventoryWeight">{{ current_variant.weight }} grams</span> | |
{% endif %} | |
</div> | |
<script> | |
var variant_inventory = []; | |
{% for variant in product.variants %} | |
variant_inventory[ {{ variant.id }} ] = {{ variant.inventory_quantity }}; | |
{% endfor %} | |
</script> | |
<script> | |
var variant_weight = []; | |
{% for variant in product.variants %} | |
variant_weight[ {{ variant.id }} ] = {{ variant.weight }} + ' grams'; | |
{% endfor %} | |
</script> | |
in theme.js | |
$('#inventoryQuantity').html( variant_inventory[ variant.id] ); | |
$('#inventoryWeight').html( variant_weight[ variant.id] ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment