Ready to Transform Your Online Presence? Let's Get Started!

How to Set Minimum Quantity on WooCommerce Product Page (Simple Code Snippet)

If you’re running a wholesale store, bulk-selling products, or offering B2B pricing, you may want customers to purchase a minimum quantity before they can add a product to the cart.

By default, WooCommerce allows customers to purchase even a single item — but with a small customization, you can enforce a minimum quantity directly on the product page.

In this guide, I’ll show you a simple and effective code snippet to set a minimum quantity in WooCommerce.

Why Set a Minimum Quantity?

Setting a minimum quantity is useful when:

  • You sell wholesale products
  • You want to increase the average order value
  • You have packaging restrictions (e.g., boxes of 10)
  • You offer bulk discounts
  • You want to reduce small, unprofitable orders

For example, if you sell printed materials in packs of 10, you can force customers to buy at least 10 units.

The Simple WooCommerce Code Snippet

Add the following code to your theme’s functions.php file (preferably in a child theme):

add_filter('woocommerce_quantity_input_args', function ($args, $product) {

    if (!is_product()) {
        return $args;
    }

    $min_qty = 10; // set this to your minimum quantity

    $args['min_value']   = $min_qty;
    $args['input_value'] = max($args['input_value'], $min_qty);

    return $args;

}, 20, 2);

What This Code Does

Let’s break it down:

1️⃣ Hooks into WooCommerce Quantity Field

The filter:

woocommerce_quantity_input_args

Allows us to modify the quantity input field arguments.

2️⃣ Restricts It Only to Single Product Pages

if (!is_product()) {
    return $args;
}

This ensures the minimum quantity is applied only on single product pages, not on shop/archive pages.


3️⃣ Sets Minimum Quantity

$min_qty = 10;

You can change 10 to any number you want.


4️⃣ Forces Default Value to Minimum

$args['min_value']   = $min_qty;
$args['input_value'] = max($args['input_value'], $min_qty);
  • min_value → Prevents selecting less than 10
  • input_value → Ensures the default quantity is 10 when the page loads

Important: This Only Controls the UI

This snippet only controls the front-end quantity field.

If someone manually edits the quantity via cart page or custom request, WooCommerce might still allow it.

For full validation (including cart validation and archive pages), you’ll need additional hooks.

If you need a complete professional implementation, check our WooCommerce Customization Services

We help businesses implement advanced quantity logic, role-based pricing, dynamic rules, and more.

How to Make It Product-Specific (Optional Upgrade)

If you want this minimum quantity to apply only to specific products:

Replace 123 with your product ID.

add_filter('woocommerce_quantity_input_args', function ($args, $product) {

    if (!is_product() || $product->get_id() != 123) {
        return $args;
    }

    $min_qty = 10; // set this to your minimum quantity

    $args['min_value']   = $min_qty;
    $args['input_value'] = max($args['input_value'], $min_qty);

    return $args;

}, 20, 2);

When Should You Use Custom Development?

Use this snippet if:

  • You want a simple minimum quantity
  • You’re comfortable editing functions.php
  • You don’t want to install extra plugins

But if you need:

  • Role-based minimum quantities
  • Category-based rules
  • Variable product support
  • Cart validation protection
  • Archive/shop page support
  • AJAX add-to-cart enforcement

Then you’ll need a more advanced solution.

👉 Explore our professional WooCommerce customization services here:
https://wplogist.com/service/woocommerce-customization/

Final Thoughts

Setting a minimum quantity in WooCommerce is simple with the right filter. With just a few lines of code, you can control purchasing behavior and increase your store’s profitability.

If you’re running a growing WooCommerce store and want custom logic tailored to your business model, professional customization can save time and prevent technical issues later.

Need help implementing advanced WooCommerce logic?
We’ve got you covered.