---
title: Example - Applying a Buy X Get Y discount
related:
  - https://docs.kentico.com/k82/e-commerce-features/configuring-and-managing-your-store/discounts/working-with-buy-x-get-y-discounts.md
  - https://docs.kentico.com/k82/e-commerce-features/configuring-and-managing-your-store/discounts/working-with-buy-x-get-y-discounts/example-applying-a-buy-x-get-y-discount-1.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

The example demonstrates an application of a Buy X Get Y discount. The example uses the sample _E-commerce Site_.

We want every customer who has a coupon to get 50% discount on the cheapest book in customer's shopping cart for buying 3 of them. Customer gets as many discounts as many books they buy. The discount is time-limited, and is applied while shopping on the live site, and while editing an existing [order](https://docs.kentico.com/k82/e-commerce-features/configuring-and-managing-your-store/orders.md) in the administration interface. Coupons start with "BOOKS-" and there are 100 of them. Every coupon can be used once.

## Adding a Buy X Get Y discount

To add a Buy X Get Y discount, you have to follow several steps. Remember that the discount is saved after finishing all steps.

### Create a new Buy X Get Y discount and fill the general properties

1. Open **Buy X Get Y discount** application.
2. Click **New Buy X Get Y discount**.

   ![New Buy X Get Y discount button](https://docs.kentico.com/docsassets/k82/example-applying-a-buy-x-get-y-discount-2/new_buy_x_get_y_discount_button.png "New Buy X Get Y discount button")
3. Enter the following values to discount's general properties:

   - **Name**: Buy 3 books get 1 with 50 % off
   - **Enabled**: Yes (selected)

We created a new discount which we named.

### Fill in "Buy" Conditions and "Get" Conditions

1. In the **"Buy" Conditions** category, select _products in departments_ in the **Buy any** field.
2. Click **Select departments**.
3. Select _Books_, and click **Select**.

   ![Select departments](https://docs.kentico.com/docsassets/k82/example-applying-a-buy-x-get-y-discount-2/select_departments.png "Select departments")
4. Enter _2_ to **Minimum unit quantity** (2 are for the full price, the third is for the discounted price).
5. In the **"Get" Conditions** category, choose _cheapest unit for discounted amount_ in the **Get** field.
6. In **Discount**, choose _percentage_.
7. To **Amount**, enter _50_.

   ![Buy and Get conditions](https://docs.kentico.com/docsassets/k82/example-applying-a-buy-x-get-y-discount-2/buy_get_conditions.png "Buy and Get conditions")

You have now a discount that automatically adds 50% discount to the cheapest book in the shopping cart when customer buys three of them.

### Add other discount properties and save it

1. In **Coupons** tab, select **Customer has to redeem a coupon to get the discount**.
2. Set **Valid from** and **Valid to** in **Duration** category, e.g., _9/1/2014 12:00:00_ _AM_ and _12/31/2014 11:59:59 PM_.
3. Click **Save**.

The system saves the discount. The discount adds 50% discount to the cheapest book in the shopping cart when customer buys three of them between September and December 2014, and when customer types a coupon code. After you save the discount, you will be redirected to **Coupons** tab automatically.

### Generating coupons

1. On the **Coupons** tab, click **Generate coupon codes**.
2. Enter _100_ to **Quantity**.
3. Type _BOOKS-_ to **Coupon code prefix**.

   ![Generating coupons](https://docs.kentico.com/docsassets/k82/example-applying-a-buy-x-get-y-discount-2/generating_coupons.png "Generating coupons")
4. Click **Generate**.

The system now generates the coupon codes. We can [distribute them](https://docs.kentico.com/k82/e-commerce-features/configuring-and-managing-your-store/discounts/working-with-discount-coupons/use-order-coupons.md) among our customers.

## Applying the Buy X Get Y discount

### While shopping on the live site

1. View the live site.
2. Sign in as a customer (user).
3. Select **Books** in your on-line store main menu.
4. Click **Add to cart** at any book, e.g., _Bill Gates (E-book)_.
5. Enter _3_ to **Units** of the book and press **Enter** to refresh the shopping cart.
6. Type one of the coupon codes to **Discount coupon** and press **Apply**.

   ![](https://docs.kentico.com/docsassets/k82/example-applying-a-buy-x-get-y-discount-2/shopping_cart_with_discount.png)

You have now applied the discount. One of the three books in the shopping cart is with 50% discount. If you now click **Check out**, you can continue with the [checkout process](https://docs.kentico.com/k82/e-commerce-features/configuring-and-managing-your-store/checkout-process.md).

### While editing an existing order in the administration interface

1. Open the **Orders** application.
2. **Edit** () the selected order.
3. Switch to the **Items** tab.

   ![Shopping cart before discount](https://docs.kentico.com/docsassets/k82/example-applying-a-buy-x-get-y-discount-2/shopping_cart_before_discount.png "Shopping cart before discount")
4. Click **Add item**.
5. Select any book, e.g., _Bill Gates (E-book)_.
6. Enter _3_ to **Units** at the book.
7. Type one of the coupon codes to coupon code field and press **Enter**.

   ![Shopping cart with discount](https://docs.kentico.com/docsassets/k82/example-applying-a-buy-x-get-y-discount-2/shopping_cart_with_discount2.png "Shopping cart with discount")

The system added a 50% discount to one of the books. If you click **Next** or **OK** (depending on the type of the order), you can proceed with order editing.
