feat(promotion): Allow buyget promotion to apply multiple times on cart (#13305)

what:

Introduces 2 new features to promotion module:

1. Introduce max quantity limit to promotion application - This will limit the application of the promotion based on the quantity of the target products in the cart. 
2. When applying buy get promotions, we will now apply buyget promotion until eligible items are exhausted or max quantity is reached. 

```
- Buy 2 t-shirts, Get 1 sweater
- Max quantity -> 1

This means you can add two t-shirts, and get 1 sweaters for free. However, if you add four t-shirts, you only get one sweater for free.
```

```
- Buy 2 t-shirts, Get 1 sweater
- Max quantity -> 3

This means you can add six t-shirts, and get three sweaters for free. However, if you add eight t-shirts, you only get three sweaters for free
```

```
- Buy 4 t-shirts, Get 2 sweater
- Max quantity -> 1

This should throw on creation, as the max quantity should as a minimum be the same value as the target rule quantity
```

RESOLVES SUP-2357 / https://github.com/medusajs/medusa/issues/13265
This commit is contained in:
Riqwan Thamir
2025-08-31 15:35:36 +02:00
committed by GitHub
parent f53f027ce6
commit ca038ff583
8 changed files with 1406 additions and 242 deletions

View File

@@ -2725,7 +2725,8 @@ medusaIntegrationTestRunner({
application_method: {
type: "fixed",
target_type: "items",
allocation: "across",
allocation: "each",
max_quantity: 1,
value: 100,
apply_to_quantity: 1,
buy_rules_min_quantity: 1,
@@ -2896,7 +2897,8 @@ medusaIntegrationTestRunner({
type: "fixed",
currency_code: "usd",
target_type: "items",
allocation: "across",
allocation: "each",
max_quantity: 1,
value: 100,
apply_to_quantity: 1,
buy_rules_min_quantity: 1,