# Buy X get Y

### How to buy 2 items and get another item as a gift.

In this tutorial, let's explore how to **buy 2 pairs of shoes get 1 cap for free.**

**Discussion steps:**

* Pricing settings
* Conditions
* Settings
* Application

To get started with this, we will go through **YayCommerce >> YayPricing >> Product Pricing >> Add Rule**. Then select the Buy X Get Y rule (the X+Y variation).

<figure><img src="/files/aWFIefdHC0ngZ7LscOVB" alt=""><figcaption><p>Campaign table</p></figcaption></figure>

**Pricing settings.**

After selecting the Buy X Get Y rule, then we go ahead to configuring the price settings, as seen in the screenshot below;

<figure><img src="/files/2o1hM874JGrGo5GV4zdK" alt=""><figcaption><p>Pricing rule settings</p></figcaption></figure>

1. The **"Buy Products"** field allows you to select the products that users must purchase in order to receive the discount.
2. The **"Get Products"** field allows you to specify the discounted item that the promotion will apply to.

**Conditions**

You can set conditions to further define when the rule should be applied and when it should not be applied to customers. In this example, we set the rule to apply only when the cart subtotal is greater than $100.

<figure><img src="/files/k1uZzsoUCOXnjoKAZG1h" alt=""><figcaption><p>Conditions tab</p></figcaption></figure>

**Settings**

The screenshot below shows the settings that can be applied to our rule. There are up to 5 checkboxes that can be activated to apply the four available settings in this case. However, we have only checked boxes (1) and (4) to display the offer description on the product page and enable the promotion schedule.

<figure><img src="/files/2H2TyxhuM19JQBUQG3FG" alt=""><figcaption><p>Settings</p></figcaption></figure>

**(2).**&#x57;hen this box is checked, the description set in box (1) will only be shown to customers when the specified conditions are met.

**(3).**&#x57;hen this box is checked, customers will see a tooltip text on the final price in the Cart page after the pricing rule is applied to their cart items.

**(5).** Check this box to limit the number of times a customer can enjoy the discount rule.

We saved the changes!

**Application**

Offer description in the **X** product page.

<figure><img src="/files/6o0vOmRIcfGNnatMUZjv" alt=""><figcaption></figcaption></figure>

**1** quantity of **Y** is automatically added to the cart after we've added **2 or more** quantities of **X** product.

<figure><img src="/files/FjY9aao9wZx7FgB6QkIr" alt=""><figcaption><p>Cart</p></figcaption></figure>

## How to buy 2 items and get the cheapest item free.<br>

**Pricing settings.** &#x20;

In this case, instead of selecting the "Free" option in the Item Get type, choose "Discount" and set it to a 100% discount, as shown in the reference below.

Additionally, don't forget to select the "Cheapest One" option to make the cheapest item free.

<figure><img src="/files/yRhoqmUap9l8Mxx75YAJ" alt=""><figcaption><p>Pricing rule settings</p></figcaption></figure>

**Conditions**

To restrict the promotion to users with a coupon code, you should set the condition accordingly as a reference below.

<figure><img src="/files/t6UeHgScPwvDjTlK8CFB" alt=""><figcaption><p>Conditions</p></figcaption></figure>

The item with the lower price will be given as a free gift on the cart page when the user applies the coupon.

<figure><img src="/files/Q8aRdOJDsesE39nXf0nS" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yaycommerce.com/yaypricing/use-cases/buy-x-get-y.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
