=== Buy X Get Y Free BOGO Offers for WooCommerce ===
Contributors: hell0bunny
Donate link: https://profiles.wordpress.org/hell0bunny/
Tags: woocommerce, bogo, buy x get y, gift, promotions
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Create Buy X Get Y offers for WooCommerce. Gift, percent off, or a fixed price — one clear deal per product, no stacking.

== Description ==

**Buy X Get Y Free BOGO Offers for WooCommerce** lets you run promotions customers understand and store owners can trust.

Set up classic **buy 2 get 1** deals, gift another product, or sell the reward at a discount. Works on simple products and on each variation of a variable product.

No complicated builders. No two deals fighting on the same item. One product, one offer.

= Highlights =

* Buy X get Y of the **same product** or a **different gift**
* Reward as a **gift**, **percent off**, or **fixed price**
* Store-wide **global rules** with drag-and-drop priority
* Target **all products**, **specific products**, **categories**, or **tags**
* **Custom** or **Disabled** mode on each product and variation
* **One offer per product** — rules never stack
* **Schedules**, **user roles**, sale-item and coupon controls
* **Badges**, offer text, and a **gift highlight** on the product page
* Works with **Cart / Checkout blocks**, classic cart, and **HPOS**
* Shortcode `[bxgy_offer]` for templates

= Feature list =

**Deals**

* Same-product BOGO — buy X, get Y of that product
* Different-product gift — buy X, get Y of another product or variation
* Buy quantity and Get quantity set per rule, product, or variation

**Rewards**

* Gift — reward line at zero price
* Percent off — discount the reward by a percentage
* Fixed price — sell the reward at a set price

**Global rules**

* Add as many store-wide rules as you need
* Scope: all products, products, categories, or tags
* AJAX search pickers with a selected list
* Categories show Parent › Child labels
* Drag to reorder; numbered priority (1, 2, 3…)
* Expand / collapse each card; expand all / collapse all
* Enable or disable a rule without deleting it
* Optional rule title for admin use
* Higher rules win first when more than one could match

**Per product**

* Mode: Inherit global / Custom / Disabled
* Full custom deal on a simple product
* Option to let Custom mode overwrite global rules

**Per variation**

* Separate settings on each variation
* Mode: Inherit / Custom / Disabled
* Gift search includes products and variations
* Product-page offer text updates when a variation is selected

**Priority (conflict-free)**

* Each product gets at most one offer
* Disabled — excluded from every BOGO offer
* Custom (when overwrite is on) — only that item’s own deal
* Otherwise the first matching global rule wins (top to bottom)
* If a product is in two categories, the higher rule applies
* Recommended order: specific products → narrow categories/tags → broader → All products last

**Limits**

* Maximum applications per order (0 = unlimited)
* Exclude sale items
* Block other coupons with this BOGO
* Apply to all variations of a variable product
* Limit to selected user roles (empty = everyone)

**Schedule & messages**

* Start and end date/time
* Message before the offer starts
* Message while the offer is active
* Upcoming / active / ended status

**Storefront**

* Optional badges on shop and product pages
* Offer text on shop / category pages
* Offer text on single product pages
* Gift highlight card (image + name) for different-product deals
* Custom cart label on the reward line
* Customers can remove the reward from the cart
* Shortcode: `[bxgy_offer]` with `product_id`, `badge="yes|no"`, `text="yes|no"`

**Placeholders**

Use in messages and cart labels:

`{buy_qty}` `{get_qty}` `{reward}` `{title}` `{remaining}` `{start_date}` `{end_date}` `{product_name}` `{gift_name}`

**Admin**

* Dedicated **Buy X Get Y** menu
* Priority / conflict notice on the settings screen
* Searchable pickers for products, categories, and tags
* WooCommerce product search for gift fields
* Settings link on the Plugins screen

**Compatibility**

* WooCommerce 6.0+
* High-Performance Order Storage (HPOS)
* Cart and Checkout blocks
* Classic cart and mini-cart
* Simple and variable products

= In detail =

**1. Deal types**

Create **buy X get Y of the same product** (classic BOGO) or **buy X of one product, get Y of a gift**. Gift products can be simple items or a specific variation of a variable product. Buy and Get quantities are set on each global rule, simple product, or variation.

**2. Reward types**

