---
title: "Buy x get y: discount another product in WooCommerce"
description: "Set up buy X get Y deals in WooCommerce with Pricepep: buying some products discounts others or makes them free, optionally added to the cart."
url: "https://pricepep.com/docs/buy-x-get-y/"
updated: "2026-12-02"
category: Product pricing
---

# Buy x get y: discount another product in WooCommerce

Buy x get y discounts products from a second list when the customer buys products from a first list: buy a laptop, get a mouse 50% off; buy 2 coffees, get a croissant free. Choose **Buy x get y** (once) or **Buy x get y - Repeating** (again for every full set), fill **Products - Buy** and **Products - Get**, and set the discount.

## How do I set up a Buy x get y rule?

1. Go to **WooCommerce > Pricepep > Product Pricing** and click **Add Rule**.
2. Set **Method** to **Buy x get y** or **Buy x get y - Repeating**.
3. Set **Quantities** for the bought products (see [quantities](/docs/quantities-and-ranges/)).
4. Under **Quantities & Discount**: **Buy - At Full Price** (how many to buy), **Get - Discounted** (how many get the discount), **Discount** and its value.
5. Under **Products - Buy**, choose what must be bought, for example **Product category** in list Laptops.
6. Under **Products - Get**, choose what gets the discount, for example **Product** in list "Wireless mouse".
7. Click **Save Changes**.

An empty **Products - Get** list means "Applies to all products."

## What does the customer pay?

Laptop $800, mouse $40, rule Buy 1, Get 1, Percentage discount 50:

| Cart | Result |
| --- | --- |
| 1 laptop | No change: there is no mouse to discount |
| 1 laptop + 1 mouse | Mouse $20 |
| 1 laptop + 2 mice | One mouse $20, one $40 |
| 2 laptops + 2 mice, Repeating | Both mice $20 |

When several products could get the discount, the cheapest are discounted first.

## Can I limit how often the deal repeats?

Yes, since 2.6.0. **Buy x get y - Repeating** has an optional **Maximum repetitions** field next to **Quantities**: the most times the deal applies in one cart, counted over all matching products (each set bought and discounted counts once). Leave it empty (placeholder "No limit") to repeat for every full set, as before. Example: buy a shirt, get a mug free, **Maximum repetitions** `3`: 10 shirts and 10 mugs give 3 free mugs instead of 10. Automatically added free products follow the same limit. The field takes whole numbers from 1.

## Can the free product be added to the cart automatically?

Yes, with conditions:

- **Automatically add free product to cart** is on (**WooCommerce > Pricepep > Settings**, **Product Pricing**).
- The method is **Buy x get y** or **Buy x get y - Repeating**.
- **Discount** is **Percentage discount** `100` or **Fixed price** `0`.
- **Products - Get** has exactly one row of type **Product** or **Product variation** with exactly one item selected (a simple product, or a variation with all attributes set).
- The customer adds at least the **Buy** quantity in one go, and the free product isn't in the cart yet.

Pricepep then adds the **Get** quantity (times the number of full sets for Repeating rules, at most **Maximum repetitions** times when the rule has one). Each time a product is added, only the first qualifying rule (from the top) adds its gift, and Pricepep doesn't change or remove the gift later. Details in the [free gift example](/docs/free-gift-with-purchase/) and [troubleshooting](/docs/free-product-not-added-automatically/).

## What if a product is in both lists?

That works. Pricepep uses the units that aren't in the Get list for the Buy part first, so "buy 2 shirts, get a third shirt or a tie free" still discounts correctly.

## Examples

- **Gift with a product:** Buy 1 of "Camera", Get 1 "Memory card", Percentage discount 100, with automatic adding.
- **Accessory deal:** Buy 1 from category Phones, Get 1 from category Cases, Percentage discount 30.
- **Lunch deal:** Buy 2 from Coffee, Get 1 from Pastries, Fixed price 1.00, Repeating.

For a complete worked example, see [Buy X get Y configuration](/docs/buy-x-get-y-configuration/).

## Frequently asked questions

### Can the Y product be added to the cart automatically?

Yes, for a free product: turn on Automatically add free product to cart on the Settings tab and give one specific product or variation at 100% off (or a fixed price of 0).

### What if the customer doesn't have the Y product in the cart?

The rule has nothing to discount. The customer adds it, or Pricepep adds a free Y product automatically when the setting is on and the rule qualifies.

### Which product gets the discount when several could?

The cheapest ones from Products - Get. There's no option to discount the most expensive instead.

### Can the gift depend on the cart total?

Not with a product pricing rule: Cart subtotal is only offered in cart discounts and checkout fees. Use a cart discount on the gift with a Cart subtotal condition; the customer adds the gift to the cart.

### How do I stop the deal from repeating?

Use Buy x get y instead of Buy x get y - Repeating, or set Maximum repetitions in the repeating rule (since 2.6.0).

## Related articles

- [Free gift with purchase (added to the cart automatically)](https://pricepep.com/docs/free-gift-with-purchase/)
- [Buy X get Y configuration: worked example](https://pricepep.com/docs/buy-x-get-y-configuration/)
- [Buy x get x: BOGO and 3 for 2 deals in WooCommerce](https://pricepep.com/docs/buy-x-get-x/)
- [Free product isn't added to the cart automatically](https://pricepep.com/docs/free-product-not-added-automatically/)

All articles in [Product pricing](https://pricepep.com/docs-category/product-pricing/)
