Exclude products from Min/Max Quantities order totals

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 customizations. We are unable to provide support for customizations 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 top

Something missing from this documentation? Still have questions and need assistance?

  • If you have a question about a specific extension or theme you’d like to purchase, contact us to get answers.
  • 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.

Related Products

WooCommerce Subscriptions is a WooCommerce extension that lets customers subscribe to your products or...

Offer add-ons like gift wrapping, special messages or other special options for your products.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.