Use a filter to exclude selected products from the quantities and values counted by order rules in Min/Max Quantities.
Note:
This is a developer-level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customization work. We are unable to provide support for customization under our Support Policy.
This example returns yes for the selected IDs and preserves the existing value for other items. Replace the example IDs with the IDs used by your rules. Depending on the rule, the checked ID can be a product or variation ID, so test your own configuration.
add_filter( 'wc_min_max_quantity_minmax_do_not_count', 'example_mmq_exclude_order_totals', 10, 4 );
function example_mmq_exclude_order_totals( $do_not_count, $checking_id, $cart_item_key, $cart_item ) {
$excluded_ids = array( 123, 456 );
if ( in_array( (int) $checking_id, $excluded_ids, true ) ) {
return 'yes';
}
return $do_not_count;
}
Add custom code using a site-specific plugin or a child theme, and test it on a staging site first. The filter changes what counts toward order quantity and value limits; review the other product and category rules separately.
For setting up rules in the dashboard, see Min/Max Quantities.
Questions and support
↑ Back to topSomething missing from this documentation? Still have questions and need assistance?
- If you have a question about an extension or theme you’d like to purchase, visit our contact page and use the AI Assistant or contact options.
- If you already purchased this product and need some assistance, get in touch with a Happiness Engineer via our support page and select this product’s name from the Product dropdown.