10.4 C
London
Friday, March 27, 2026

How To Set Min And Max Product Quantities In WooCommerce

- Advertisement -spot_imgspot_img
- Advertisement -spot_imgspot_img

To change the Min And Max Product Quantities of the products, one needs to use the filters provided by WooCommerce.

Below are the filters which are related to the quantity selector field:

  • woocommerce_quantity_input_min
  • woocommerce_quantity_input_max

woocommerce_quantity_input_min filter allows to change the minimum value for the quantity. The default value for the minimum quantity is 0.

woocommerce_quantity_input_max filter allows changing the maximum value for the quantity. The default value for the minimum quantity is -1.

/*Woocommerce min input quantity filter : woocommerce_quantity_input_min*/
<?php
/*
* Changing the minimum quantity to 1 for all the WooCommerce products
*/
function woocommerce_quantity_input_min_callback( $min, $product ) {
  $min = 1;  
  return $min;
}
add_filter( 'woocommerce_quantity_input_min', 'woocommerce_quantity_input_min_callback', 10, 2 );
?>
/*Woocommerce max input quantity filter : woocommerce_quantity_input_max*/
<?php
/*
* Changing the maximum quantity to 2 for all the WooCommerce products
*/
function woocommerce_quantity_input_max_callback( $max, $product ) {
  $max = 2;  
  return $max;
}
add_filter( 'woocommerce_quantity_input_max', 'woocommerce_quantity_input_max_callback', 10, 2 );
?>

- Advertisement -spot_imgspot_img
Latest news
- Advertisement -spot_img
Related news
- Advertisement -spot_img

LEAVE A REPLY

Please enter your comment!
Please enter your name here