Solved

Is there a limit to product quantity selection in Shopify?

Walker_Edwards
Tourist
7 0 12

Apologies if this has been answered but I can't seem to find it.

 

Using the Pop theme I have enabled the Product Quantity selector. As it is currently programmed, a customer can select an infinite qty and only on the cart page are they notified that the qty they selected is unavailable and it will need to be reduced. My expectation of functionality would be that if a variant has an available qty of 4 that the qty selector would max out at 4 and not allow the customer to select a qty of 5+ before clicking add to cart. Shopify support says Development is "aware" of this. Thanks in advance!

Accepted Solution (1)

Lilith
Shopify Staff
603 73 185

This is an accepted solution.

Hey, @Walker_Edwards!

 

My name is Lilith, I'm on the Social Care team at Shopify.

 

The above answer from @Jasoliya will work excellently! I also wanted to drop a few screenshots of how Pop works for limited quantities.

 

Pop Theme notification

 

It does have a notice on the Product Page before going to the Cart Page where the customer can have a limit of how many items they can add to the cart.

If you have Shopify tracking your inventory this is what it'll look like.

 

This is the inventory set at 10 maximum on a test store for these variants:

 

 

alt

 

 

When viewing the site, this is what happens if more than the maximum is selected:

 

 

alt

 

 

It shouldn't allow the customer to add the item to the cart. If this isn't happening on your site, there could be some custom code that could be interfering with it. The other reason this might not show up is if your theme is not up to date. In the latter case, I'd recommend downloading a fresh copy of the theme and adding your customized visuals to it if you haven't had too many customizations to the theme, this will usually help solve several things for merchants.

 

Showing Inventory Left In Stock

 

Another helpful option that I've used frequently in my own stores is to add a snippet to the product page as well to let customers know how much is left in stock.

 

Here's the snippet I used on any Pop theme:

 

 <div>{{ variant.inventory_quantity }} left in stock</div>

 

You can add it anywhere in the Section called product-template.liquid, but here's where I normally placed it:

 

 

alt

 

 

Of course, you can add styles to it and change the font format and much more, but for the purposes of simplicity, I've left it plain here.

Here's what it looks like on the site:

 

 

alt

 

 

Some other options

 

I've got a couple of apps that can do a similar display of in-stock numbers as well if you'd like to check them out.

 

I do like using a display of inventory on products even if a maximum quantity is limited on the page. This display of stock count helps drive a bit of urgency and can really boost conversions in the long run as well. I love using it, but this is just an option and an idea that might help as well.

 

Here are the apps that can help with this if you don't want to modify the code:

 

 

Let me know how you do with the information above! I'm happy to answer any questions you think of as you work on your business.

Lilith | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

View solution in original post

Replies 30 (30)

Jasoliya
Shopify Expert
4808 621 1217

Hi @Walker_Edwards 

Follow this:

1. Section -> product-template.liquid -> find your quantity box and add bellow code:

max="{{ product.selected_or_first_available_variant.inventory_quantity}}"

So it look like something:

<input type="number" id="Quantity-{{ section.id }}" name="quantity" max="{{ product.selected_or_first_available_variant.inventory_quantity}}" value="1" min="1" class="product-form__input" pattern="[0-9]*">

If you have variants then you have to change max value using Js from Asset->theme.js from variants select callback function.  find if(variants)

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
saraht
Tourist
3 0 3

Thanks @Jasoliya for the answer to the previous question!  I was able to implement it for singular products, but was unable to figure out how/where/what code to write  to update product variant max quantities on the product page.  Would you be able to instruct me how to do this for variants in the Debut template, please?  I searched in Js for "if (variant)" but I've really no idea what to do. 

Jasoliya
Shopify Expert
4808 621 1217

What you want to do exact? 

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
saraht
Tourist
3 0 3

I have products with multiple variants, and would like to set the max quantity for each variant on the product page quantity selector.  So if a customer chooses a variant, they are able to select the maximum quantity of that variant, and not be given the option to select a higher number. 

Jasoliya
Shopify Expert
4808 621 1217

Then you have to manage it by Js code.

you have to get qty from variant callback function and then place as MAX attribute in qty selector so user can not ad more MAX qty. 

You can fine if(variant) in theme.js file, where you can get variant object in Js

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
andreea204
Visitor
1 0 0

Saraht, i have the same problem? Did you fix it? Can you help?


@saraht wrote:

I have products with multiple variants, and would like to set the max quantity for each variant on the product page quantity selector.  So if a customer chooses a variant, they are able to select the maximum quantity of that variant, and not be given the option to select a higher number. 





 

saraht
Tourist
3 0 3
Unfortunately, no, I didn't fix it. I don't know anything about coding, so
I'll have to hire someone to do it for me, if I want it done, because I
couldn't figure it out. I tried and failed.
CiaoBella
Tourist
9 0 8

