Skip to content
Shopify tutorials

How to limit order quantity in Shopify (per product, per order & B2B)

Running a limited drop, selling a product with low stock, or tired of resellers buying 50 units of your bestseller? Then you probably need to limit order quantity in Shopify. By default, Shopify lets customers add as many units as you have in stock, so one buyer can empty your inventory in a single order.

In this tutorial, we will learn how to limit quantity in Shopify using four methods: the native add-to-cart limit, a maximum value on the theme quantity selector, a checkout rule app (for per-customer and per-product rules), and B2B quantity rules for wholesale catalogs. Previously, I published a tutorial on how to add products and variants in Shopify, so I assume your products are already set up.

shopify limit quantity methods

Which method should you use?

Here is a quick summary before we start:

  • Add-to-cart limit (built in, free): one maximum quantity per item for the whole store. Great for stopping bulk buying, but it is the same number for every product.
  • Theme quantity max (free, a little code): shows a different maximum on each product page. It improves the shopping experience but can be bypassed, so use it together with another method.
  • Checkout rule app (paid apps): enforces limits per product, per variant, per order or per customer at checkout. This is the method to use for “1 per customer” drops.
  • B2B quantity rules: minimum, maximum and increment per variant for wholesale catalogs.

Step 1: Turn on the Shopify add-to-cart limit

Since 2025, Shopify has a native setting that caps how many units of a single item can be added to the cart. It is turned on by default for most stores, but the default number is usually high (Shopify suggests a limit based on your order history, and stores with fewer than 250 orders get a default of 50). Let’s set our own number.

  1. From your Shopify admin, go to Settings > Checkout.
  2. Scroll down to Advanced preferences and click Add-to-cart limit.
  3. Tick Set a maximum quantity per item that can be added to a cart.
  4. Enter a whole number in the Limit field, for example 5. Shopify shows its recommended limit under the field.
  5. Click Done, then click Save.

shopify add to cart limit setting

A few things to know about this setting:

  • The limit applies to each variant separately. With a limit of 5, a customer can buy 5 red T-shirts and 5 blue T-shirts in the same order.
  • It limits the quantity per order, not per customer. A buyer can place a second order.
  • It does not apply to POS carts, draft orders, B2B carts with quantity rules, products with Track quantity turned off, and products set to Continue selling when out of stock.

You can read the official notes in Shopify’s help article about the add-to-cart limit.

Step 2: Set a maximum quantity on the product page (theme)

The add-to-cart limit is store-wide. If you want a different maximum for each product (for example 2 for a limited sneaker and 10 for socks), you can store the number in a product metafield and use it on the quantity selector. I used the same metafield idea when I showed how to add a size chart in Shopify.

Create the metafield

  1. Go to Settings > Metafields and metaobjects > Products and click Add definition.
  2. Name it Max quantity, set the namespace and key to custom.max_quantity, choose the type Integer and click Save.
  3. Open a product, scroll to Metafields and enter the maximum, for example 2.

Use the metafield in the quantity selector

Go to Online Store > Themes, click … next to your theme and choose Duplicate first (always edit a copy). Then click … > Edit code on the copy and find the quantity input on the product page. In Dawn and most Online Store 2.0 themes, it is in sections/main-product.liquid (search for name="quantity"). Add a max attribute that reads the metafield:

{%- assign max_qty = product.metafields.custom.max_quantity.value -%}
<input
  class="quantity__input"
  type="number"
  name="quantity"
  value="1"
  min="1"
  {% if max_qty %}max="{{ max_qty }}"{% endif %}
>
{% if max_qty %}
  <p class="quantity-limit-note">Limit {{ max_qty }} per order</p>
{% endif %}

Keep any other attributes your theme already has on the input (like id, form or data- attributes) and only add the max part. Save and preview the product: the “+” button now stops at your maximum.

Important: this is only a front-end limit. A customer can still add the product again from the product page or change the quantity in the cart. Combine it with the add-to-cart limit (Step 1) or a checkout rule (Step 3) for real enforcement.

Step 3: Limit quantity per product or per customer with a checkout rule

If you need “1 per customer”, a minimum order quantity, or different limits per collection, the reliable way is a checkout rule. Checkout rules are built with Shopify’s cart and checkout validation functions, which block checkout when the cart breaks a rule, so the limit can’t be bypassed from the cart page. You need an app to create them.

  1. Open the Shopify App Store and search for order limits or checkout rules. Pick an app that lists “cart and checkout validation” and supports the rule you need (per product, per customer, per order total…).
  2. Install the app and create your rule inside the app, for example Max 2 units per customer for the “Limited drop” collection.
  3. Go to Settings > Checkout, scroll to Checkout rules and click Add rule.
  4. Select the rule from the app, then save it and turn it on.

shopify checkout rules add rule

When a customer tries to check out with too many units, Shopify shows the app’s error message and the order can’t be completed until the quantity is reduced. Per-customer limits usually need the customer to log in, so choose an app that explains how it identifies returning buyers.

Step 4: Set quantity rules for B2B catalogs

If you sell wholesale with Shopify B2B, you can set a minimum, maximum and increment for each variant in a catalog:

  1. Go to Markets > Catalogs and open your B2B catalog.
  2. In Products and pricing, click Manage > Manage products and pricing.
  3. In the Quantity rules column of a variant, click + Add.
  4. Fill in Increment, Minimum and Maximum, then click Done and Save.

shopify b2b quantity rules

The maximum limits how many units of that variant a B2B customer can buy in one order. You can also import quantity rules with a CSV file if you have many products. See Shopify’s guide to quantity rules and volume pricing.

Step 5: Test your quantity limit

Never trust a limit until you have tried to break it. Open your store in a private browser window and:

  • Try to increase the quantity past the maximum on the product page.
  • Add the product, go back and add it again, then change the quantity in the cart.
  • Go to checkout and confirm you see the limit message.

To go all the way to the thank-you page without paying, place a test order in Shopify with the Bogus gateway or Shopify Payments test mode.

Common errors

The add-to-cart limit doesn’t work for a product

Check the product’s inventory settings. The limit is skipped when Track quantity is off or when Continue selling when out of stock is on.

Customers can still buy more than the theme maximum

That’s expected: the max attribute only controls the input on the product page. Use the add-to-cart limit or a checkout rule to enforce it.

“Add rule” is not available in Checkout rules

You haven’t installed an app that provides a checkout validation function yet, or the app’s rule hasn’t been created. Some apps also require a specific Shopify plan, so check the app listing before installing.

Wrapping up

That’s how you limit order quantity in Shopify. For most stores, I recommend setting the native add-to-cart limit first, adding a per-product maximum on the theme for a clearer shopping experience, and using a checkout rule app only when you need “per customer” limits for limited drops.

If you have any questions about limiting quantity in Shopify, or a rule that doesn’t work as expected, leave a comment below and I’ll help you out!

Written by

Hung Tran

Hung Tran is the main editor of magentip.com, he loves to write about everything related to Magento 2