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 17 (17)
LitExtension
Shopify Partner
3353 661 721

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
3353 661 721

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
3353 661 721

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
3353 661 721

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
3353 661 721

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!
LitExtension
Shopify Partner
3353 661 721

Hi @SunShopp ,

Please change 'Second Part:'

return n.prototype=Object.assign({},n.prototype,{init:function(){this.plus.addEventListener("click",function(){var e = this._getQty();if (e >= this.maxValue) {e = this.maxValue;}this._change(e);}.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() + 1;if (e >= this.maxValue) {e = this.maxValue;}this._change(e);}.bind(this))

 

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

With that change the quantity selector wont go above 1.

LitExtension
Shopify Partner
3353 661 721

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!
LitExtension
Shopify Partner
3353 661 721

Hi @SunShopp ,

I checked and this JS function is called in many places, so if possible please create staff account, I will help you debug and rewrite 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

Sorry for the delay. We will actually be bringing things in house.

Thank you for your time.

LitExtension
Shopify Partner
3353 661 721

Hi @SunShopp,

I saw you liked my answer. If it helped 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!
magecomp
Shopify Partner
80 4 6

Hello @SunShopp 

Our simple app can help you to fulfill your requirements

 

https://apps.shopify.com/purchase-limit?
https://apps.shopify.com/limit-sales-per-day? 

Checkout Our Bestseller Shopify App
Limit Qty Purchase
janvi_22
New Member
10 0 0

Hey @SunShopp,

 

I understand your query. I can suggest you one extension called Limit Quantity Purchase

 

The features of this app are as below: 

1. Specific Product purchase limits Minimum and Maximum.

2. Flexible Purchase Limit of items within a group of products.

3. Apply Limit For individual products or collection

 

It has all the features that you have mentioned in your query. Please, check it out here for more details: Shopify Limit Qty Purchase

 

Hope this helps you. 

 

Thank you.