Stockout Prevention with Automated Alerts for Ecommerce Teams
A low-stock threshold set in units is wrong for most of a catalogue. In a public dataset of 3796 products, 10 units meant anything from 1 day of stock to a year. Set the threshold from recent sales and supplier lead time, and the same number drives reorder alerts, restock and pre-order notices and the weekly inventory report, on any platform.
A low-stock alert fires when a product falls below a number someone typed in once, and for most of a catalogue that number is wrong. In a public record of a real online shop’s sales, a threshold of 10 units meant less than a day of stock for its best sellers and a month or more for a third of its range.
Every major shop platform asks for the threshold as a number of units and leaves it to you to choose. The fix is to stop choosing it by hand: work it out each week from what the product sold recently and how long the supplier takes to deliver. That one number then does four jobs: it tells you when to reorder, how much to order, what to tell customers while a product is out, and what goes in the weekly stock report. This post is for the person in a small or mid-sized shop who places the purchase orders and finds out about stockouts from customers.
One threshold in units fits almost nothing in a real catalogue
The evidence comes from the Online Retail II dataset published by the UC Irvine Machine Learning Repository: every transaction of a UK online retailer of gift-ware between December 2009 and December 2011, about a million order lines, many of them from wholesale buyers. It is real trading data, released under CC BY 4.0. It has no stock levels in it, so it shows the demand side only, which is the side the threshold has to match.
Taking the sales from 1 January to 30 November 2011, net of cancelled orders, and averaging each product’s sales per day over those 334 calendar days gives 3796 products that sold at least one unit. The table below turns a 10-unit threshold into what it means for each of them: days of stock left when the alert fires. Every figure in this post can be reproduced with this Python script and the dataset.
| Products, ranked by that number | Days of stock 10 units represents |
|---|---|
| Fastest 10% | 1.1 or less |
| Fastest 25% | 2.6 or less |
| Median product | 10.0 |
| Slowest 25% | 65.5 or more |
| Slowest 10% | 371.1 or more |
So for 9.3% of the range the alert fires with a day or less of stock left, which is too late for almost any supplier. For 33.6% it fires with a month or more left, so it is noise, and a team that gets noise learns to ignore the channel. The best seller in this period, a popcorn holder (stock code 22197), sold an average of 142 a day; 10 units is less than two hours of its average sales.
Sales also move with the season, so a threshold that was right in February is wrong by November. This shop sold 2.63 times as many units in November 2011 as in February. Of the 1898 products that sold in both months, 786 (41.4%) sold at least twice as fast per day in November. The extreme case is a Christmas paper chain kit (22086), which sold 0.2 a day in the 28 days to 28 February and 269 a day in the 28 days to 30 November.
Wholesale buyers make demand lumpy as well. Across the 50 best sellers, the largest single order line was a median 14.1 times the product’s average daily sales. The dataset also holds a warning about bad inputs: on 18 January 2011 one customer ordered 74,215 ceramic storage jars (23166) and the order was cancelled 16 minutes later. Count that order without its cancellation and that jar becomes the shop’s best seller for the period.
The threshold should come from lead time and recent sales
The standard answer is the reorder point. In the Curtin University supply chain lecture notes (Wiwatanapataphee, June 2026), for uncertain demand and a fixed lead time:
- reorder point = average daily demand × lead time in days + safety stock
- safety stock = z × the standard deviation of daily demand × √(lead time)
where z sets the service level: 1.645 for 95%, meaning stock runs out in about one replenishment cycle in 20. Wikipedia’s reorder point article gives a general form that also allows for a lead time that varies; when it does not vary, the two are the same. The notes state the assumptions, and they matter: demand roughly normal and lead time fixed. Neither holds for lumpy wholesale demand, so treat the result as a better starting point than a typed-in number, not as a guarantee.
The reorder point is in units, but it is calculated from days, which is the point. With a 14-day lead time, a magazine rack in the dataset (22781) that sold about 2 a day gets a reorder point of 43 units. The paper chain kit, in November, gets thousands.
Step 1: work out the sales rate from an order export
Every platform can export order lines. This function takes them with a SKU, a timestamp and a quantity, with cancellations as negative quantities, and returns each SKU’s average daily sales and spread over the last 28 days. Days with no sales count as zero, which is the mistake that most often inflates a rate.
import pandas as pd
def daily_rates(orders: pd.DataFrame, end: str, days: int = 28) -> pd.DataFrame:
"""Average units sold per day, and the spread, for each SKU over the last `days` days.
`orders` has one row per order line: sku, date, quantity (cancellations negative)."""
first = pd.Timestamp(end) - pd.Timedelta(days=days - 1)
calendar = pd.date_range(first, periods=days, freq="D")
window = orders[(orders.date >= first) & (orders.date < calendar[-1] + pd.Timedelta(days=1))]
daily = (
window.assign(day=window.date.dt.normalize())
.groupby(["sku", "day"]).quantity.sum()
.unstack(fill_value=0)
.reindex(columns=calendar, fill_value=0) # days with no sales count as zero
)
return pd.DataFrame({"per_day": daily.mean(axis=1), "sd": daily.std(axis=1)})The 28-day window is a choice, not a law. It is short enough to catch the seasonal swing above and long enough not to chase a single wholesale order. It is also the window Shopify uses for its own days of inventory remaining report, so the numbers line up with what a Shopify merchant already sees.
Step 2: turn the rate into a reorder point and a status
def reorder_point(per_day: float, sd: float, lead_days: int, z: float = 1.645) -> float:
"""Demand during the supplier's lead time, plus safety stock (z = 1.645 for 95%)."""
return per_day * lead_days + z * sd * lead_days ** 0.5
def stock_status(on_hand: int, on_order: int, per_day: float, rop: float) -> dict:
cover = on_hand / per_day if per_day > 0 else float("inf")
if on_hand <= 0:
status = "out"
elif on_hand + on_order <= rop:
status = "reorder"
else:
status = "ok"
return {"status": status, "days_of_cover": round(cover, 1)}Stock already on order counts towards the reorder point, so a product with a purchase order on the way does not keep firing. Run on the Online Retail II sales for the 28 days to 30 November 2011, with a 14-day lead time chosen for illustration (the dataset has no supplier data), the paper chain kit’s reorder point is 5303 units. Run on the 28 days to 28 February, it is 6. A threshold typed in during February would have caught nothing in the season that mattered.
One number drives four jobs
flowchart LR
O[Order export] --> R[Daily sales rate]
L[Supplier lead time] --> P[Reorder point]
R --> P
S[Stock on hand and on order] --> C{Status}
P --> C
C -->|reorder| A[Alert to buyer with order quantity]
C -->|out, PO open| B[Pre-order with arrival date]
C -->|back in| N[Back in stock email]
C --> W[Weekly stock report]
Reorder alerts. The alert goes to the person who places purchase orders, and it carries the numbers they need to act: stock on hand, stock on order, the daily rate, days of cover and the supplier’s lead time. It also suggests a quantity, for example enough to cover the lead time plus the time until the next order, minus what is in hand and on order. Send it once per product per incident, not every time an order lands.
Restock and pre-order notifications. When a product is out but a purchase order with a delivery date is open, the shop can keep selling it as a pre-order and show that date, instead of a dead “sold out” page. When stock arrives, the customers who asked to be told get an email. Both depend on the same status: “out, with stock on order” is a different message from “out, nothing coming”.
The weekly inventory report. One table, sorted by days of cover against lead time: what must be ordered this week, what is out and when it returns, and what is not moving. The slow end deserves a line too. In the dataset above, a third of the products would have taken a month or more to sell 10 units, and that is cash sitting on a shelf.
What each platform does without an app, and what it leaves to you
All four platforms below can warn you about low stock, report on stock and let you sell out-of-stock products. None of them sets the threshold for you from lead time and recent sales. Checked against each vendor’s documentation on 15 November 2026:
| Low-stock warning | Back-in-stock email to customers | Selling while out of stock | Stock report | |
|---|---|---|---|---|
| Shopify | No built-in low-stock email found in its help centre; the free Shopify Flow app (Basic, Grow, Advanced and Plus plans) has a trigger that fires when a variant’s inventory changes | Not built in; apps | ”Continue selling when out of stock”, which Shopify lists for pre-orders | Days of inventory remaining, ABC analysis, sell-through |
| WooCommerce | Low-stock and out-of-stock thresholds with email | Paid extension; a core version was “early alpha” in the 10.9 beta of June 2026 | Backorders, with a notification email | Stock report filtered by low, out and on backorder |
| BigCommerce | Low stock level with an email warning | Not checked | Pre-order settings, listed in its developer documentation | Not checked |
| Adobe Commerce (Magento) | “Notify for Quantity Below” | Built in, as product alerts | Backorders, optionally telling the customer | Low Stock report |
Shopify comes closest to the method above, because its report already divides stock by a 28-day sales rate. However, it is a report rather than an alert, and it does not know your supplier’s lead time, so it cannot tell you that 20 days of cover is too little for a supplier who takes 30.
So the practical split is the same on every platform. The platform keeps the stock count, takes pre-orders and sends the customer emails it supports. A small scheduled script reads orders and stock through the platform’s export or API, works out the rates and reorder points, sends the buyer’s alert and writes the weekly report. Only the export and the write-back differ between platforms; the arithmetic stays the same.
Where the method falls short
The dataset shows demand, not stock, so it cannot show how many stockouts this shop actually had or how many a reorder point would have prevented. Nobody should read the figures above as a measured saving. The 14-day lead time is an illustration. The normal-demand assumption behind safety stock is weak for a shop where one order line can be 14 times an average day, and for those products a minimum order quantity or a manual review of large orders matters more than the formula. Finally, a new product has no 28 days of history, so it needs a hand-set threshold until it has.
Start with your own export
Export the last 28 days of order lines and a stock count, run the two functions above with your real supplier lead times, and compare each product’s reorder point with the threshold currently set on your platform. If your catalogue looks anything like the one above, where 10 units ranged from a day of stock to a year, most of those settings will be wrong in one direction or the other. Then run it weekly through the season and watch two numbers: alerts per week, which should be few enough that each one is read, and products that still ran out.
Enjoyed this article?
Get notified when I publish new articles on automation, ecommerce, and data engineering.
Get in touch