Woo Quantity Control Rules
Minimum, maximum and step quantities for WooCommerce by product, variation, category, tag and user role, with order limits by item count and by value, enforced in the classic cart and in the block checkout alike.
by George Vasiliades · github.com/poseidonas/woo-quantity-control-rules · website
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/poseidonas/woo-quantity-control-rules/releases/download/v1.0.0/woo-quantity-control-rules.zipDeclares an update source (https://github.com/Poseidonas/woo-quantity-control-rules), so updates arrive through the plugin's own updater.
Readme
Woo Quantity Control Rules
Minimum, maximum and step quantities for WooCommerce, set by product, variation, category, tag or user role, with limits for the whole order by item count and by value. Every rule is enforced on the classic cart and checkout and on the block cart and checkout alike.
- Author: George Vasiliades - https://github.com/Poseidonas
- License: GPL-2.0-or-later
- Requires WordPress 6.7 or newer
- Requires PHP 8.0 or newer
- Requires WooCommerce 9.0 or newer, tested up to 11.0
- Compatible with High-Performance Order Storage and with the cart and checkout blocks
- Settings live in WooCommerce > Settings > Products > Quantities
What was measured before writing this
Measured on WooCommerce 11.0.1 with a stock store:
| Question | Result |
|---|---|
| What quantity control does the core ship with? | One checkbox per product, Sold individually, which forces a maximum of one |
| Default quantity arguments for a simple product | min_value: 1, max_value: -1, step: 1, meaning no minimum above one, no maximum and no step |
| Options holding a store wide minimum or maximum | None exist |
| Where does the block cart read its limits from? | woocommerce_store_api_product_quantity_minimum, _maximum and _multiple_of, a different path from the classic woocommerce_quantity_input_args |
| What does WooCommerce do when a maximum ends up below the minimum? | It raises the maximum to the minimum and renders the quantity field as type="hidden" |
| What does the block cart do with a quantity that is not a multiple? | It rounds down to the nearest multiple rather than refusing the request |
The third row is the reason a rule has to be declared twice. A plugin that only filters the classic arguments leaves the block checkout free to submit any quantity, and the order goes through.
The last two rows shaped two features. Because a contradictory rule makes a product look broken rather than restricted, the settings page reports contradictions before a customer meets them. And because the block cart rounds a quantity down on its own, the difference between refusing and raising a quantity is stated plainly rather than assumed.
How a rule is resolved
For every product the plugin builds one rule out of four sources, each one overriding the one before it:
- The store defaults in WooCommerce > Settings > Products > Quantities
- The rule matching the role of the signed in customer, or
guestfor visitors - The rule matching any product category or product tag of the product
- The values on the product itself, and then on the variation
A product can carry Ignore store rules, in which case only its own values and its variations count and the first three steps are skipped. Sold individually in the WooCommerce core always wins and pins the maximum to one.
Each part of a rule is resolved on its own, so a category can set the step while the product sets the maximum.
Settings
Quantities for every product
Minimum, maximum and step for the whole store. Every field is empty on a fresh install, so nothing changes until a rule is set.
When a quantity does not fit decides what happens to a quantity that breaks the rule. Off, the default, means the customer is told and the cart refuses to proceed. On, the quantity is raised to the next allowed one: with a minimum of six and a step of six, a request for seven becomes twelve.
Rules by category, tag and role
One rule per line, written as slug | minimum | maximum | step. A number left out places no limit:
wholesale|6||6
clearance||2
guest||3
Category and tag rules read product category and product tag slugs. Role rules read role names such as administrator, customer or wholesale_customer, and guest for visitors who are not signed in.
Limits for the whole order
Fewest and most items, and smallest and largest order value. They are checked in the cart and again at checkout, on classic pages and on blocks. The value is compared against the subtotal including tax.
Messages
Every message can be replaced with your own wording. Write {product} for the product name and {limit} for the number. A field left empty uses the built in wording, translated into the language of the store.
Products that break the rules right now
Two reports sit under the settings, and both are reports only.
The first lists combinations of rules that cancel each other out, such as a category demanding six while a role allows four. Nothing on the product is wrong in that case, yet no customer can buy it, and WooCommerce responds by hiding the quantity field, so the product looks broken. The report names the combination before a customer meets it.
The second lists products whose own values cannot be satisfied: a minimum above the maximum, a step above the maximum, a minimum that is not a multiple of the step, or stock lower than the minimum. Each row links to the product. Role rules are left out of this one, because the answer would depend on who is looking at the screen.
Per product and per variation
The product data Inventory panel gains Minimum quantity, Maximum quantity, Sold in multiples of and Ignore store rules. Every variation gains the same three numbers, so a rule can differ between sizes of the same product.
Honest limits
- Rules apply from the moment they are set. Orders already placed and carts already saved are not rewritten.
- The order value is compared against the subtotal including tax, before shipping and before coupons, so the number a customer sees in the cart total may differ.
- The step for the block cart depends on
multiple_of, which WooCommerce added to the Store API. On older versions the minimum and maximum still apply and the step is enforced when the cart is checked. - Adding to the block cart, WooCommerce rounds a quantity down to the nearest allowed multiple on its own, whatever the raising option says. The raising option governs the classic cart. Order limits are refused on both.
- Raising a quantity applies when a product is added to the cart and when a cart line is changed. Orders created in the admin or through the REST API are not touched.
- The plugin does not create roles. A role rule matches a role that already exists on the site.
Filters
add_filter( 'icxcnika_qty_rule', function ( array $rule, WC_Product $product ): array {
return $rule;
}, 10, 2 );
add_filter( 'icxcnika_qty_settings', function ( array $settings ): array {
return $settings;
} );
icxcnika_qty_rule receives the resolved min, max and step, each either an integer or null, and is the last word before the rule is used. icxcnika_qty_registry_payload receives the data sent to the installation registry.
Data stored
- Options, one per settings field, all prefixed
icxcnika_qty_settings_. - Post meta on products and variations:
_icxcnika_qty_min,_icxcnika_qty_max,_icxcnika_qty_stepand_icxcnika_qty_override. - Option
icxcnika_qty_registry_key(random installation key of 48 characters, created only if installation reporting is active). - Transient
icxcnika_qty_release(cached GitHub release lookup, 12 hours). - Cron event
icxcnika_qty_registry_ping(weekly, only if installation reporting is active).
Installation reporting
On activation, on deactivation and once a week the plugin sends a small JSON message to the author's installation registry: plugin slug, plugin version, home URL, site URL, WordPress version, WooCommerce version, PHP version, locale and whether the site is a multisite. Each report carries a random installation key generated locally on first use. No customer data, order data, product data or personal data is ever sent.
The reporting address is empty by default, which means nothing is sent at all. Add define( 'ICXCNIKA_REGISTRY_DISABLE', true ); to wp-config.php to turn the reporting off, or define( 'ICXCNIKA_REGISTRY_URL', '...' ); to point it elsewhere.
Updates
Updates are delivered from GitHub Releases through the Update URI header of WordPress. The Plugins screen shows View details and allows automatic updates to be enabled, exactly as for a plugin from the directory.
Uninstall
Deleting the plugin removes every option, every product and variation value it wrote, the installation key, the cached release check and the scheduled report. Nothing of the WooCommerce core is touched.
Woo Quantity Control Rules (Ελληνικά)
Ελάχιστες, μέγιστες και βηματικές ποσότητες για το WooCommerce, ορισμένες ανά προϊόν, παραλλαγή, κατηγορία, ετικέτα ή ρόλο χρήστη, με όρια για ολόκληρη την παραγγελία σε τεμάχια και σε αξία. Κάθε κανόνας εφαρμόζεται τόσο στο κλασικό καλάθι και ταμείο όσο και στο καλάθι και το ταμείο με μπλοκ.
- Δημιουργός: George Vasiliades - https://github.com/Poseidonas
- Άδεια: GPL-2.0-or-later
- Απαιτεί WordPress 6.7 ή νεότερο
- Απαιτεί PHP 8.0 ή νεότερη
- Απαιτεί WooCommerce 9.0 ή νεότερο, δοκιμασμένο έως 11.0
- Συμβατό με το High-Performance Order Storage και με τα μπλοκ καλαθιού και ταμείου
- Οι ρυθμίσεις βρίσκονται στο WooCommerce > Ρυθμίσεις > Προϊόντα > Ποσότητες
Τι μετρήθηκε πριν γραφτεί
Μετρήθηκε σε WooCommerce 11.0.1 με κατάστημα χωρίς παρεμβάσεις:
| Ερώτημα | Αποτέλεσμα |
|---|---|
| Τι έλεγχο ποσότητας έχει ο πυρήνας; | Ένα κουτάκι ανά προϊόν, το Πωλείται μεμονωμένα, που επιβάλλει μέγιστο ένα |
| Προεπιλεγμένες παράμετροι ποσότητας για απλό προϊόν | min_value: 1, max_value: -1, step: 1, δηλαδή κανένα ελάχιστο πάνω από ένα, κανένα μέγιστο και κανένα βήμα |
| Επιλογές με καθολικό ελάχιστο ή μέγιστο | Δεν υπάρχουν |
| Από πού διαβάζει τα όριά του το καλάθι με μπλοκ; | woocommerce_store_api_product_quantity_minimum, _maximum και _multiple_of, διαφορετική διαδρομή από το κλασικό woocommerce_quantity_input_args |
| Τι κάνει το WooCommerce όταν το μέγιστο βρεθεί κάτω από το ελάχιστο; | Ανεβάζει το μέγιστο στο ελάχιστο και αποδίδει το πεδίο ποσότητας ως type="hidden" |
| Τι κάνει το καλάθι με μπλοκ με ποσότητα που δεν είναι πολλαπλάσιο; | Τη στρογγυλοποιεί προς τα κάτω στο πλησιέστερο πολλαπλάσιο αντί να την απορρίψει |
Η τρίτη γραμμή είναι ο λόγος που κάθε κανόνας πρέπει να δηλωθεί δύο φορές. Ένα πρόσθετο που φιλτράρει μόνο τις κλασικές παραμέτρους αφήνει το ταμείο με μπλοκ ελεύθερο να στείλει οποιαδήποτε ποσότητα, και η παραγγελία περνά.
Οι δύο τελευταίες γραμμές διαμόρφωσαν δύο δυνατότητες. Επειδή ένας αντιφατικός κανόνας κάνει το προϊόν να δείχνει χαλασμένο αντί για περιορισμένο, η σελίδα ρυθμίσεων αναφέρει τις αντιφάσεις πριν τις συναντήσει ο πελάτης. Και επειδή το καλάθι με μπλοκ στρογγυλοποιεί μόνο του προς τα κάτω, η διαφορά ανάμεσα στην απόρριψη και στην ανύψωση δηλώνεται ρητά αντί να θεωρείται δεδομένη.
Πώς προκύπτει ένας κανόνας
Για κάθε προϊόν συντίθεται ένας κανόνας από τέσσερις πηγές, καθεμιά υπερισχύει της προηγούμενης:
- Οι προεπιλογές του καταστήματος στο WooCommerce > Ρυθμίσεις > Προϊόντα > Ποσότητες
- Ο κανόνας του ρόλου του συνδεδεμένου πελάτη, ή
guestγια τους επισκέπτες - Ο κανόνας κάθε κατηγορίας ή ετικέτας του προϊόντος
- Οι τιμές του ίδιου του προϊόντος, και έπειτα της παραλλαγής
Ένα προϊόν μπορεί να φέρει Αγνόησε τους κανόνες του καταστήματος, οπότε μετρούν μόνο οι δικές του τιμές και οι τιμές των παραλλαγών του και τα τρία πρώτα βήματα παραλείπονται. Το Πωλείται μεμονωμένα του πυρήνα υπερισχύει πάντα και καθηλώνει το μέγιστο στο ένα.
Κάθε μέρος του κανόνα προκύπτει ξεχωριστά, οπότε μια κατηγορία μπορεί να ορίσει το βήμα ενώ το προϊόν ορίζει το μέγιστο.
Ρυθμίσεις
Ποσότητες για κάθε προϊόν
Ελάχιστο, μέγιστο και βήμα για όλο το κατάστημα. Κάθε πεδίο είναι κενό σε νέα εγκατάσταση, οπότε τίποτα δεν αλλάζει μέχρι να οριστεί κανόνας.
Το Όταν μια ποσότητα δεν ταιριάζει αποφασίζει τι γίνεται με μια ποσότητα που παραβιάζει τον κανόνα. Ανενεργό, που είναι η προεπιλογή, σημαίνει ότι ο πελάτης ενημερώνεται και το καλάθι δεν προχωρά. Ενεργό, η ποσότητα ανεβαίνει στην επόμενη επιτρεπτή: με ελάχιστο έξι και βήμα έξι, ένα αίτημα για επτά γίνεται δώδεκα.
Κανόνες ανά κατηγορία, ετικέτα και ρόλο
Ένας κανόνας ανά γραμμή, γραμμένος ως slug | ελάχιστο | μέγιστο | βήμα. Αριθμός που παραλείπεται δεν βάζει όριο:
wholesale|6||6
clearance||2
guest||3
Οι κανόνες κατηγοριών και ετικετών διαβάζουν slug κατηγοριών και ετικετών προϊόντων. Οι κανόνες ρόλων διαβάζουν ονόματα ρόλων όπως administrator, customer ή wholesale_customer, και guest για επισκέπτες χωρίς σύνδεση.
Όρια για ολόκληρη την παραγγελία
Λιγότερα και περισσότερα τεμάχια, μικρότερη και μεγαλύτερη αξία παραγγελίας. Ελέγχονται στο καλάθι και ξανά στο ταμείο, σε κλασικές σελίδες και σε μπλοκ. Η αξία συγκρίνεται με το μερικό σύνολο μαζί με τον φόρο.
Μηνύματα
Κάθε μήνυμα μπορεί να αντικατασταθεί με δική σας διατύπωση. Γράψτε {product} για το όνομα του προϊόντος και {limit} για τον αριθμό. Πεδίο που μένει κενό χρησιμοποιεί την ενσωματωμένη διατύπωση, μεταφρασμένη στη γλώσσα του καταστήματος.
Read the full README on GitHub →
Releases
| Tag | Published | Asset | Downloads |
|---|---|---|---|
| v1.0.0 | Aug 19, 2026 | woo-quantity-control-rules.zip | 1 |