> For the complete documentation index, see [llms.txt](https://help.dollarlabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.dollarlabs.io/dollarlabs-ultimate-discounts/unified-discount-engine-v2/limits/max-quantity.md).

# 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="/files/3sPPzEwGG4R4B2E0RRpl" 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.dollarlabs.io/dollarlabs-ultimate-discounts/unified-discount-engine-v2/limits/max-quantity.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
