> ## Documentation Index
> Fetch the complete documentation index at: https://docs.partnero.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Adjust affiliate commission when a discount code is used

> Reduce or remove the commission automatically when the customer used a discount or coupon code

When a customer uses a discount code on a sale credited to a partner, you pay for the discount *and* the full
commission. Discount-based commissions reduce or remove the commission on those sales automatically. For example:

* Pay no commission on a customer's first order if they used a code.
* Pay half the normal commission on any discounted order.
* Pay less as the discount gets bigger — full commission for small discounts, none for big ones.

The adjustment is a **percentage of the commission**, not of the sale. If the normal commission is $8 and the rule
says pay 50%, the partner earns $4. Sales without a discount always earn the normal commission.

***

## Turn on discount-based commissions

1. Open your affiliate program, go to **Settings** under **Program**, scroll to **Commission** and click
   **Set up rules** (or **Manage rules**).
2. Open the **Discount-based** tab.
3. Turn on **Adjust commission when a discount code is used**.
4. Choose the [adjustment type](#adjustment-type) and [when to apply it](#when-to-apply-it). The parts are
   explained [below](#parts-of-a-rule).
5. Click **Save** to close the window, then **Update** to save the program settings.

***

## Parts of a rule

### Adjustment type

**Flat** — pay the same share of the normal commission whenever a code is used. Enter it under
**Commission to pay when a code is used**:

* `0` — pay no commission.
* `50` — pay half.
* `100` — pay the full commission.

**Tiered** — pay less as the customer's discount grows. Click **Add tier** for each range:
*If discount is between \[from]% and \[to]%, pay \[share]% of commission*.

| If discount is between | Pay |
| - | - |
| 0% and 10% | 100% of commission |
| 11% and 25% | 50% of commission |
| 26% and 100% | 0% of commission |

The discount is a percentage of the price before the discount. Both ends of a range are included, and if ranges
overlap, the first matching tier is used. If the discount doesn't fall into any range, the full commission is paid.

### When to apply it

| Option | The adjustment applies to |
| - | - |
| **On every transaction with a code** | Every discounted sale |
| **Only on the customer's first transaction** | The customer's first sale, if it used a code. Later sales earn the normal commission |
| **Only during the first period** | Discounted sales in the first set number of **days** or **months**, counted from **customer creation** or **partner creation**. After that, the normal commission is paid |

***

## Examples

All examples use a default commission of 20%.

| Goal | How to set it up | Result |
| - | - | - |
| No commission on the first order if the customer used a code | Flat, pay `0`, only on the customer's first transaction | The first discounted order pays nothing. Later orders pay 20% |
| Pay less as discounts grow | Tiered: 0–10% → 100%, 11–25% → 50%, 26–100% → 0%, on every transaction with a code | A $40 order with a 20% code: the normal commission is $8 (20% of the $32 paid), the 20% discount falls in the 50% tier, so the partner earns $4 |
| Reduced commission for new customers | Flat, pay `25`, only during the first 3 months from customer creation | Discounted orders in the customer's first 3 months pay a quarter of the commission. After that, the full 20% |

***

## Good to know

* A sale counts as discounted when it has a discount amount above 0 or a discount code. Full-price sales are never
  adjusted.
* **Tiered** needs the discount as a percentage, so it needs both the discount amount and the price before the
  discount. If only a code is known, the full commission is paid.
* The adjustment is applied after the commission rate is picked — default, custom, dynamic or product — and before
  currency conversion and the [maximum commission](https://docs.partnero.com/knowledge-base/commissions-rewards/guide-to-commission-set-up.md#adjust-commission-options).
  It doesn't change [goal-based rewards](https://docs.partnero.com/knowledge-base/commissions-rewards/create-goal-based-rewards.md).
* Turning the setting off restores normal commissions for new sales. Commissions already created don't change.

***

## Where discount data comes from

These integrations send the discount automatically:

| Integration | Discount read from |
| - | - |
| **Stripe** | The invoice or charge discount |
| **Paddle** | The transaction discount |
| **WooCommerce** | The order discount total |
| **Shopify** | The order discounts |

For other integrations, and when you record transactions with the API or the JavaScript library, send the discount
with the transaction.

### For developers: send discount data

Add these optional fields to the transaction:

| Field | Type | Description |
| - | - | - |
| `discount_amount` | number | The discount applied, in major currency units, for example `8.00` |
| `gross_amount` | number | The price before the discount. If omitted, it's `amount + discount_amount` |
| `discount_code` | string | The code the customer used |

`amount` stays the amount the customer actually paid, after the discount.

**REST API** — `POST /v1/transactions`. See [Create a transaction](https://docs.partnero.com/api-reference/transactions/create.md).

```json theme={"system"}
{
  "key": "order_12345",
  "amount": 32.00,
  "amount_units": "USD",
  "customer": { "key": "customer@example.com" },
  "discount_amount": 8.00,
  "gross_amount": 40.00,
  "discount_code": "SAVE20"
}
```

The same fields work for each item in the `transactions` array when you create transactions in bulk.

**JavaScript library**

```javascript theme={"system"}
partnero('track', 'transaction', {
  key: 'order_12345',
  amount: 32.00,           // amount paid, after the discount
  amount_units: 'USD',
  customer: { key: 'customer@example.com' },
  discount_amount: 8.00,
  gross_amount: 40.00,     // optional, defaults to amount + discount_amount
  discount_code: 'SAVE20'  // optional
});
```

If you don't send any discount fields, the sale isn't treated as discounted and no adjustment is applied.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.