# Discount only the cheapest items on Shopify, like second item half price

To discount only the cheapest items in a cart, use [OneCode: Stackable Discounts](https://apps.shopify.com/rm-combo-discounts). On a **Product Discount**, click **Add quantity limit**, enter how many items get the discount, and keep **Apply discount to** on **Cheapest items first**. Only that many items are discounted, starting with the lowest-priced. Choose **Most expensive items first** to discount the priciest items instead. Add a **Group Quantity** condition to make it "buy 2, get the cheaper one half price".

## Example: 50% off the 2 cheapest shirts

The code SHIRTS50 takes 50% off the Shirts collection, limited to 2 items, cheapest first. A customer buys shirts at $40, $30 and $25:

- The $25 shirt is $12.50 and the $30 shirt is $15.
- The $40 shirt is full price.
- The customer pays $67.50 instead of $95, $27.50 saved.

![SHIRTS50 at checkout. The $40 Oxford shirt is full price, the $30 Linen shirt is $15, the $25 Cotton shirt is $12.50, the subtotal is $67.50, shipping is $8 and the total is USD $75.50.](/images/checkout-cheapest.png)

With **Most expensive items first**, the $40 and $30 shirts get 50% off instead. The customer pays $20 + $15 + $25 = $60, $35 saved.

The limit counts items, not products. Three of the same $25 shirt means two are $12.50 and one is $25.

![A 50% Product Discount on the Shirts collection with a Quantity Limit of 2 and Apply discount to set to Cheapest items first, with no Per-Discount Conditions](/images/quantity-limit.png)

## Set it up

1. In OneCode, click **Create discount**. Choose **Discount code** and enter a code, or choose **Automatic discount** and give it a **Title**.
2. Click **Add Discount Type**. Keep **Product Discount** and **Percentage**, and enter `50` in **Percentage**.
3. Set **Target** to **Specific Collections**, click **Browse** and pick Shirts.
4. Click **Add quantity limit**. Enter `2` in **Quantity Limit** and keep **Apply discount to** on **Cheapest items first**.
5. Click **Save discount**.

## Second item half price

For "buy 2, get the cheaper one 50% off", make two changes to the setup above:

- Enter `1` in **Quantity Limit**, cheapest first.
- Under **Per-Discount Conditions**, click **Add Condition**. Set **Field** to **Group Quantity**, **Operator** to **Greater than or equal to** and **Value** to `2`.

A customer with a $40 shirt and a $30 shirt pays $40 + $15 = $55. One shirt on its own is full price, because the group has only one item. **Group Quantity** counts only the Shirts items, so a hat in the same cart doesn't help reach 2.

Enter `100` instead of `50` and the cheapest item is free. That's buy one, get one free, covered step by step in the [BOGO guide](/guides/bogo.md).

![OneCode editor for code SOCKSBOGO: a 100% Product Discount on the Socks collection with Quantity Limit 1, Cheapest items first, and Group Quantity greater than or equal to 2](/images/editor-bogo.png)

## Add free shipping or a second discount

The same code can carry more than the cheapest-item discount. Add a **Shipping Discount** with **Free Shipping**, or a second **Product Discount** on another collection. To make shipping free only when the shirt discount applies, give the shipping discount the condition **Match Another Discount's Rules** and tick the shirt discount. A [Shopify discount code](https://help.shopify.com/en/manual/discounts/discount-methods/discount-codes) holds one kind of discount, so this would otherwise take two codes. See [a discount code with free shipping](/guides/discount-code-with-free-shipping.md).

## Things to check before you launch

- The quantity limit is per order, for this discount type only. With a limit of `1`, a customer who buys four shirts still gets one shirt half price. To discount two items from four, set **Quantity Limit** to `2` and **Group Quantity** to at least `4`.
- **Apply discount to** only appears when there's a choice: when **Target** is **All Products** or **Specific Collections**, or more than one specific product.
- Items left out by **Exclude sale items** or an **Item has subscription** condition don't count toward the limit or toward **Group Quantity**.
- For different percentages at 2, 3 and 4 items rather than a discount on the cheapest ones, see [buy more, save more](/guides/buy-more-save-more.md).

OneCode costs $9.90 USD every 30 days after a 7-day free trial, billed by Shopify. Install it from the [Shopify App Store](https://apps.shopify.com/rm-combo-discounts).
