Per-Product Quantity Rules WordPress Function
What it does?
-
Admin UI for quantity rules
Adds a “Quantity settings” toggle on the product editor (simple & variable). When enabled, shows fields for Min Qty, Max Qty (supports unlimited), and Step. Includes a small script to reveal/hide the fields instantly. -
Saves rules per product
Stores the chosen min/max/step so editors can manage MOQs, case packs, or wholesale increments per SKU. -
Applies rules on single product pages
-
Sets the quantity input’s min, max, and step.
-
Uses the min as the default input value (outside the cart), so customers start at the correct quantity.
-
Caps max by real stock when stock is managed and backorders are disallowed.
-
-
Works with variations
Inherits the parent product’s rules and exposes min_qty / max_qty to the variation data. For stock-managed variations without backorders, max is further limited by the variation’s stock. -
Shop/Archive add-to-cart
For AJAX add-to-cart buttons in product loops, forces the min quantity so quick adds honor your rules.
Why it’s useful?
-
Stop odd or unprofitable orders
Enforce minimum order quantities, carton multiples, and clean increments to protect margin and packing efficiency. -
Consistent UX, fewer errors
Customers see valid quantities everywhere (product, variations, and loop), reducing cart validation errors and support tickets. -
Operational fit
Aligns storefront behavior with warehouse realities (e.g., sell in 6-packs, cap buys to available stock). -
Granular control
Tune rules per product instead of a one-size-fits-all approach.
