Quantity limiter

SunShopp
Excursionist
36 2 5

We Just switched to the Impulse theme and cannot figure out how to limit the maximum quantity a customer can select for a given product to what we currently have in stock.

Any help is appreciated.

Thank you

 

Store URL:

https://thesunshopp.com/

Replies 15 (15)
LitExtension
Shopify Partner
1997 332 408

Hi @SunShopp,

If your product does not have a variant, you can add the following code:

Go to snippets > quantity-input.liquid file and add code: https://i.imgur.com/c63A8Uo.png
max="{{ product.selected_or_first_available_variant.inventory_quantity }}"

If your product has multiple variants, it will be a complex requirement and you need to change it with JS too. So you need to hire an expert for it.

Please visit: https://community.shopify.com/c/Shopify-Ecommerce-Jobs/bd-p/shopify-job-board

Hope it helps!

If my answer can help you solve your issue, please mark it as a solution. Thank you and good luck.

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
SunShopp
Excursionist
36 2 5

This did not resolve the issue.

LitExtension
Shopify Partner
1997 332 408

Hi @SunShopp ,

Sorry, quantity is still changing in JS, so you need to change more code in theme.min.js file.
Go to Assets > theme.min.js , find '.js-qty__adjust--minus' and add code here:
https://i.imgur.com/kSNaywk.png , Code: this.maxValue = this.input.getAttribute("max") || 1
Find 'this._change(this._getQty())' and change code:

this._change(this._getQty())
=>
var e = this._getQty();
if (e >= this.maxValue) {
  e = this.maxValue;
}
this._change(e);

Refer https://i.imgur.com/iuTVt0w.png
Hope it helps!

 

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
SunShopp
Excursionist
36 2 5

When I make those edits images don't load and the quantity wont change past 1.

LitExtension
Shopify Partner
1997 332 408

Hi @SunShopp ,

It may be because your JS change is not correct, can you send me the whole changed code. I will check it.

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
SunShopp
Excursionist
36 2 5

First Part:

function n(n,s){this.wrapper=n,this.plus=n.querySelector(t),this.minus=n.querySelector(i),this.input=n.querySelector(e), this.maxValue = this.input.getAttribute("max") || 1,this.minValue=this.input.getAttribute("min")||1;var o={namespace:null,isCart:!1,key:this.input.dataset.id}

 

Second Part:

return n.prototype=Object.assign({},n.prototype,{init:function(){this.plus.addEventListener("click",function(){var e=this._getQty();this._change(e+1)}.bind(this)),this.minus.addEventListener("click",function(){var e=this._getQty();this._change(e-1)}.bind(this)),this.input.addEventListener("change",function(e){this._change(this._getQty())=>var e = this._getQty();if (e >= this.maxValue) {e = this.maxValue;}this._change(e);}.bind(this))

 

 

thank you

LitExtension
Shopify Partner
1997 332 408

Hi @SunShopp ,

You changed it wrong, please change:

First Part:

function n(n,s){this.wrapper=n,this.plus=n.querySelector(t),this.minus=n.querySelector(i),this.input=n.querySelector(e), this.maxValue = this.input.getAttribute("max") || 1, this.minValue=this.input.getAttribute("min")||1;var o={namespace:null,isCart:!1,key:this.input.dataset.id}

Second Part:

return n.prototype=Object.assign({},n.prototype,{init:function(){this.plus.addEventListener("click",function(){var e=this._getQty();this._change(e+1)}.bind(this)),this.minus.addEventListener("click",function(){var e=this._getQty();this._change(e-1)}.bind(this)),this.input.addEventListener("change",function(e){var e = this._getQty();if (e >= this.maxValue) {e = this.maxValue;}this._change(e);}.bind(this))

Hope it clear to you.

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
SunShopp
Excursionist
36 2 5

The page loads regularly with the new code but the quantity is still not being limited.

LitExtension
Shopify Partner
1997 332 408

Hi @SunShopp ,

Please create staff account with email: namphan992@gmail.com

I will check it for you.

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!