# 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="https://2582339638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagGARFBou99u1ioIn7vL%2Fuploads%2FYhgLgnHIsotxGpKcue0G%2Fbxgy.jpg?alt=media&#x26;token=8a78c153-20e8-4071-b693-ae5d4c8a8480" 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="https://2582339638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagGARFBou99u1ioIn7vL%2Fuploads%2FN05d3CodTFVf34dFPWcl%2Fbygy1.jpg?alt=media&#x26;token=c704fa54-4507-445a-9783-c1d1868199b4" 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="https://2582339638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagGARFBou99u1ioIn7vL%2Fuploads%2FQxtFkZnj603PZLOX5x7D%2Fbygy2.jpg?alt=media&#x26;token=d5016915-785f-4ecf-9e58-88ab82adb488" 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="https://2582339638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagGARFBou99u1ioIn7vL%2Fuploads%2FAE93tCw5omPwWUtgXowt%2Fsetting%20bxgy.jpg?alt=media&#x26;token=9288ee52-3f2c-4285-bcee-64d84a9a27b0" 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="https://2582339638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagGARFBou99u1ioIn7vL%2Fuploads%2Fn773jn2om536WrrnftD5%2Fdescription.jpg?alt=media&#x26;token=fb274c35-bf6c-412f-a243-b3681b2ca975" 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="https://2582339638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagGARFBou99u1ioIn7vL%2Fuploads%2FrD2dTY0OPAPPOYKl2BgP%2Fresultbxgy.jpg?alt=media&#x26;token=47f9e553-3cfc-4327-94bc-d7315b0d5f74" 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="https://2582339638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagGARFBou99u1ioIn7vL%2Fuploads%2FNeFc98pgv4XePQsPsuip%2Fcheapest.jpg?alt=media&#x26;token=2242f343-31e1-4450-8157-5ff85fc6c1e9" 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="https://2582339638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagGARFBou99u1ioIn7vL%2Fuploads%2F4iorZsh1CIlsXgh9sHZe%2Fcheapest%20cond.jpg?alt=media&#x26;token=47b6f776-c539-428f-8b18-71d9f40b01e7" 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="https://2582339638-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FagGARFBou99u1ioIn7vL%2Fuploads%2FQ1HE3QWaqOOqPSRQ6F8M%2Fcheapest%20result.jpg?alt=media&#x26;token=508cd411-02f9-437d-ac63-600f1b17cd5f" alt=""><figcaption></figcaption></figure>