Can anyone help me with this? The two things I'd love to have on my site, mind you I can copy and paste code into a certain spot if directed exactly but that is the limit on my coding ability. 

1. Need quantity available on products for EACH VARIANT shown on the product pages for customers. Preferably BELOW where they select the quantity they are going to purchase. 

2. Need a customer to only be able to add what is available in stock for a item to their carts. NO I do not want them to add it to their cart and then get an error at checkout. NO I do not want them to go over the amount available and then get an error below on the product page saying they can't add said item to their cart. It doesn't explain to them why and they might think the item is out of stock. Both of those instances are frustrating for customers and we could loose the sale. 

I can't believe these two items are not standard on any Shopify theme since they are standard everyday things needed to sell retail. 

Thank you in advance to anyone who can help since I have been hunting for the solution since launching my site. 

My theme is Minimal and the website is www.ciaobellaboutique.shop

Lilith
Shopify Staff
603 73 185

@CiaoBella for Minimal you can try out this solution that has worked for other merchants. That other forum post thread has some great solutions for your theme type. Have you had a chance to try those out?

Lilith | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Jahangir
Shopify Partner
96 2 16

Hello @CiaoBella,

You can easily solve this by using the  MultiVariants - Bulk Order app. The app will display all available variants with a quantity selector. You can define the quantity selector for quantity selection. It will automatically check your available stock quantity and will not allow customers to input quantity over your available.

Here is the demo you can take a look at.

Quantity selector (drop-down)Quantity selector (drop-down)

Jahangir | EFOLI
- Was my reply helpful? Please Like and Accept Solution!
- Selling Personalized Products? Try Inkybay | For bulk variant order, check MultiVariants
mstav2u
Excursionist
21 0 1

I am searching the same thing for my Debut theme.  I just want my customers to be able to purchase the amount I have, not get an error if they select more than I have in stock.  How frustrating this is for a customer.  Any help for the Debut theme on quantity control?  Thanks.

Muhtasham
Visitor
2 0 0

How to do it in turbo parallax theme.

Lilith
Shopify Staff
603 73 185

@Muhtasham since Parallax is a 3rd party theme, our support team isn't able to support this modification. The theme is supported by a fantastic partner, Out of the Sandbox. They might be able to assist you, but you may need to keep in mind that modifications might not be free. You can find the link to reach their support on the theme store page.

Alternatively, you can also hire a Shopify Expert to customize your theme in any way you need to fit your business. I highly recommend hiring one of our partners to help you with this. You can find a suitable Shopify Partner in the Experts Marketplace or request a quote by following this guide here.

Lilith | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

rachlstan
Tourist
5 0 2

I'm having the same issue but using Minimal.  Let me know how to fix.  Thank you! 

Lilith
Shopify Staff
603 73 185

Hi, @rachlstan! Turns out there was someone else in this thread that had the same situation on Minimal as well. You can check the reply and link to some solutions here 😊

Lilith | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

rachlstan
Tourist
5 0 2

I believe I followed the coding steps and did not work. Can someone provide a new thread to include the step by step process for Minimal?  Thank you. 

Jackielazzi
Tourist
3 0 1

hello,

I am using the DAWN themes and I was able to limit the quantity to the stock level

However, I have variant in my shop and I wanted to also add this on the quantity selector. My current HTML looks like this:

 

<input class="quantity__input"
type="number"
name="quantity"
id="Quantity-{{ section.id }}"
min="1"
value="1"
max="{{ product.selected_or_first_available_variant.inventory_quantity}}"
form="product-form-{{ section.id }}"
>

 

thank you for your help,

Jackie

mstav2u
Excursionist
21 0 1

In reply to the solution for the limit quantity selector as this was a question I have been looking for a solution to.  You say to add the code under the section product-template and then if you have variants to go to jstheme, but I'm confused on what you need to change in there when you go to the callback function?  I did the first code and checked my store and now quantity goes to 8 on everything, so I am assuming it has to do with whatever needs done in the jstheme?  At least the quantity is stopping at a certain amount instead of going on for infinity.  Any help is appreciated.  Thanks.

Marilyn

mstav2u
Excursionist
21 0 1

Not understanding the part where you say if you have variants.  I did the first part and it stops my product quantities from going on forever, but I have variants, so need to change the code there, but not understanding what exactly you change and for some reason can't find where?  I found the variant area.  Any help at all?  Thanks in advance.

Lilith
Shopify Staff
603 73 185

@mstav2u there may be some additional steps that you might need for your specific theme and situation. I highly recommend hiring one of our partners to help you with this if you're still looking for a solution. You can find a suitable Shopify Partner in the Experts Marketplace or request a quote by following this guide here.

