5 Best WordPress Hosting Services for 2025? Best Wordpress Hosting

Shopify Limit Quantity per Customer: How to Set Easy in 5 minutes

  • Dec 03, 2025
  • Hin Hin
  • 8,792 view(s)

Many merchants search for ways to apply a Shopify limit quantity per customer so they can restrict how many units a shopper can purchase for a specific product (for example, no more than 2–3 items per order). This helps protect inventory, prevent bulk buying, and maintain control over promotional campaigns. Shopify does not offer this feature natively — but you can still add a maximum quantity rule with just one line of code, no app required, and without slowing down your theme.

In this guide on Orichi, you’ll learn step-by-step how to set a maximum order quantity directly in the Shopify cart

shopify limit quantity per customer

Table of Contents

Why You Should Set a Maximum Order Quantity in Shopify

Setting a maximum order quantity is one of the most effective ways to maintain control over your store’s inventory and customer buying behavior. By limiting how many units a shopper can purchase in a single order, you can:

  • Prevent stockouts caused by customers buying too many units at once
  • Protect your inventory during peak sales, product drops, or flash deals
  • Reduce reseller or bot-like behavior, which is common during limited-edition launches
  • Maintain fair purchasing opportunities so more customers can access the product
  • Control the performance of promotional campaigns by ensuring discounts aren’t exploited

However, Shopify does not provide a built-in maximum quantity limit, meaning you cannot enforce these rules natively on the product page or cart. To implement maximum purchase restrictions reliably, you’ll need to use custom code or a specialized limit-control app like OC Quantity Breaks & Order Limit, which can apply these rules automatically across products, variants, or collections.

How to Set Maximum Order Quantity Using Madgic Order Limits Quantity (No Code Required)

For merchants who need advanced control — not just one universal limit — the Madgic Order Limits Quantity app offers a far more flexible way to manage maximum purchase rules. You can set limits per product, per collection, per variant, or even based on customer tags. Madgic supports every quantity and checkout validation rule that Shopify doesn’t offer by default, and you can configure everything without editing theme code.

When Should You Use an App Instead of Code?

Choose Madgic Order Limits Quantity when your store requires more precise control, such as assigning different minimum or maximum limits per product, applying rules based on quantity steps, or restricting purchases by customer tags like wholesale or retail groups.

It supports protective limits during flash sales, total order caps, and collection-specific restrictions such as allowing only one or two sale items per customer.

You can also set variant-level rules, enforce storewide checkout validation, create tailored error messages, and apply conditions consistently across product pages, collections, the cart, and checkout. When your workflows demand advanced order-control logic, the app is the right solution, and you can also review the code method provided below.

How to Add Maximum Order Quantity Using the Madgic App

TRY NOW

Step 1 — Install the App

Go to Shopify App Store: Madgic Order Limits Quantity

→ Click Add app → Install and approve the required permissions (permissions are minimal and relate only to order-limit validations).

Step 2 — Open the “Order Limits” / Rule Builder Module

In the app dashboard, you will see Madgic’s rule-building interface, where you can set:

  • Minimum Order Quantity (MOQ)
  • Maximum Order Quantity
  • Multiples (packs of 2, 3, 5…)
  • Collection limits
  • Variant limits
  • Checkout rules

To create a max-quantity rule, select: Maximum Quantity

Step 3 — Create a New Limit Rule

Click Create New Rule.

You will see options such as:

  • Maximum Quantity per Product
  • Minimum Quantity
  • Multiples (x2, x3, x5…)
  • Order-level quantity limit
  • Limit per Variant
  • Limit per Collection

Select: Maximum Quantity.

Step 4 — Set the Maximum Quantity

Enter the quantity limit you want:

  • Max = 2 → customers can only buy 2
  • Max = 3 / 5 / 10 → use any number you prefer

Madgic supports limit targeting by:

  • Variant (SKU)
  • Product
  • Collection
  • Entire cart

Examples:

  • Collection “Sale” → Max 1 item
  • Product “iPhone Case” → Max 3 per order
  • Variant Red / Size Large → Max 2

Step 5 — Choose Who the Rule Applies To

You can assign the rule to:

  • All customers
  • Logged-in customers only
  • Guests only
  • Customers with specific tags
  • Wholesale buyers
  • Subscribers / membership customers

This level of targeting is not possible with basic Shopify code.

Step 6 — Customize the Error Message

You can display a custom message when customers exceed the limit.

Example (EN):

“You can only purchase up to 2 units of this product.”

You can style the message based on tone, language, or situation (flash sale, members-only, etc.).

Step 7 — Save & Test the Rule

Click Save, return to your storefront, and try increasing the quantity on the Product page or Cart page.

Madgic will:

  • Automatically block quantity beyond the limit
  • Display your custom error message
  • Prevent checkout if the customer attempts to bypass the rule

No theme editing required.

No code conflicts.

Fully built for Shopify.

How to Add a Maximum Quantity Rule in Shopify By CODE

Step 1 — Open the Theme Code Editor

In your Shopify Admin:

Online Store → Themes → … (More) → Edit code

Step 2 — Locate the Cart File

In the file search bar, type:

  • main-cart-items

Open main-cart-items.liquid (or the equivalent file depending on your theme).

Step 3 — Find the Quantity Input Section

Press:

  • CTRL + F (Windows)
  • CMD + F (Mac)

Search for:

  • data-cart-quantity

This is where Shopify handles the cart quantity logic.

Step 4 — Remove the Existing Conditional Line

Right below the data-min and data-max attributes, you will see a line similar to:

  • {% if … %}

→ Delete that entire line.

Step 5 — Add the 1-Line Code for Maximum Quantity

Paste the exact line of code provided in the tutorial into the area you just removed.

Copy this:

  • data-max=”{{ item.variant.quantity_rule.max }}”

Step 6 — Set Your Maximum Quantity

Find:

max=”…”

→ Remove the content inside the quotation marks (keep the quotes).

→ Type the maximum quantity you want.

Examples:

  • 2 → only allow max 2
  • 3 → allow max 3
  • 5 → allow max 5

Step 7 — Remove the Closing {% endif %}

Shopify will highlight the line in red.

→ Delete the {% endif %} line.

Step 8 — Save and Test

Click Save, open your Cart page, then refresh.

Now you will see:

  • The quantity “increase” button stops working after hitting the limit
  • A “stop” icon may appear, or Shopify will disable the button

Important Notes

  • This solution only applies to limits on the Cart page, not the Product page.
  • If you want different limits per variant, per collection, or per customer type → you need an app.

Why Orichi App Is Better for Multi-Rule Stores

Here are the features that manual code cannot handle, but the Orichi app can:

FeatureManual CodeMadgic App
Limit per product✔️✔️
Limit per collection✔️
Limit per customer tag / subscribers✔️
Limit for entire order✔️
Multiple rulesVery difficult✔️
Checkout validation rules✔️
Custom error messages✔️
No code required✔️

Recommended for you:

Editor’s Pick