# Max Quantity

Maximum Quantity allows you to **limit how many items receive a discount** in a given discount configuration. It is especially useful when you want to prevent discount abuse or offer selective rewards (like “only one item gets the discount”).

{% embed url="<https://youtu.be/vmaMU-Tfcaw>" %}

***

### 🧩 Where to Find It

**Maximum Quantity** is available only in the **Unified Discount v2**. This is the latest version of the DollarLabs discount engine.

> ⚠️ Not available for **Order** or **Shipping** discounts – only for **Product** discounts.

#### To enable it:

1. Go to your **Unified Discount v2** setup.
2. Inside a **Product discount**, click on the **Settings icon** ⚙️.
3. Enable **Max Quantity** → this enables **Maximum Quantity** at the **discount level**.

<figure><img src="https://2844543096-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcVBfwy7Yj4tU8TsxkHEr%2Fuploads%2Fz6T4Od7l4geP2yqfQXj8%2Fimage.png?alt=media&#x26;token=580c69c1-0b6e-44fa-821c-a0f941e31cc7" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
You can also configure **Maximum Quantity at the Function Level**, limiting the total discount across all configs within that function.
{% endhint %}

***

### 🧪 How Does It Work?

Let’s break it down with an example:

Suppose you set a rule like:

> “Give 20% off to any one item in the Hydrogen Collection.”

If a customer adds **2 Hydrogen items**, **only one will receive the discount**.

What actually happens:

* The cart items are **split** into different line items.
* One line item (e.g., Hydrogen, quantity 1) gets **20% off**.
* The remaining item(s) **do not** get a discount.

This mechanism gives you **granular control** over how discounts are applied, especially useful for BOGO-style promotions.

***

### 🎛️ Modes of Maximum Quantity

You can configure **Maximum Quantity** in two ways:

#### 1. ✅ **Fixed Mode**

* Define a strict quantity limit (e.g., “Only 1 item gets 10% off”).
* Great for simple “Buy X, Get Y” offers.

#### 2. 🔄 **Dynamic Mode**

* Allows **scaling the discount** based on cart contents.
* Prevents abuse by setting a **ceiling** (upper limit).

**Example Use Case:**

> "For every 2 items bought from *Hydrogen Collection*, give 1 item from *Oxygen Collection* a 10% discount."

So:

* If a user buys **10 Hydrogen items**, then
* **5 Oxygen items** can receive a 10% discount (based on the divisor rule: `10 ÷ 2 = 5`).

{% hint style="success" %}
Max Quantity can also be set to negative to enable use cases like "Every item except the first gets the discount" - ie it works in the opposite manner to the positive values.
{% endhint %}

***

### ⚙️ Configuring Dynamic Scaling

When using **Dynamic Maximum Quantity**, you can:

#### 🧮 Choose **Cart Group** Logic:

Use these variables to determine scaling:

* Line Count
* Quantity Sum
* Unique product count
* Unique variant count
* All – applies the rule universally

#### 🔢 Apply Mathematical Operators:

* `add`, `subtract`, `multiply`, `divide` (quotient only), `modulo` (remainder only)
* `none` – applies rule unconditionally when the cart group is present

{% hint style="info" %}
In both Modulo and Division operators the quotient / remainder is floored to ensure that it's always an integer and never decimal
{% endhint %}

***

### 💬 Need Help?

If you’re unsure how to configure this or need help creating specific rules, our team is just a message away.

📩 Chat with us or email us at <support@dollarlabs.io> anytime — we’re happy to help.
