=== DreamFox Purchase Limits for WooCommerce ===
Contributors: dreamfox
Tags: woocommerce, minimum order quantity, min max quantity, quantity limits, step quantity
Requires at least: 6.0
Tested up to: 7.0.4
Requires PHP: 7.4
WC requires at least: 7.0
WC tested up to: 11.0.1
Stable tag: 1.1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Set minimum, maximum and step purchase quantities per product, variation, category or storewide, plus cart item and order limits.

== Description ==

**DreamFox Purchase Limits for WooCommerce** gives you full control over how many units customers can buy. Enforce a minimum order quantity, cap the maximum, force sales in fixed increments (packs of 6, 12, …), and set minimum/maximum limits on the whole cart — item count and order amount alike.

Every rule is enforced on the product page quantity stepper, at add-to-cart, on the cart page and again at checkout, with clear, fully customizable notices so customers always know what to do. Works with both the classic (shortcode) cart/checkout and the **Cart & Checkout blocks**.

= Free features =

* **Minimum quantity** – require customers to buy at least a set number of units, per product.
* **Maximum quantity** – cap how many units of a product can be purchased.
* **Step / increment rules** – force purchases in multiples (packs of 6, 12, or any custom step).
* **Per-variation rules** – set independent min/max/step on each variation of a variable product.
* **Per-category rules** – apply limits to a whole product category, with the most restrictive rule winning.
* **Per-tag rules** – apply limits to a whole product tag, with the most restrictive rule winning.
* **Amount (spend) limits** – set a minimum/maximum line total (price × quantity) per product, variation, category or tag.
* **Storewide defaults** – one min/max/step and min/max amount applied to every product unless overridden.
* **Cart item-count limits** – require a minimum or enforce a maximum number of items per order.
* **Cart order-amount limits** – set a minimum or maximum order subtotal before checkout.
* **Cart distinct-product limits** – require a minimum or cap the maximum number of different products per order.
* **Category cart totals** – require a minimum or cap the maximum combined quantity, amount and number of different products of a whole category in the cart.
* **Role-based rules** – override the storewide defaults and cart limits per user role (wholesale, VIP, members …); the most restrictive of a user's roles applies.
* **Minimum after discount** – optionally check order-amount limits against the discounted total instead of the subtotal.
* **Exclude individual products** – flag a product (gift cards, samples, …) to ignore every limit, including category, tag and storewide rules.
* **Disable rules per category or tag** – flag a category or tag so its products ignore all limits.
* **Product-page hint** – optionally show the minimum, maximum and step on the product page so customers see the rule before they hit an error.
* **Smart quantity stepper** – the product and cart quantity inputs respect the min, max and step automatically.
* **Cart-aware validation** – limits account for what a customer already has in the cart.
* **Role exemptions** – let chosen roles (e.g. wholesale buyers) bypass all limits.
* **Customizable notices** – rewrite every message with placeholders like {product}, {min}, {max}, {step}, {qty} and {amount}.
* **Priority resolution** – variation → product → category → tag → storewide default, so the most specific rule always wins.
* **HPOS compatible** – declares full High-Performance Order Storage support.
* **Cart & Checkout blocks compatible** – declares full support for the block-based Cart and Checkout, alongside the classic shortcode-based cart and checkout.
* **Translation ready** – all strings are localizable.

= Rule priority =

For any product the effective limit is resolved in this order, most specific first:

1. Variation
2. Product
3. Category (most restrictive when a product is in several)
4. Tag (most restrictive when a product has several)
5. Storewide default

A product flagged as excluded skips all of the above and has no limits.

