> For the complete documentation index, see [llms.txt](https://docs.roadmap.so/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.roadmap.so/discounts-and-gwp/using-gwp-and-discounts/create-a-discount-code-with-rules.md).

# Create a discount code with rules

One code customers enter at checkout that discounts different collections and products by different amounts, using a rule for each.

Most discount codes do one thing. **Discount Code** does several at once: a single code that carries its own set of rules, each giving a different discount to a different part of your catalogue.

One code can take 20% off body care and 30% off face care, and the customer only ever types `BLACKFRIDAY`.

This is the discount to reach for when a promotion is not uniform. A sitewide sale with a few richer categories, a spend threshold that unlocks a better rate, or different treatment for subscription and one-time purchases all fit in one code.

### Create one

In **Discounts**, create a discount and choose **Discount Code** from **Select discount method**, described there as *One code customers enter at checkout, with its own discount rules*.

<figure><img src="https://393112916-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJ8asLD4FVCFagK40xEr4%2Fuploads%2FG4kpJLS5zuw9FJX8DDWX%2FScreenshot%202026-11-04%20at%202.00.06%E2%80%AFPM.png?alt=media&amp;token=915646ac-4733-4ce9-b972-a7eed138dc3d" alt="" width="375"><figcaption></figcaption></figure>

{% hint style="info" %}
Do not confuse it with **Discount Code Generator**, directly above it. The Generator creates and sends codes automatically from a trigger, such as a birthday. This one is a single code you create and publish yourself.
{% endhint %}

{% stepper %}
{% step %}

#### Name it and set the code

**Name** is for your reference only and is never shown to customers.

Under **Discount code**, type the **Code** customers will enter, or click **Generate** for a random one. Capital letters do not matter at checkout.
{% endstep %}

{% step %}

#### Add your first rule

Each rule is one discount applied to one set of products.

* **Applies to**, then pick the collections or products the rule covers. Use **Select collections** or **Browse**, and **+ Add products** to name individual products as well.
* **Discount type** and **Value**, for example `Percentage` and `20`.
* **Purchase type**, either one-time or subscription.
* **Minimum purchase requirements**, covered below.

<figure><img src="https://393112916-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJ8asLD4FVCFagK40xEr4%2Fuploads%2FGlINDPqjZJygByoqXXgc%2FScreenshot%202026-11-04%20at%202.21.56%E2%80%AFPM.png?alt=media&amp;token=b362005a-37d0-4f7a-97ab-249a4e613ed6" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Add the rest

Add a rule for each part of the catalogue that needs a different discount. Rules are numbered **Rule 1**, **Rule 2** and so on, and each has its own **Delete rule**.

There is no shared setting between rules. Each one carries its own targeting, discount, purchase type and minimum.

<figure><img src="https://393112916-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJ8asLD4FVCFagK40xEr4%2Fuploads%2F8PqP9dxtgZqHxvUhVP5E%2FScreenshot%202026-11-04%20at%202.23.21%E2%80%AFPM.png?alt=media&amp;token=771b57f9-6d25-4d35-931b-71be846b302c" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Set the code-level settings

Below the rules, four cards apply to the code as a whole rather than to any single rule:

* **Maximum discount uses**: limit the total number of uses, limit to one use per customer, or both.
* **Customer Eligibility**: all customers, logged-in only, customers with or without a given tag, members, or non-members.
* **Active Dates**: a start date and time, and optionally an end date and time.
* **Combinations**: which other discounts this code can stack with, across product, order and shipping discounts.

<figure><img src="https://393112916-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJ8asLD4FVCFagK40xEr4%2Fuploads%2F9YvHpf8a7qya2ZkL20tS%2FScreenshot%202026-11-04%20at%202.23.55%E2%80%AFPM.png?alt=media&amp;token=f442f3c9-2249-4a8e-b1d5-a7072f85e789" alt="" width="375"><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### How the rules resolve

One principle covers everything the code does:

{% hint style="info" %}
A rule applies only when its own conditions are met, meaning its minimum and its purchase type. Among the rules that do apply to a product, the **best single discount wins**.
{% endhint %}

Two consequences follow.

**A product in no rule gets no discount.** The code is not a sitewide percentage with exceptions. If you want everything covered, every product needs to fall inside a rule.

**Discounts never add together.** A product matching a 20% rule and a 30% rule pays 30%, not 50%. This is what makes layering safe: you can add a richer rule over the top of a broad one without having to carve anything out of the broad one.

That layering is the whole technique. A rule can cover the same collection as another rule, with a different minimum or a different purchase type, and the customer simply lands on whichever one they qualify for.

### Minimum purchase requirements

Each rule carries its own, so one rule can require a spend while another applies immediately.

| Option                                       | What it checks                              |
| -------------------------------------------- | ------------------------------------------- |
| **No minimum requirements**                  | The rule always applies to its products     |
| **Minimum purchase amount ($)**              | The cart's total amount                     |
| **Minimum quantity of all products in cart** | The total quantity of all units in the cart |

Both minimums look at the **whole cart**, not at the products the rule targets. A $250 minimum on your face-care rule is met by $250 of anything, not $250 of face care.

### One-time and subscription purchases

**Purchase type** lets one code treat the two differently. Point two rules at the same collection, set one to one-time purchase and the other to subscription, and each gets its own discount.

A subscription receives the discount on its **first order only**, not on every renewal.

So a cart holding the same product twice, once as a one-off and once on subscription, shows two different savings from the same code.

### What the customer sees

The code is entered at checkout like any other. Each discounted line shows the code name against the saving on that line, for example `BLACKFRIDAY (-$28.80)`, with the original price struck through, and the cart shows a total saving across everything.

Because each line names the code, a customer can see at a glance that one code produced several different amounts, which heads off the "my discount only partly applied" question.

<figure><img src="https://393112916-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FJ8asLD4FVCFagK40xEr4%2Fuploads%2FHdxcVIv2i5qZMTfUJMlN%2FScreenshot%202026-11-04%20at%202.09.17%E2%80%AFPM.png?alt=media&amp;token=59b73dbf-3dd9-45ce-9b01-023e4eb5c0f7" alt="" width="375"><figcaption></figcaption></figure>

### Some example combinations

Three promotions that are awkward to build any other way.

#### Different collections, different discounts

The straightforward case: one code, a richer rate on your higher-margin range.

* **Rule 1**: `Body` collection, Percentage `20`, one-time purchase, no minimum
* **Rule 2**: `Face` collection, Percentage `30`, one-time purchase, no minimum

A customer buying a Hair Serum at $96.00 and a Body Wash at $59.00 pays $67.20 and $47.20. The cart shows `BLACKFRIDAY (-$28.80)` on the serum and `BLACKFRIDAY (-$11.80)` on the wash, with a total saving of $40.60.

Anything outside both collections is charged at full price.

#### Spend more, save more

Two rules on the **same** collection, separated by a minimum, turn one code into a spend ladder.

* **Rule 1**: `Body` collection, Percentage `20`, no minimum
* **Rule 2**: `Body` collection, Percentage `30`, minimum purchase amount `$250`

Under $250 only the first rule qualifies, so the customer gets 20%. At $250 both qualify, and the better of the two wins, so the whole collection jumps to 30%.

You do not need to exclude anything from the first rule. It stays as the floor and the second rule overtakes it.

#### One-time and subscription priced differently

Use a better rate to push customers toward subscribing.

* **Rule 1**: `Body` collection, Percentage `20`, one-time purchase
* **Rule 2**: `Body` collection, Percentage `30`, subscription

A customer with the same Body Wash in their cart twice, once as a one-off and once on subscription, sees `BLACKFRIDAY (-$11.80)` on the one-off, taking $59.00 to $47.20, and `BLACKFRIDAY (-$15.93)` on the subscription line, taking $53.10 to $37.17. Total saving $27.73.

The subscription line is already discounted by its plan before the code applies, and the code's saving is on top of that for the first order.

### Related guides

* [Create a product discount](https://docs.roadmap.so/discounts-and-gwp/using-gwp-and-discounts/create-a-product-discount.md)
* [Create an order discount](https://docs.roadmap.so/discounts-and-gwp/using-gwp-and-discounts/create-an-order-discount.md)
* [Discount Code Generator](https://docs.roadmap.so/discounts-and-gwp/using-gwp-and-discounts/discount-code-generator.md)
* [Use tags for discount eligibility](https://docs.roadmap.so/discounts-and-gwp/using-gwp-and-discounts/use-tags-for-discount-eligibility.md)
* [Run multiple discounts & GWPs](https://docs.roadmap.so/discounts-and-gwp/using-gwp-and-discounts/run-multiple-discounts-and-gwps.md)
* [Discounts not applying correctly](https://docs.roadmap.so/discounts-and-gwp/troubleshooting/discounts-not-applying-correctly.md)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.roadmap.so/discounts-and-gwp/using-gwp-and-discounts/create-a-discount-code-with-rules.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
