Gatemi Min/Max Quantities Developer Reference

Read from the plugin code. The free edition is plain WordPress PHP (GMMQF_* classes); the full edition is namespaced (GatemiMinMaxQuantities).

Free edition

The free edition applies no filters or actions of its own. It hooks:

Hook What it does
woocommerce_quantity_input_args Sets min_value, max_value and, off the cart page, input_value.
woocommerce_add_to_cart_validation Refuses an addition over the maximum.
woocommerce_check_cart_items Adds an error notice for every product outside its rule.
woocommerce_product_options_inventory_product_data / woocommerce_admin_process_product_object The two product fields.

Meta keys: _gmmqf_min and _gmmqf_max on products (whole numbers as strings; empty means none). Uninstall deletes both.

Filters — Full edition

Filter Arguments What it changes
gmmq_rules RuleSet $rules, WC_Product $product The final rule for a product, after inheritance and normalization. Applied after the cache, so a per-request filter is never frozen in.
gmmq_category_rules RuleSet $rules, WC_Product $product What the product inherits from its categories, before its own values apply.
gmmq_quantity_input_args array $args, WC_Product $product The quantity field's arguments after the rules are applied.
gmmq_cart_item_counts bool $counts, array $cart_item, WC_Product $product, string $cart_item_key Return false to leave one cart line out of every rule.
gmmq_violation_message string $message, Violation $violation The wording of any message a blocked shopper reads. Plain text — the Store API strips markup.
gmmq_order_value_includes_tax bool $includes Whether tax counts toward the order-value rules.
gmmq_can_display_express_checkout bool $allowed, WC_Product $product Whether express checkout buttons may appear on a product.
gmmq_settings array $settings The order-wide settings after defaults.
gmmq_modules array $modules The module list the plugin boots.
gmmq_license_api_url string $url The gatemi.com licensing endpoint.
gmmq_update_cache_ttl int $seconds How long the update payload is cached.

A RuleSet holds three integers, read with minimum(), maximum() and group_of() (0 means "none"), and is built with new RuleSet( $min, $max, $group_of ).

Example: a different minimum for trade customers

use GatemiMinMaxQuantitiesRulesRuleSet;

add_filter( 'gmmq_rules', function ( $rules, $product ) {
	if ( current_user_can( 'wholesale_customer' ) ) {
		return new RuleSet( max( 12, $rules->minimum() ), $rules->maximum(), $rules->group_of() );
	}
	return $rules;
}, 10, 2 );

A RuleSet returned from the filter goes through the same sanity pass as any other rule (minimum up to the next multiple, maximum down); anything that is not a RuleSet is ignored and the unfiltered rule is used.

Example: leave gift-wrap lines out of every rule

add_filter( 'gmmq_cart_item_counts', function ( $counts, $item, $product ) {
	return has_term( 'gift-wrap', 'product_cat', $product->get_parent_id() ?: $product->get_id() ) ? false : $counts;
}, 10, 3 );

Actions — Full edition

gmmq_booted fires after every module has booted, with the plugin's container.

Meta keys — Full edition

Key On Value
_gmmq_min_qty product, variation, product_cat term minimum quantity
_gmmq_max_qty product, variation, term maximum quantity
_gmmq_group_of product, variation, term "sold in multiples of"
_gmmq_variation_rules variation yes when the variation uses its own numbers
_gmmq_combine_variations product yes to judge all variations together
_gmmq_exclude_order_rules product yes to ignore order-wide rules
_gmmq_exclude_order_count product yes to leave the product out of order totals
_gmmq_exclude_category_rules product yes to inherit nothing from categories

An absent or empty value means "no opinion" — the product inherits.

Options and cache — Full edition

  • gmmq_settings — min_order_quantity, max_order_quantity, min_order_value, max_order_value, value_includes_tax, delete_data.
  • gmmq_rules_generation — a counter bumped whenever a rule could have changed; every cache entry is keyed by it.
  • Object-cache group gmmq_rules.
  • gmmq_license and the transient gmmq_update_payload for the licence.

Store API — Full edition

Problems are added to the Store API's cart errors (woocommerce_store_api_cart_errors) and checked again on woocommerce_store_api_checkout_update_order_meta, where a violation stops the order.

CSS and script — Full edition

On product and cart pages the plugin enqueues gatemi-mmq.css and gatemi-mmq.js (localized as gmmqSettings), which show a short hint beside the quantity box — "Sold in multiples of 6.", "Minimum 4.", "Adjusted to 12." — styled with .gmmq-hint and .gmmq-hint--active. The free edition loads no storefront assets.

What neither edition has

No database tables, no REST routes, no shortcodes, no cron events (apart from the full edition's licence check), and nothing written to orders.

Shopping Cart
Scroll to Top