Built by [DreamFox Media](https://dreamfoxmedia.com).

== Installation ==

1. Upload the plugin files to `/wp-content/plugins/dreamfox-purchase-limits-for-woocommerce`, or install through the WordPress plugins screen.
2. Activate the plugin through the 'Plugins' screen.
3. Go to **WooCommerce → Quantity Rules** to set storewide defaults, cart limits and messages.
4. Optionally set per-product limits on the product **Inventory** tab, per-variation limits on each variation, or per-category and per-tag limits on the category/tag edit screens.

== Frequently Asked Questions ==

= Can I force customers to buy in packs of 6? =

Yes. Set the **Step (increment)** to 6 on the product (or storewide). Customers can then only buy 6, 12, 18, and so on. Combine it with a minimum for a starting pack size.

= Which rule wins if a product has both product and category limits? =

The most specific rule wins: variation over product, product over category, category over tag, and tag over the storewide default. Each of minimum, maximum and step is resolved independently.

= Can I set limits on a product tag? =

Yes. Edit any product tag (Products → Tags) and set its minimum, maximum and step, just like categories. Category rules take priority over tag rules when both apply.

= How do I stop a specific product from having any limit? =

Open the product, go to the **Inventory** tab and tick **Exclude from limits**. That product will ignore every rule — product, category, tag and storewide. You can also disable rules for a whole category or tag from its edit screen.

= Can I limit spend rather than quantity? =

Yes. Every level (product, variation, category, tag and storewide) supports a minimum and maximum **line amount** (price × quantity), alongside the quantity rules.

= Can I require a minimum quantity or spend for a whole category across the cart? =

Yes. Edit a product category and set its **Cart minimum/maximum quantity** and **Cart minimum/maximum amount**. The plugin sums every item from that category in the cart and enforces the limits at checkout.

= Can I limit how many different products are in an order? =

Yes. Under **WooCommerce → Quantity Rules → Cart limits** set a minimum and/or maximum number of distinct products, either storewide or per category.

= Can I set different limits for wholesale or VIP customers? =

Yes. Under **WooCommerce → Quantity Rules → Role-based rules** you can override the storewide defaults and cart limits for any user role. When a customer has several roles, the most restrictive rule applies. You can also fully exempt a role from all limits.

= Can the order-amount limit use the price after discounts? =

Yes. Enable **Order amount basis → after discounts** in the Cart limits section to check the minimum/maximum order amount against the discounted total rather than the subtotal.

= What happens when a product is in several categories with different limits? =

The most restrictive category rule is used: the highest minimum, the lowest maximum and the largest step.

= Can some customers bypass the limits? =

Yes. Under **WooCommerce → Quantity Rules → Role exemptions** you can let specific roles (such as wholesale buyers) purchase any quantity.

= Are the limits enforced at checkout? =

Yes. Rules are checked on the product page, at add-to-cart, on the cart page and again during the checkout validation step, so invalid quantities can never slip through.

= Is the plugin compatible with HPOS (High-Performance Order Storage)? =

Yes, the plugin declares full HPOS compatibility.

= Does this work with the block-based Cart and Checkout? =

Yes. The plugin declares full compatibility with the Cart and Checkout blocks. Add-to-cart is blocked immediately with the same customizable message you configure for classic checkout. A rule broken while editing quantities in the Cart block is shown as a clear notice and still prevents checkout until it's resolved, exactly like the classic flow.

== Screenshots ==

1. Storewide defaults, cart limits and role exemptions.
2. Per-product min/max/step on the Inventory tab.
3. Per-variation limits.
4. Per-category limits on the category screen.
5. A clear notice shown when a quantity is invalid.

== Changelog ==

= 1.1.0 =
* Verified and declared compatibility with the WooCommerce Cart & Checkout blocks (Store API), after testing against a live WordPress 7.0.4 / WooCommerce 11.0.1 install with blocks active. Add-to-cart and cart-item quantity limits (including step/increment) are enforced the same way they are under classic checkout; amount and cart-wide/category total rules are enforced as a blocking checkout notice.
* Updated "WC tested up to" to 11.0.1 and WordPress "Tested up to" to 7.0.4.

= 1.0.5 =
* Fix: text domain now matches the plugin's registered WordPress.org slug (dreamfox-purchase-limits-for-woocommerce), per plugin review feedback — translations load correctly again. Display name is unchanged.

= 1.0.4 =
* Renamed to DreamFox Purchase Limits for WooCommerce (was Quantity Rules for WooCommerce), per WordPress.org plugin review feedback on name distinctiveness.

= 1.0.3 =
* Redesigned the settings screen with a tabbed layout (Information, Storewide Defaults, Cart Limits, Role Rules, Display, Notice Messages) and a proper Information tab.

= 1.0.2 =
* Renamed to Quantity Rules for WooCommerce (was Min & Max Quantities for WooCommerce).

= 1.0.1 =
* Fix: shortened the plugin's short description to meet WordPress.org's length limit.
* Fix: prefixed global-scope variables in the multisite uninstall routine.
* Fix: hardened the bundled CLI test scripts against direct web access.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.1.0 =
Adds verified, declared compatibility with the Cart & Checkout blocks; no change to classic checkout behavior.

= 1.0.5 =
Fixes the plugin's text domain to match its WordPress.org slug so translations work; no functional changes.

= 1.0.4 =
Plugin renamed to DreamFox Purchase Limits for WooCommerce; no functional changes.

= 1.0.3 =
Redesigned settings screen with tabs; no changes to how rules are enforced.

= 1.0.2 =
Plugin renamed to Quantity Rules for WooCommerce; no functional changes.

= 1.0.1 =
Minor fixes for WordPress.org plugin review compliance; no functional changes.

= 1.0.0 =
Initial release.