The extra item can be a **gift** (zero price), **percent off**, or a **fixed price**. Percent and fixed rewards still add a clear reward line in the cart so the promotion is visible at checkout.

**3. Global rules**

The **Buy X Get Y** settings screen holds a repeater of rule cards. Each rule has a scope: all products, a product list, categories, or tags. Search pickers show what is selected and let you add or remove items. Drag the handle to change priority. Put specific product or category rules above a fallback “All products” rule. Turn a rule off without deleting it. Give it a title so the list stays readable.

**4. Product and variation settings**

On a simple product, choose Inherit, Custom, or Disabled. Custom lets you define the full deal on that product. On a variable product, each variation can inherit, use its own deal, or be excluded. The product page offer updates when the customer selects a variation.

**5. How the winning offer is chosen**

Offers never stack. **Disabled** wins first (no offer). **Custom** wins next when product overwrite is enabled (only that item’s deal). Otherwise global rules are checked from top to bottom and the first matching scope is used. If a product belongs to two categories with different rules, the higher rule in the list applies.

**6. Limits, schedule, and display**

Cap how many times an offer applies per order. Exclude sale items. Disallow other coupons. Restrict by user role. Set start and end times with messages for before and during the offer. Optionally show badges and offer text on shop and product pages. Different-product deals can show a gift card with image and name. The cart line can use a custom label with placeholders. Shoppers can remove the reward; changing the main quantity can offer it again.

**7. Shortcode**

`[bxgy_offer]` — optional attributes: `product_id`, `badge="yes|no"`, `text="yes|no"`.

Author: [hell0bunny](https://profiles.wordpress.org/hell0bunny/)

== Installation ==

1. Upload the plugin folder to `/wp-content/plugins/buy-x-get-y-free-bogo-offers-for-woocommerce/`
2. Activate **Buy X Get Y Free BOGO Offers for WooCommerce** (WooCommerce must be active)
3. Go to **Buy X Get Y** in the admin menu
4. Add a global rule, or open a product / variation and set a custom deal
5. Save and add the product to the cart to test

== Frequently Asked Questions ==

= Does this plugin need WooCommerce? =

Yes. It only works with WooCommerce.

= Can two offers apply to the same product at once? =

No. Each product gets one offer only, so customers are never confused by stacked deals.

= What if a product is in two categories with different rules? =

The **first matching global rule** (higher in the list) wins. Drag rules to change priority. Put specific category rules above broader ones.

= Can the reward be something other than a gift? =

Yes. Choose gift (zero price), percent off, or a fixed price for the reward item.

= Does it work with variable products? =

Yes. You can set BOGO on each variation (for example one color gets a gift, another does not). On the product page, the offer updates when a variation is selected.

= Can I gift a different product? =

Yes. Choose “different product” and pick the gift. Prefer a specific variation when the gift is variable.

= Can customers remove the reward item from the cart? =

Yes. They can remove it. If they change the main product quantity later, the offer can be offered again.

= How do I turn BOGO off for one product? =

Edit the product (or variation) → Buy X Get Y → set mode to **Disabled**.

= Will it work with Cart and Checkout blocks? =

Yes. It is built to work with WooCommerce Cart / Checkout blocks and classic pages.

== Screenshots ==

1. Global rules — store-wide Buy X Get Y offers, priority, and conflict-free notice
2. Product settings — custom deal on a simple product, including a gift product
3. Variation settings — a different offer on one variation
4. Product page — badge, offer text, and gift highlight
5. Cart — reward line with a custom BOGO label

== Changelog ==

= 1.0.0 =
* Initial release
* Same-product or different-product Buy X Get Y deals
* Rewards: gift, percent off, or fixed price
* Unlimited global rules (all products, products, categories, or tags)
* Drag-and-drop rule priority with numbered badges
* Expand / collapse rule cards
* Searchable product / category / tag pickers
* Custom deals on simple products and variations
* Conflict-free priority (one offer per product; product overwrite option)
* Schedules, role limits, sale-item and coupon controls
* Max applications per order
* Badges, shop/single offer text, and gift highlight
* Variation-aware offer display
* Custom cart labels with placeholders
* Removable reward line in the cart
* Shortcode `[bxgy_offer]`
* HPOS and Cart / Checkout block compatible

== Upgrade Notice ==

= 1.0.0 =
First public release of Buy X Get Y Free BOGO Offers for WooCommerce.
