Website Building » WooCommerce » How Do I Add a Minimum Quantity in WooCommerce?

How Do I Add a Minimum Quantity in WooCommerce?

Last updated on January 15, 2023 @ 1:58 pm

Do you sell products in bulk and want to set a minimum quantity per order in WooCommerce? By default, WooCommerce doesn’t have an option to set a minimum quantity for products. In this article, we’ll show you how to easily add a minimum quantity for products and orders in WooCommerce.

When selling products in bulk, you may want to set a minimum quantity per order in WooCommerce. This will ensure that customers purchase the minimum amount that you require, and helps to avoid small orders that may not be profitable.

WooCommerce doesn’t have an option to set a minimum quantity for products by default. However, it’s easy to add this functionality with the help of a plugin or custom code.

PRO TIP: If you are planning to add a minimum quantity in WooCommerce, be aware that this may impact your sales. If customers are unable to purchase the minimum quantity required, they may be discouraged from buying from your store altogether. Be sure to test this feature thoroughly before making it live on your site.

Method 1: Use a Plugin

There are many plugins that allow you to set a minimum quantity for products and orders in WooCommerce. We recommend using the Minimum Order Quantity for WooCommerce plugin. It’s simple to use and is available for free from the WordPress plugin repository.

To use the Minimum Order Quantity for WooCommerce plugin:

  1. Install and activate the plugin
  2. Go to WooCommerce → Settings → Products → Minimum Order Quantity
  3. Configure the plugin settings according to your needs
  4. Save your changes

Method 2: Use Custom Code

If you’re comfortable working with code, you can add a minimum quantity for products and orders in WooCommerce with just a few lines of code. Simply add the following code snippet to your theme’s functions.php file or a site-specific plugin.

/**

Set a minimum order quantity for items in WooCommerce.
/
function wc_minimum_order_quantity( $qty, $product ) {
$minimum = 3; // Set your minimum order quantity here
return $minimum;
}
add_filter( 'woocommerce_stock_amount', 'wc_minimum_order_quantity', 10, 2 );
/*
Display a notice if the item is below the minimum required order quantity.
*/
function wc_minimum_order_quantity_notice() {
global $woocommerce;
$message = sprintf( 'You must have at least %s items in your cart.' , wc_minimum_order_quantity() );
wc_print_notice( $message, 'error' );
}
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_quantity_notice' );
Drew Clemente

Drew Clemente

Devops & Sysadmin engineer. I basically build infrastructure online.