=== Groups Discount for WooCommerce ===
Contributors: eggemplo
Donate link: https://growthplugins.com
Tags: wholesale, b2b, dynamic-pricing, user-roles, wholesale-pricing
Requires at least: 5.6
Requires PHP: 7.2
Tested up to: 7.0
Stable tag: 5.0.0
WC requires at least: 5.0
WC tested up to: 10.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Automatic per-audience pricing for WooCommerce — discounts driven by WordPress roles, the Groups plugin and other membership sources.

== Description ==

Groups Discount for WooCommerce applies personalized pricing to your customers based on the user roles or groups they belong to. Logged-in users see their own discounted prices automatically, without coupons or manual intervention.

Version 5.0.0 introduces an extensible **audience** model: discounts can now be driven by WordPress roles out of the box, by the free Groups plugin, or by paid add-ons that connect to other membership systems.

= Key features =

* **Two discount methods** — percentage (e.g. 0.1 = 10% off) or fixed amount (e.g. 5 = 5 off in your store currency).
* **Choose the base price** — apply the discount to the regular price or to the sale price when it exists.
* **Per-category overrides** — set a different discount for specific product categories. Configurable per audience, with a tie-break policy when a product belongs to several categories.
* **Multi-audience conflict resolution** — when a customer belongs to several roles or groups, pick the higher discount, the lower one, or follow a deterministic order.
* **Optional dual price display** — show original and discounted prices side by side, with a customizable label.
* **Built-in audience sources** — WordPress Roles (always available) and the free Groups plugin (when installed).
* **Pluggable architecture** — any third-party plugin can register itself as an audience source through the `wgd_audience_providers` filter.
* **Compatible with simple and variable products**, including variations.
* **WooCommerce HPOS and Cart/Checkout Blocks** compatibility declared.
* **Translation ready** (Spanish bundled).

= Typical use cases =

* Wholesale and B2B stores that need automatic discounts for verified buyers.
* Membership sites that reward subscribers with member-only prices.
* VIP and loyalty programs that grant escalating discounts.
* Employee, student or staff stores.

= Audience sources =

Two providers ship with the free plugin:

