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

# Buy X get Y: discount items already in the cart

> Set separate purchase and discount scopes, qualifying quantities, repeat limits, and the requirement to add all items to the cart.

Buy X get Y discounts eligible items that are already in the cart. It does not add products automatically. Use [automatic gifts](https://discount.xrtotech.com/en/features/automatic-gifts.md) when the system should add a qualifying gift.

## Configuration

1. Add **买 X 件，另 Y 件减价** (Buy X items, discount another Y).
2. Enter **需购买件数 X** (Purchase quantity X) and **购物车中享优惠件数 Y** (Discounted quantity Y).
3. Choose purchase scope and discounted-item scope separately.
4. Set the discount type and value. Enter percentage `100` to make the discounted items free.
5. Optionally set **每单最多优惠组数（可选）** (Maximum groups per order).
6. Save and activate. Add both purchase and discounted items before testing checkout.

## Same-product example: buy one, get another half price

Use product P for both scopes, X = 1, Y = 1, and 50% off. Each P costs 60.

| Cart | Expected result without a group limit |
| - | - |
| 1 P | No offer; one unit cannot serve both roles |
| 2 P | One unit saves 30; total 90 |
| 3 P | Still only one complete offer group |
| 4 P | Two groups; two units each save 30 |

For overlapping scopes, the rule reserves purchase quantities before selecting discounted quantities. Among different prices, the current implementation discounts lower-priced eligible units first.

For fixed savings, check the amount per group rather than treating it as a final item price. See the [buy-one-get-one scenario](https://discount.xrtotech.com/en/scenarios/bogo.md).


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