Lilith | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

Khan01
Excursionist
70 0 4

Dear @Jasoliya ,

Can you please guide what code do we need to add/edit in theme.js file to restrict the Quantity Selector for a site that has variants.?

Jasoliya
Shopify Expert
4808 621 1217

Hi @Khan01  its all depend on your theme code, what we have given is for free shopify theme 

Best regard 

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
Khan01
Excursionist
70 0 4
I am using Shopify’s Debut theme (which is a free theme).

Can you please guide what code do I need to add OR edit in the *theme.js*
file of the Debut theme.?
Jasoliya
Shopify Expert
4808 621 1217

You have to find where is variant callback function coded and then in variant change event you have to get actual qty of that variant and then change to "max" attribute, its bit complicated if you dont know js and all, i can just give way and idea for that, or hire someone or me 

Best regard 

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here
Khan01
Excursionist
70 0 4

@Jasoliya I know some JS  🙂

Do you mean to say that I need to add some code in the below snippet:

 

   /**
     * Event handler for when a variant input changes.
     */
    _onSelectChange: function(){

      var variant = this._getVariantFromOptions();
      
      this.container.dispatchEvent(
        new CustomEvent('variantChange', {
          detail: {
            variant: variant
          },
          bubbles: true,
          cancelable: true
        })
      );

      if (!variant) {
        return;
      }

      this._updateMasterSelect(variant);
      this._updateImages(variant);
      this._updatePrice(variant);
      this._updateSKU(variant);
      this.currentVariant = variant;

      if (this.enableHistoryState) {
        this._updateHistoryState(variant);
      }
    },

 


If yes, what do I need to add OR edit here.? 

Jasoliya
Shopify Expert
4808 621 1217

yes you have to code here. you can code below this ' var variant = this._getVariantFromOptions();'

logic i given to you first you have to code in liquid  and add your actual qty of each variant as attribute and then get this attribute and manage from this js you have to manage 

 

Want custom changes? hire me.
3 months of Shopify for $1/month. Look here.
Email us Or WhatsApp, Try our Free app for product bundles and Codify Order Cancel or Order edit
Want to get Free review and advice for sale on store ?? just text me here

Lilith
Shopify Staff
603 73 185

This is an accepted solution.

Hey, @Walker_Edwards!

 

My name is Lilith, I'm on the Social Care team at Shopify.

 

The above answer from @Jasoliya will work excellently! I also wanted to drop a few screenshots of how Pop works for limited quantities.

 

Pop Theme notification

 

It does have a notice on the Product Page before going to the Cart Page where the customer can have a limit of how many items they can add to the cart.

If you have Shopify tracking your inventory this is what it'll look like.

 

This is the inventory set at 10 maximum on a test store for these variants:

 

 

alt

 

 

When viewing the site, this is what happens if more than the maximum is selected:

 

 

alt

 

 

It shouldn't allow the customer to add the item to the cart. If this isn't happening on your site, there could be some custom code that could be interfering with it. The other reason this might not show up is if your theme is not up to date. In the latter case, I'd recommend downloading a fresh copy of the theme and adding your customized visuals to it if you haven't had too many customizations to the theme, this will usually help solve several things for merchants.

 

Showing Inventory Left In Stock

 

Another helpful option that I've used frequently in my own stores is to add a snippet to the product page as well to let customers know how much is left in stock.

 

Here's the snippet I used on any Pop theme:

 

 <div>{{ variant.inventory_quantity }} left in stock</div>

 

You can add it anywhere in the Section called product-template.liquid, but here's where I normally placed it:

 

 

alt

 

 

Of course, you can add styles to it and change the font format and much more, but for the purposes of simplicity, I've left it plain here.

Here's what it looks like on the site:

 

 

alt

 

 

Some other options

 

I've got a couple of apps that can do a similar display of in-stock numbers as well if you'd like to check them out.

 

I do like using a display of inventory on products even if a maximum quantity is limited on the page. This display of stock count helps drive a bit of urgency and can really boost conversions in the long run as well. I love using it, but this is just an option and an idea that might help as well.

 

Here are the apps that can help with this if you don't want to modify the code:

 

 

Let me know how you do with the information above! I'm happy to answer any questions you think of as you work on your business.

Lilith | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

mstav2u
Excursionist
21 0 1

When I put the snippet code in that someone suggested, all that came up on my page was left in stock(did not show a quantity).  Was there something else I needed to do?

RobGFP
New Member
9 0 0

I'm having the same issue where the code results in text just saying "left in stock" and not showing a quantity. Does anyone have a solution to this?

Lilith
Shopify Staff
603 73 185

@RobGFP are you looking for a way to remove the text or is the code not working to assist with the quantity limits itself?

Lilith | Social Care @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog