Site icon Experience Wordpress Developer Online – Design Develop and Maintenance Support

Define Add to Cart Min, Max & Incremental Quantities

Are you planning to define the minimum,maximum & Incremental quantities to the products which you are selling on your store build up with WooCommerce? If yes, then you can achieve your goal simply by using filters available in WooCommerce. Let’s to do this.

So first of all Open your WordPress admin panel. Go to Products and Edit one of your product than go to at product data-simple product. In product data-simple product go to invetory. In invetory set mark enable at Manage stock and also set Stock quantity 1. save your changes. For Your refresence see the below screenshot:

Add this following line of code in your theme’s functions.php file of your active child theme (or theme) and Save the file. You can see that quantity value is set in single product page.

add_filter( 'woocommerce_quantity_input_args', 'wp_woocommerce_quantity_changes', 10, 2 );
  
function wp_woocommerce_quantity_changes( $args, $product ) {
  
   $args['input_value'] = 4; // Start from this value (default = 1) 
   $args['max_value'] = 10; // Max quantity (default = n/a)
   $args['min_value'] = 2; // Min quantity (default = 1)
   $args['step'] = 2; // Increment/decrement by this value (default = 1)
  
   return $args;
}
Exit mobile version