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