How to prevent negative stock in WooCommerce

WooCommerce has a track record of leaving store owners with negative inventory for their products. Negative stock can happen when multiple people try to purchase the same product at the exact same time (also known as race conditions). I’ll go over a few ways to help fix and prevent negative stock numbers in WooCommerce.

Firstly turn off backorders.

The backorder feature allows your product to be purchased when it’s out of stock. Make sure the backorder setting on the individual product is set to “do not allow”.

Allow products to be reserved per customer.

We’ve been developing our Reserved Stock Pro plugin to allow customers to reserve products for a limited time in their cart. Once all the product stock is reserved, no other customers can add the same product to their cart.

How does it prevent negative stock?

The standard WooCommerce way:

Inventory levels in WooCommerce are only reduced when an order is marked as processing, on-hold, or completed.

Let’s 100 people could be trying to checkout at the same time while there are only 5 items in stock. In a rush sale it’s likely that more than 5+ orders could be made at the exact same time. This could cause WooCommerce to oversell the product stock unintentionally due to the code running at the same time.

The rest of the customers who attempt to checkout around the same time will be left disappointed with an “Product is out of stock” message on the checkout.

The better way – Let customers reserve products in their cart:

Our Reserved Stock Pro plugin allows customers to reserve the product stock as soon as they add the product to their cart. They can safely checkout within a set amount of time.

All cart actions goes through additional validation compared to the standard WooCommerce way. This method ensures there are enough stock for every single customer who managed to add the product to the cart. There’s no overselling due to rush customers completing the checkout.

We’ve written the technical explanation and concurrency information in the documentation.

This means that only the customers who reserved the product are able to checkout. This prevents an overload of people going through the checkout when there’s not enough stock.

Limit product quantity per customer order

This problem is similar to the above with one difference. Maybe you don’t have a huge amount of customers rushing to the checkout. Instead, you have scenarios where customers tend to buy the bulk of your product at the same time. In that case, I’d also recommend our Reserved Stock Pro plugin.

However, if you are just looking to limit the number of product quantities per order, then that could also be a solution. You can use our Minimum and Maximum Quantities plugin, it’s fully compatible with Reserved Stock Pro as well.

How to test that negative stock is fixed

The only way to ensure that your negative stock issue in WooCommerce is fixed is by testing it. Testing can be done automatically by running traffic load tests with WooCommerce.

Load testing will simulate user actions and traffic load to your site.

Try it out

We do offer a 14-day refund guarantee on our plugins. Give them a go and we know if they don’t solve your negative stock issues!

Avatar photo
Morgan

I help eCommerce store owners to run their stores smoothly and get more sales. Let's discuss optimizing your store! Hit me up via the support page or on Twitter @morganhvidt

Leave a Reply

Your email address will not be published. Required fields are marked *