Title: Minimum quantity filter
Last modified: November 12, 2025

---

# Minimum quantity filter

 *  Resolved [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [7 months, 1 week ago](https://wordpress.org/support/topic/minimum-quantity-filter/)
 * Is there a filter in this plugin that allows changing the minimum quantity in
   PHP, so that subsequent actions and validations will work?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fminimum-quantity-filter%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Support [Sarmin](https://wordpress.org/support/users/sarmina5/)
 * (@sarmina5)
 * [7 months ago](https://wordpress.org/support/topic/minimum-quantity-filter/#post-18716295)
 * Yes, you can use our filter hook to change the minimum quantity with PHP.
   **Example:**
 * `add_filter( 'wcmmq_single_product_min_max_condition', function( $args, $product){
   
   if ( $product->get_id() == 123 ) {  $args['min_value'] = 10;  } return $args;},
   10, 2 );
 * This will update the minimum quantity dynamically.
 *  Thread Starter [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [7 months ago](https://wordpress.org/support/topic/minimum-quantity-filter/#post-18716369)
 * That’s not working for me. I’ve set both `min_value` and `min_qty` to 20, but
   nothing happens.
 * For reference, here’s my code:
 *     ```wp-block-code
       add_filter( 'wcmmq_single_product_min_max_condition', 'ps_vary_minimum_quantity', 10, 2 );function ps_vary_minimum_quantity( $args, $product ) {		if ( is_null( WC()->cart ) || WC()->cart->is_empty() ) {		return $args;	}	if ( $product->get_slug() != '600ml-bottle-carton-24' ) {		return $args;	}	$categories_to_check = [ 'spring-water-coolers', 'filtered-water-coolers-dispensers' ];	$term_ids = array();	foreach ( $categories_to_check as $term ) {		$term_object = get_term_by( 'slug', $term, 'product_cat' );		if ( $term_object && ! is_wp_error( $term_object ) ) {			$term_ids[] = $term_object->term_id;		}	}	if ( empty( $term_ids ) ) {		return $args;	}	$found  = 0;	foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {				$product_id = $cart_item['product_id'];				if ( $cart_item['variation_id'] > 0 ) {			$product_id = $cart_item['data']->get_parent_id();		}		if ( has_term( $term_ids, 'product_cat', $product_id ) ) {			$found++;			break;		}	}		if ( ! $found ) {		$args['min_value'] = $args['min_qty'] = 20;	}	return $args;}
       ```
   
 *  Thread Starter [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [7 months ago](https://wordpress.org/support/topic/minimum-quantity-filter/#post-18722882)
 * Any thoughts?
 *  Plugin Support [Sarmin](https://wordpress.org/support/users/sarmina5/)
 * (@sarmina5)
 * [6 months, 4 weeks ago](https://wordpress.org/support/topic/minimum-quantity-filter/#post-18726079)
 * The logic you wrote is correct, but **that filter (`wcmmq_single_product_min_max_condition`)
   only affects the product page**, not the cart/checkout validations.
   So even if
   you set `min_value` and `min_qty = 20`, the cart rules will **not** change because
   they use a different validation hook.
 * To make this work, you need to modify both:
 * ✅ **Product page filter** (you already did)
   ❗ **Cart validation filter** – 
   this is the one enforcing the rule
 * **The plugin uses the following filter for cart checks:**
   `add_filter( 'wcmmq_before_add_to_cart_validation_args','
   your_callback_function', 10, 2 );`
 * **You need to apply your condition inside this cart-level filter as well. Something
   like:**
 * add_filter( ‘wcmmq_before_add_to_cart_validation_args’, function( $args, $product){
 *     ```wp-block-code
       if ( $product->get_slug() !== '600ml-bottle-carton-24' ) {    return $args;}$categories_to_check = [    'spring-water-coolers',    'filtered-water-coolers-dispensers'];$term_ids = array();foreach ( $categories_to_check as $term ) {    $term_obj = get_term_by( 'slug', $term, 'product_cat' );    if ( $term_obj && ! is_wp_error( $term_obj ) ) {        $term_ids[] = $term_obj->term_id;    }}$found = false;foreach ( WC()->cart->get_cart() as $item ) {    $pid = $item['variation_id'] > 0 ? $item['data']->get_parent_id() : $item['product_id'];    if ( has_term( $term_ids, 'product_cat', $pid ) ) {        $found = true;        break;    }}if ( ! $found ) {    $args['min_value'] = 20;    $args['min_qty']   = 20;}    return $args;}, 10, 2 );
       ```
   
 *  Thread Starter [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [6 months, 4 weeks ago](https://wordpress.org/support/topic/minimum-quantity-filter/#post-18727412)
 * Thank you for this.
 * I added the line `add_filter( 'wcmmq_before_add_to_cart_validation_args', 'ps_vary_minimum_quantity',
   10, 2 );`, but nothing is happening when I add a 600ml bottle or change it quantity
   when there’s no cooler in the cart.
 * I have working code that uses the `woocommerce_update_cart_validation` and `woocommerce_after_calculate_totals`
   filters, but it’s not perfect, so I prefer to let your plugin handle the user
   experience.
 * Can you confirm that your filters work with blocks? If not, is there anything
   I need to do for this to work?
 *  Plugin Support [Sarmin](https://wordpress.org/support/users/sarmina5/)
 * (@sarmina5)
 * [6 months, 3 weeks ago](https://wordpress.org/support/topic/minimum-quantity-filter/#post-18729099)
 * It looks like this requires a custom solution.
   Please reach out to us through
   our official support channel so we can assist you properly.
 * This forum is limited to support for free features only.
 *  Thread Starter [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [6 months, 1 week ago](https://wordpress.org/support/topic/minimum-quantity-filter/#post-18745960)
 * I sent an email to your support team 2 weeks ago and have still not received 
   an answer. Do you know if the latest update enables the filters on blocks?
 *  Plugin Support [Sarmin](https://wordpress.org/support/users/sarmina5/)
 * (@sarmina5)
 * [6 months, 1 week ago](https://wordpress.org/support/topic/minimum-quantity-filter/#post-18746117)
 * Please create a ticket at: [http://codeastrology.com/my-support/](http://codeastrology.com/my-support/)

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Minimum quantity filter’ is closed to new replies.

 * ![](https://ps.w.org/woo-min-max-quantity-step-control-single/assets/icon-256x256.
   png?rev=3538540)
 * [Min Max Control - Min Max Quantity & Step Control for WooCommerce](https://wordpress.org/plugins/woo-min-max-quantity-step-control-single/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-min-max-quantity-step-control-single/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-min-max-quantity-step-control-single/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-min-max-quantity-step-control-single/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-min-max-quantity-step-control-single/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-min-max-quantity-step-control-single/reviews/)

 * 12 replies
 * 2 participants
 * Last reply from: [Sarmin](https://wordpress.org/support/users/sarmina5/)
 * Last activity: [6 months, 1 week ago](https://wordpress.org/support/topic/minimum-quantity-filter/#post-18746117)
 * Status: resolved