# Advanced promotions guide - part 2 - Magento built-in "Buy X get Y" promotion

In this series, we cover Magento price cart rules in depth. This is the second part of our promo series, and it will deal with the **Magento buy x get y promotion**.

(If you are interested in the other three core promotion types—percentage, fixed, and fixed discount for the whole cart—please refer to Part 1 of this series.)

## Part 2 - buy x get y free in Magento

In this part, we will look closely at the **buy x get y free** promotion. Examples:

- buy one get one free
- buy x get y free
- magento 3 for 2 promotion

### How do you configure a **buy one get one free** in Magento?

As we will see, Magento's out-of-the-box cart rules only allow the **buy x get y free promotion** for the **same product**. That is, if the customer adds X quantity of a specific product, he gets the extra Y quantity **of the same product** for free.

That is, for the following promotion examples, **you won't be able** to use the Magento buy x get y price cart rule:

- 1+1 on all t-shirts - where one t-shirt has an SKU TSHIRT1, and the other (free) t-shirt has an SKU TSHIRT2
- Buy a t-shirt, get an accessory free

To create such promotions, you will need to use an **advanced promo extension for Magento**.

* If you are considering this option, we recommend you look into the Mexbs Additional Promotions extension, which contains more than 22 advanced promo types.

### Buy X get Y free - same product

Let's go back to the out-of-the-box **Magento buy one get one free promotion**. Let’s take a look at a few examples.

#### “1+1 on all t-shirts”

This promotion will allow you to add another quantity of (the same) t-shirt for free.

#### Promo configuration

To configure it, choose “Buy X get Y (discount amount is Y)” -

Set the value 1 in “Discount Amount” and 1 in “Discount Qty Step (Buy X).”

In order for the cart rule to apply the discount **only** on the t-shirt category, we need to add a condition in the “Actions” tab.

To do that, go to the “Actions” tab.

Scroll down to the *“Apply the rule only to cart items matching the following conditions (leave blank for all items)”* field, and then choose the categories of t-shirts. In our example, we choose two categories—women’s t-shirts and Men’s t-shirts—and use the “Category is one of” condition.

Save the promo.

#### Promo results

##### Adding two of the same products

In the cart and the mini-cart, we can see that if we add two of the same t-shirts, **we get one of them for free**.

* Out-of-the-box, Magento doesn’t display discounts in the mini cart (marked by the blue ellipse).

* If you want this feature on your site, we suggest you look into our advanced promotions plugin for Magento 2, which contains this and many other valuable features.

##### Adding four of the same products

As expected, if we add four of the same t-shirts, we will get two free.

##### Adding two different products

Let's see what happens when we add two different t-shirts to the cart.

As expected, no discount has been applied. As we mentioned before, the out-of-the-box **Magento buy x get y shopping cart price rule** only allows discounting the extra quantity of the same exact item.

If we change the quantity of each item to two, they will get discounted.

* Out-of-the-box, Magento doesn’t display discounts in the mini cart (marked by the blue ellipse).

* If you want this feature on your site, we suggest you look into our special promotions plugin for Magento 2, which contains this and many other valuable features.

#### Limiting the number of discounted products

If we want to limit the discount quantity per product, we need to fill in the “Maximum Qty Discount is Applied To” field.

Pay attention to the fact that the field should contain a value according to the following formula -

Formula = (X+Y) * (M/Y)

X = number of items purchased

Y = number of free items

M = Maximum number of free items allowed

(source: Adobe Commerce documentation - https://experienceleague.adobe.com/en/docs/commerce-admin/marketing/promotions/cart-rules/price-rules-cart-buy-this-get-that)

That is, in the example above, if we want to limit the discounted quantity to two, our values will be:

X = 1

Y = 1

M = 2

So the formula will yield (1+1)*(2/1) = 4

So if we fill 4 in “Maximum Qty Discount is Applied To,” we can get a maximum quantity of two for free of each matching product.

#### 3 for 2 promotion

**3 for 2 promotion** is the same as **buy two get one free**. Therefore, we can configure it similarly to how we did before.

The only difference is that we fill in 2 in the “Discount Qty Step (Buy X).” The field “Discount Amount” remains 1.

If we want to set the maximum discount quantity to be two, we will go by the previous formula:

Formula = (X+Y) * (M/Y)

Where

X = number of items purchased

Y = number of free items

M = Maximum number of free items allowed

X = 2, Y = 1, M = 2

So the formula will yield (2+1)*(2/1) = 6

So if we fill 6 in “Maximum Qty Discount is Applied To,” we can get a maximum quantity of two for free of each matching product.

#### Promo results

We can see that if we add three t-shirts, we get one of them for free. That is, we got 3 for 2.

* Out-of-the-box, Magento doesn’t display discounts in the mini cart (marked by the blue ellipse).

* If you want this feature on your site, we suggest you look into our advanced promotions plugin for Magento 2, which contains this and many other helpful features.

##### FAQ: Magento buy x get y free not working - what can be the issue?

Two possible issues could happen:

- You added different products to the cart and expect to get free items calculated based on the total quantity of all matching items. In this case, the Magento buy x, get y promotion won’t work because it only applies the discount on the
**quantity of the same items**. - You set the wrong value in the “Maximum Qty Discount is Applied To” field. Remember to use the formula we mentioned above. Otherwise, the discount might not apply (if the number is too low).

### Part 2 wrap-up

In this part, we learned how to set up the **Magento buy x get y promotion**. We saw that there is a big limitation in that it only allows to discount the quantity of the same item.

In the next section, we will see how to create a buy x get y free promotion for **different products** using the Mexbs Additional Promotions extension.