How do I limit the total quantity per product that the customer can purchase?

We have very low print run items in our shop.

I just need a fix to edit the liquid code for the various product variations that allows us to limit it to 1 or 2 TOTAL per customer, no matter which variants/option they pick.

Can we limit it at the global product level instead of having to go into the individual options?

Can we display text that says, limit x per customer?

Limit Quantity, Limit Total, Limited Edition

I want to hard code this and don’t want to mess with a monthly app with more features.

Can someone help me out?

@JosephAMichael

Welcome to the Shopify community!
Thanks for your good question.

Please share your site URL,
I will check out the issue and provide you a solution here.

Hi @JosephAMichael

you can do this by using some liquid code and jquery code.
when customer change the value match the value with maximum one if its low or equal to the maximum one add cart button will work otherwise not working.

Can you share or screenshot me what the code should be changed to?

Hi @JosephAMichael
Have to write code according to your website.
It will take 3-5 Hours.

How much in usd will it cost and what is your turnaround to complete it?

Can you make sure that nothing else will break or change with the coding?

Hi @JosephAMichael

If you are still looking for a solution to this you can try using the Checkout Guardian app, wherein you can restrict the user to a maximum number of purchase and if added more he wont be able to checkout. You can display a customised message to the client saying you can order only 2 products from the store and further restrict them from future purchase also.

Let me know if you find this app suitable as per your requirment.

Hello Joseph, you can limit per item quantity to any fixed number using the Cart Lock https://apps.shopify.com/cart-lock app. Follow the steps below:

  1. Open the app and click on the “Add a new rule” button.
  2. Click “Add a new condition” and select the “Single item quantity” option then add quantity limit like 2.
  3. In the “Error message” field, add an appropriate message which will be displayed in the checkout page.
  4. Save the rule.

That’s it. Now your customers cannot buy more than 2 quantity per items.

Yes — you can limit the total quantity per product, even across variants, without touching Liquid or writing custom scripts.

I had the same issue with some limited-run items, and the manual code approach kept breaking (especially with AJAX carts and variant changes). What ended up working reliably for me was using a small checkout-validation tool that lets you set per-product or per-variant limits, like:

  • Max 1 per customer

  • Max 2 per product (all variants combined)

  • Min/Max order quantity rules

  • Custom error messages at checkout

It took less than a minute to set up, and it applies across the cart, product page, and checkout.

Here’s the one I’m using this app shopify

It lets you build simple rules like “limit 2 per product” or “limit 1 per customer,” and shows a clean validation message before checkout. No theme editing, no custom code.

Hi @JosephAMichael

You are able to add a per customer limit by using a simple script that checks the cart contents in your theme’s code: it counts the total quantity of a product (across variants). If limit is exceeded, prevent checkout and display your message. For clarity for customers, add a static note on the product template.

Hi @JosephAMichael :raising_hands:

I see you’d like to limit the maximum quantity a customer can purchase for a product — for example, allowing only 1 or 2 units regardless of the variant selected. This can be achieved using Easify Product Options.

Here’s an example I’ve created so you can see how it works:

  • This is the result:

  • This is the app setting:

To control how many items customers can select, go to the Advanced settings of your option and adjust the limits under Limit quantity input. There, you can set a Min quantity and Max quantity, or require customers to select an exact total quantity using the Set an Exact Total quantity for all selected items feature.

This allows you to control quantities per customer without manually adjusting Liquid, while still ensuring a smooth, accurate shopping experience.

It’s incredibly easy to use and performs perfectly when it comes to product personalization. Easify’s support team is just a message away if you ever have questions. :blush:

I saw your question about limiting the total quantity across variants of the same product. Shopify tracks purchases per variant, so a combined cap needs a customer-level rule.

In DC Order Limits, use Customer Purchase Limits and apply it at the product level so the limit counts across all variants of that product.

Setup:

  1. Create a new Customer Purchase Limit rule

  2. Set the max quantity, for example, 1 or 2

  3. Select the product; the limit applies across its variants

  4. Save and activate

After it is active, the customer’s total across variants is tracked, and additional units are blocked at checkout once the cap is reached.

Hello @JosephAMichael
I understand that you’re looking for a hard-coded solution to limit the total quantity per customer for a product, and I appreciate that you’re trying to avoid using third-party apps with monthly fees.

However, while you can technically implement such a limitation through code, it can require complex customizations to your Shopify theme. This would involve checking the cart, restricting quantities based on your rules, and displaying warning messages — and it can be a bit tricky to maintain as your store evolves.

That said, I’d like to suggest trying out the MultiVariants-Bulk Order app. You can use this app to restrict the minimum order quantity for a particular product. Every time a customer tries to buy the product, they must meet the restrictions. The checkout button won’t work, and a warning message will appear on the product page if the quantity restriction isn’t met. This solution is much easier to set up and maintain compared to hard-coding, and it saves you time. You can check out this demo product for a better understanding.

Product Storefront

App Admin

Plus, the app offers a 5-day free trial, so you can explore the features and see if it fits your needs before committing. Feel free to give it a try, and let me know if you’d like any help with the setup!
Thank you.