How to add qty plus minus buttons in shopify?

Sorry this is not a detailed description but a summary with all code Add available quantities first – as shown in this article – How to show stock quantities in all variants of shopify ^The above part is utmost necessary. because the following functions use previous js variables. So here we go. Good Luck!! javascript on the product page <script> $(document).ready(function($){ var $j=new jQuery.noConflict(); var qtyinput=$j("#quantity"); var qtyplus=$j("#qtyplus"); var maxallowed=parseInt($j(qtyinput).attr('max')); var qtyminus=$j("#qtyminus"); var qtyvalue=parseInt($j(qtyinput).val()); setTimeout(function(){$j(qtyminus).removeClass("hidden"); $j(qtyplus).removeClass("hidden"); },8000); $j(qtyminus).click(function($){ qtyvalue=parseInt($j(qtyinput).val()); maxallowed=parseInt($j(qtyinput).attr('max')); if(qtyvalue<2){checkFreeze(); return;} $j(qtyinput).val(qtyvalue-1); checkFreeze(); }); $j(qtyplus).click(function($){ qtyvalue=parseInt($j(qtyinput).val()); maxallowed=parseInt($j(qtyinput).attr('max')); // console.log(qtyvalue + " -- - -" + maxallowed); if(maxallowed<=qtyvalue){ checkFreeze(); return;} $j(qtyinput).val(qtyvalue+1); checkFreeze(); }); }); </script> html tags on product page. make sure you add these AROUND quantity input ...

July 21, 2019 · 2 min · Harshvardhan Malpani

How to show stock quantity for all variants in shopify?

How to show “xxx left in stock” on shopify product page? Shopify – show ONLY XX AVAILABLE IN STOCK on product page Start by adding snippet in product-template.liquid <div id="stockstatus"> {% if product.variants.size < 2 %} {% assign current_variant= product.variants.first %} {% endif %} {% if current_variant.inventory_quantity < 1 %} <p class="zero">Sold Out!<span class="variant-inventory">{{ current_variant.inventory_quantity }}</span></p> {% elsif current_variant.inventory_quantity < 6 %} <p class="few">Hurry! Only <span class="variant-inventory">{{ current_variant.inventory_quantity }}</span> left in stock.</p> {% else %} <p class="plenty"><span class="variant-inventory">{{ current_variant.inventory_quantity }}</span> available in stock.</p> {% endif %} </div> <script> var inv_qty = {}; {% for var in product.variants %} inv_qty[{{- var.id -}}] = {{ var.inventory_quantity | default: 0 }}; {% endfor %} </script> Now in theme.js or theme.js.liquid and edit function updateSku / _.updateSku ...

July 15, 2019 · 2 min · Harshvardhan Malpani