Website Building » WooCommerce » How do I limit a quantity in WooCommerce?

How do I limit a quantity in WooCommerce?

Last updated on September 24, 2022 @ 10:05 pm

When setting up your WooCommerce shop, it’s always important to keep track of how much product you’re selling. This way, you can limit your quantity to make sure you’re not running out of stock and ending up with disappointed customers.

To limit a quantity in WooCommerce, first select the product you want to limit. Then, under the “Attributes” tab, click on the “Quantity” link.

PRO TIP: WooCommerce does not currently have a built-in mechanism for limiting the quantity of items that can be purchased in a single order. However, you can use the following code snippet to achieve this:

add_filter( ‘woocommerce_quantity_input_args’, ‘jk_woocommerce_quantity_input_args’, 10, 2 );
function jk_woocommerce_quantity_input_args( $args, $product ) {
if ( is_singular( ‘product’ ) ) {
$args[‘input_value’] = 1; // Starting value (we only want to affect product pages, not cart)
$args[‘max_value’] = 20; // Maximum value
$args[‘min_value’] = 1; // Minimum value
return $args;

On the Quantity Limits page, you’ll see a limit for each attribute. For example, you can set a limit for the number of products in a category, the number of products in a subcategory, or the number of products per page.

Once you’ve set your limits, clicking on the “Update” button will update the quantity for all products with the same limit.

Kathy McFarland

Kathy McFarland

Devops woman in trade, tech explorer and problem navigator.