×

WooCommerce Limit Quantity Per Product: Control Purchase Limits

Managing stock efficiently is crucial for any WooCommerce store, especially if you sell limited-edition items, wholesale products, or bulk orders. By default, WooCommerce allows customers to purchase as many units of a product as they want, but what if you need to limit the quantity per order?

The WooCommerce Limit Quantity Per Product feature lets you set minimum and maximum quantity restrictions for individual products, helping you manage stock better and ensure fair distribution among customers. Whether you want to prevent bulk purchases, control stock levels, or encourage higher order values, this feature can be a game-changer for your store.

In this blog, we’ll explore why you should limit product quantities, how to set up quantity limits, and the best strategies for using them effectively.


Why Set a Quantity Limit on WooCommerce Products?

There are several reasons why store owners choose to restrict the quantity of products per order:

1. Prevent Bulk Buying or Hoarding

If you sell limited-stock products, preventing bulk purchases ensures fair access for all customers and prevents a single buyer from clearing out your inventory.

2. Encourage Bulk Purchases (Minimum Limits)

For wholesale or B2B stores, setting a minimum purchase limit (e.g., “You must buy at least 5 units”) helps maintain a steady order value.

3. Protect Against Fraud and Resellers

Limiting quantities helps prevent unauthorized resellers from buying in bulk and reselling your products at inflated prices.

4. Ensure Stock Availability

If you sell high-demand products, limiting per-customer purchases helps maintain stock for more customers.

5. Improve Customer Experience

For subscription-based or special promotions, setting quantity limits ensures customers can access your products in fair and controlled amounts.


How to Set a Quantity Limit in WooCommerce

You can set minimum and maximum quantity limits in WooCommerce using built-in options, plugins, or custom code.

Method 1: Using a WooCommerce Plugin (Recommended)

WooCommerce does not offer a built-in option to limit product quantity per order, but you can use plugins like:

  • WooCommerce Min/Max Quantities

  • Quantity Manager for WooCommerce

  • WooCommerce Advanced Product Quantities

How to Set Quantity Limits with a Plugin

  1. Install and activate the plugin of your choice.

  2. Go to WooCommerce > Settings > Quantity Limits (or relevant plugin settings).

  3. Select a product and set:

    • Minimum Quantity (e.g., “Customers must purchase at least 2 units”)

    • Maximum Quantity (e.g., “Customers cannot buy more than 5 units”)

  4. Save changes, and the limits will automatically apply to the product page.

Most plugins also offer bulk settings, so you can apply rules to multiple products at once.


Method 2: Manually Setting Quantity Limits via Custom Code

If you prefer a coding approach, you can add a custom PHP function to limit quantity per product.

Example: Set a Maximum Quantity Limit of 5 for a Product

Add the following code to your functions.php file:

php
function limit_product_quantity($cart_item_data, $product_id) {
$max_quantity = 5; // Set the maximum limit
if ($cart_item_data[‘quantity’] > $max_quantity) {
$cart_item_data[‘quantity’] = $max_quantity;
wc_add_notice(‘You cannot add more than ‘ . $max_quantity . ‘ of this product.’, ‘error’);
}

return $cart_item_data;
}
add_filter(‘woocommerce_add_cart_item_data’, ‘limit_product_quantity’, 10, 2);

This will prevent customers from adding more than 5 units of a specific product to their cart.


Best Practices for Using Quantity Limits

1. Set Different Limits for Different Products

Some products may require higher minimum limits (e.g., wholesale orders), while others may need lower maximum limits (e.g., exclusive items).

2. Display Clear Messages

If a customer tries to add more than the allowed quantity, display a clear error message such as:

🚫 “You can only purchase up to 3 units of this product.”

This prevents confusion and improves the shopping experience.

3. Use Limits for Flash Sales or Promotions

For time-limited discounts, restricting quantities can ensure more customers benefit from the promotion.

Example: “Max 2 per customer for Black Friday deals.”

4. Apply Different Limits for Different User Roles

For B2B stores, you might want to set higher limits for wholesale buyers and lower limits for regular customers.

Example:

  • Retail Customers → Maximum 5 units per order

  • Wholesale Customers → Maximum 100 units per order

You can achieve this using plugins like WooCommerce Role-Based Pricing.

5. Test the Rules Before Launching

Before applying quantity restrictions live, test them in your cart and checkout process to ensure they work correctly.


Common Mistakes to Avoid

🚫 Setting Limits Too Low or Too High – If your maximum quantity is too low, customers might abandon their purchase. If it’s too high, it might not serve its purpose.

🚫 Not Informing Customers About Limits in Advance – If a customer only finds out about the quantity limit at checkout, it can cause frustration. Always display quantity rules on the product page.

🚫 Forgetting to Update Limits for Different Promotions – If you’re running seasonal sales, ensure your limits align with promotional goals.


Final Thoughts

The WooCommerce Limit Quantity Per Product feature gives store owners complete control over how customers purchase products. Whether you want to prevent hoarding, manage stock efficiently, or encourage bulk purchases, setting minimum and maximum quantity limits is an effective way to optimize your WooCommerce store.

By using a plugin or custom code, you can easily apply these limits and enhance the shopping experience for your customers.

Post Comment