* **WordPress Roles** — always available. Assign a discount to any role (Customer, Subscriber, custom roles, etc.).
* **Groups** — appears automatically when the free [Groups](https://wordpress.org/plugins/groups/) plugin is active.

Additional integrations are available as paid add-ons (Paid Memberships Pro, MemberPress, WooCommerce Memberships, Restrict Content Pro, Ultimate Member). They show up in the **Add-ons** tab inside the plugin once the core is installed.

= Requirements =

* WooCommerce (required).
* Optionally, the [Groups](https://wordpress.org/plugins/groups/) plugin if you want to use Groups as an audience source.

= Documentation =

Full documentation and add-on catalog: [growthplugins.com](https://growthplugins.com/plugin/groups-discount-for-woocommerce/).

== Installation ==

= Automatic installation =

1. In your WordPress admin, go to **Plugins → Add New**.
2. Search for "Groups Discount for WooCommerce".
3. Click **Install Now** and then **Activate**.
4. Go to **WooCommerce → Groups Discount** to configure the plugin.

= Manual installation =

1. Download the plugin ZIP file.
2. Go to **Plugins → Add New → Upload Plugin** in your WordPress admin.
3. Upload the ZIP and click **Install Now**, then **Activate Plugin**.
4. Go to **WooCommerce → Groups Discount** to configure the plugin.

= Initial setup =

1. In **WooCommerce → Groups Discount → Method**, choose the discount method (rate or amount), the base price (regular or sale), and how to resolve users in multiple audiences.
2. In the **Audiences** tab, set a discount value for any WordPress role and, if Groups is active, for any group.
3. Optionally, in the **Categories** tab, override the discount on specific product categories per audience.
4. Save. Logged-in users matching an audience will now see their personalized prices.

For rate discounts, `0.1` means 10% off, `0.25` means 25% off, etc. For fixed amounts, enter the discount in your store currency.

== Frequently Asked Questions ==

= Is the Groups plugin required? =

No. Starting with version 5.0.0, only WooCommerce is required. WordPress Roles are always available as an audience source. Groups becomes available as an audience source when its free plugin is active.

= What discount methods are available? =

Two:

* **Rate (percentage)** — `0.1` is 10% off, `0.25` is 25% off, etc.
* **Fixed amount** — `5` is a 5-unit discount in your store currency.

The method is global to the plugin and applies to every audience.

= Can I apply discounts on top of sale prices? =

Yes. In **Method**, choose whether the discount is computed from the regular price or from the sale price (when present).

= What happens if a user belongs to several audiences? =

The plugin picks one according to the policy you choose in **Method → If in several groups**:

* **Higher discount** — the customer gets the best price.
* **Lower discount** — the customer gets the smallest discount.
* **Higher group ID** / **Lower group ID** — deterministic ordering.

= Can I set different discounts per product category? =

Yes. The **Categories** tab lets you override the audience default discount on specific categories. A separate policy controls what happens when a product belongs to several configured categories.

= Does it support variable products? =

Yes, including all variations.

= Will customers see the original price? =

Optionally. Enable **Display original prices** in **Method** to show the original and the discounted price together. The label is customizable.

= Does it slow my store down? =

Discount computations are memoized per request so the cost is paid once per product render. The plugin declares compatibility with WooCommerce HPOS and Cart/Checkout Blocks.

= Is it translation ready? =

Yes. Spanish (es_ES) is bundled.

= How do I extend it with my own audience source? =

Implement the `WGD_Audience_Provider` interface and register your provider through the `wgd_audience_providers` filter. Full developer documentation is on our website.

== Screenshots ==

1. **Method Settings** — choose between percentage or fixed amount discounts, select the base price and configure how multiple audiences and categories are resolved.
2. **Audience Configuration** — set a discount for any WordPress role or Groups group, organized by provider.
3. **Customer View** — logged-in users automatically see their own price; optionally with the original price shown alongside.

== Upgrade Notice ==

= 5.0.0 =
Major release: extensible audience system, WordPress Roles support, per-category discounts, modernized admin, HPOS compatibility. Existing Groups configurations are migrated automatically — no manual action required.

== Changelog ==

= 5.0.0 =

Major release.

* **Extensible audience architecture.** Discounts can now be driven by any user-segmentation source through the new `WGD_Audience_Provider` interface and the `wgd_audience_providers` filter.
* **WordPress Roles support out of the box.** Assign discounts to any role; always available regardless of which membership plugins are installed.
* **Groups plugin is no longer required.** WooCommerce remains the only mandatory dependency. Groups is now an optional audience source.
* **Per-category discounts per audience.** New "Categories" matrix in the admin, with a configurable tie-break policy when a product belongs to several categories.
* **Add-ons tab.** Surfaces optional paid providers (Paid Memberships Pro, MemberPress, WooCommerce Memberships, Restrict Content Pro, Ultimate Member) and marks installed ones as active.
* **HPOS and Cart/Checkout Blocks compatibility declared.**
* **Modernized admin UI** following WordPress best practices: `wrap`, `nav-tab-wrapper`, `form-table`, native notices, scoped styles loaded only where needed, sticky-column scrollable matrix for the Categories tab.
* **Security hardening:** nonces on every form, capability checks, sanitization of all input, escaping of all output, explicit `sanitize_callback` for every registered setting.
* **Performance:** request-scoped memoization of user audiences, computed commissions and category overrides; provider-level caches to avoid repeated database lookups.
* **Settings link** added on the Plugins list screen.
* **Automatic, one-time migration** of legacy `wgd-{group_id}` and `wgd-cat-{cat_id}-{group_id}` options to the new audience-namespaced format. No manual action required; existing setups keep working unchanged.
* **New filters for extension:** `wgd_audience_providers`, `wgd_user_audiences`, `wgd_discount_value`, `wgd_addons`.

= 4.0.0 =
* Updated plugin name to comply with WordPress.org trademark guidelines.
* Plugin display name changed from "Woo Groups Discount" to "Groups Discount for WooCommerce".
* Updated all references to WooCommerce trademark throughout the plugin.
* Compatible with WordPress 6.8.3 and WooCommerce 10.3.5.

= 3.2.0 =
* Fixed some issues with variable products.
* Compatible with WooCommerce 3.1.1.

= 3.1.1 =
* Fixed cart 3.x issues.

= 3.1.0 =
* Improved translation system.
* Fixed an issue with simple products.

= 3.0 =
* WooCommerce 3.0 full compatibility.

= 2.3 =
* Improved the administration section.

= 2.2 =
* Fixed clear products cache when plugin values are updated.
* Compatible with WordPress 4.7 and WooCommerce 2.6.9.

= 2.1 =
* Updated translation system.
* Fixed: commission calculated when rate is selected and commission is set to zero.
* Fixed: display both prices in admin screen.

= 2.0 =
* Added textarea to set the dual-price text.
* Fixed original price displayed when the discount is not applicable.
* Renamed filter `wwo_group_pricing_display_original_prices` to `woo_group_pricing_display_original_prices`.
* Compatible with WordPress 4.6 and WooCommerce 2.6.4.

= 1.0 =
* Initial release.
