Low Stock Alerts for OpenCart 4 and 3: Email the Owner Before Products Run Out (Free Extension)
A free extension that emails store owners when products and options run low after an order, with a daily report and a low-stock list in the admin.

The first time most store owners notice a product ran out is when a customer emails to ask where their order is, or when sales of a best seller quietly drop to zero. OpenCart tracks stock for every product and option, but it never tells you when something is running low. You have to remember to check.
Low Stock Alerts is a free extension that sends you an email when an order takes a product or option down to your threshold, and a daily report of everything that’s low. The settings page also lists what’s low right now, with a link to edit each product. It comes in builds for OpenCart 4.1.0.4 and OpenCart 3.0.5.1, and we tested both with real orders and a mail catcher.
Download Low Stock Alerts
- OpenCart 4.1.0.4: stockalert.ocmod.zip for OpenCart 4
- OpenCart 3.0.5.1: stockalert.ocmod.zip for OpenCart 3

This is for you, the store owner. If you want to show shoppers an “Only 3 left” message on the product page, that’s a different extension: see our low-stock message for OpenCart 4.
What it does
- An email after each order. When an order’s status changes, the extension checks the products in that order. Anything at or below your threshold that wasn’t reported yet goes into one email.
- Options count too. A T-shirt can have 40 in stock overall and 0 left in Medium. With Check option quantities on, each size or color with Subtract Stock set to Yes is checked separately.
- No repeated emails. Each item is reported once. It alerts again only after you restock it above the threshold and it drops again.
- A daily report. A secret URL sends a list of everything that’s low. Add it to your server’s cron once and get the report every morning.
- A low-stock list in the admin. The settings page shows every item that’s low right now, when the alert was sent, and an edit button.
- Several recipients. Send alerts to the owner and the person who orders stock, or leave it empty to use the store email.
Install in OpenCart 4
- Go to Extensions > Installer, upload
stockalert.ocmod.zipand click the green +. - Go to Extensions > Extensions, choose Modules, and install Low Stock Alerts.
- Click the pencil, turn Status on, set the threshold and recipients, and save.
- Make sure store email works in System > Settings > your store > Mail. If no mail engine is set, the settings page shows a warning, because no alerts can be sent.
Install in OpenCart 3
- Go to Extensions > Installer and upload
stockalert.ocmod.zip. No modification refresh is needed. - Go to Extensions > Extensions, choose Modules, and install Low Stock Alerts.
- Edit it, set Status to Enabled, fill in the threshold and recipients, and click Save.
Settings

- Alert at or below: an item is low when its quantity is this number or less. 0 means out of stock only. The default is 5.
- Check option quantities: also check option values like sizes and colors.
- Email after each order: the instant alert.
- Daily report: allows the report URL to send the full list.
- Send alerts to: comma-separated addresses. Each one is checked when you save.
- Daily report URL: created when you install the extension, with a random 32-character key. Click Send now to test it. To get it every morning at 8:00, add the line shown under it to your crontab, for example in cPanel > Cron Jobs.
Only products with Subtract Stock set to Yes and Status enabled are checked. Products you don’t track, like downloads or services, never trigger alerts.
What we tested
We used a threshold of 5 and two recipients. The demo Canon EOS 5D had 7 in stock, with its required Select option at 2 for Red and 5 for Blue. We placed an order for two Canons in Blue and moved it to Processing in the admin.
- OpenCart subtracted the stock: the Canon went to 5 and Blue to 3. One email, “Low stock: 3 item(s) after order #900026”, went to each recipient, listing Red (2), Blue (3) and the Canon itself (5).
- Moving the same order to Complete sent nothing new, because all three were already reported.
- Opening the report URL with a wrong key returned 403 Forbidden. With the right key it answered “Sent the low-stock report: 8 item(s).” and emailed the full list.
- Canceling the order put the stock back. The Canon went to 7, above the threshold, so its “already reported” mark was cleared automatically. Blue went back to exactly 5, which is still at the threshold, so it stayed on the list.
The OpenCart 3.0.5.1 build behaved the same with the same order.


How it works
OpenCart subtracts stock inside addHistory() in OpenCart 4, or addOrderHistory() in OpenCart 3, when an order moves into a processing or complete status. The extension listens right after that step, with one event per version. Admin status changes go through the same model, so they’re covered too. It only looks at the products in that order and skips anything already reported:
$threshold = (int)$this->config->get('module_stockalert_threshold');
$this->load->model('extension/stockalert/module/stockalert');
$this->model_extension_stockalert_module_stockalert->clearRestocked($threshold);
$low = $this->model_extension_stockalert_module_stockalert->getLowStock($threshold, array_unique($product_ids), (bool)$this->config->get('module_stockalert_options'));
// Only items that weren't reported yet
$new = array_diff_key($low, $this->model_extension_stockalert_module_stockalert->getAlerted());
if ($new && $this->send($new, $order_id)) {
$this->model_extension_stockalert_module_stockalert->addAlerted($new);
}
The “already reported” list is a small table. Before each check, rows for items that are back above the threshold are removed:
public function clearRestocked(int $threshold): void {
$this->db->query("DELETE s FROM `" . DB_PREFIX . "stockalert` s LEFT JOIN `" . DB_PREFIX . "product` p ON (p.`product_id` = s.`product_id`) WHERE s.`product_option_value_id` = '0' AND (p.`product_id` IS NULL OR p.`quantity` > '" . $threshold . "')");
$this->db->query("DELETE s FROM `" . DB_PREFIX . "stockalert` s LEFT JOIN `" . DB_PREFIX . "product_option_value` pov ON (pov.`product_option_value_id` = s.`product_option_value_id`) WHERE s.`product_option_value_id` > '0' AND (pov.`product_option_value_id` IS NULL OR pov.`quantity` > '" . $threshold . "')");
}
The daily report URL compares its key with hash_equals(), and calling the event method as a URL does nothing, because it needs an order ID that only the event provides.
Two things we found along the way
OpenCart 4.1.0.4’s own cron doesn’t run. OpenCart 4 has a cron system, but in 4.1.0.4 cron.php fails with “Class Twig\Loader\FilesystemLoader not found”. That’s why the daily report uses a plain URL that your server’s cron or any uptime pinger can call. It works the same on OpenCart 3.
A broken mail setup can block order updates. While testing with a local mail catcher, we left the SMTP password empty. OpenCart’s SMTP library threw “SMTP password required!”, and because the core order email doesn’t catch errors, the whole status change failed and no history was saved. Low Stock Alerts catches its own mail errors and writes them to the error log, so a mail problem never stops an order. Still, if order statuses won’t save on your store, check System > Settings > Mail first.
What’s different in the OpenCart 3 build

- The report URL is
index.php?route=extension/module/stockalert/digest&key=.... In OpenCart 4 it’sindex.php?route=extension/stockalert/module/stockalert.digest&key=.... - The event is
catalog/model/checkout/order/addOrderHistory/after. - The code avoids PHP 8-only syntax, because many OpenCart 3 stores still run older PHP. We tested it on PHP 8.2.
Why the email has no edit links
We first added an Edit link next to each product in the email. In testing, OpenCart 4.1.0.4 always sent us to the dashboard after login instead of the product, because admin links need a session token. So the email lists the product name, option and model, and the edit buttons live in the admin list, where they work.
Related posts
- Inventory on autopilot: reorder points, back-in-stock alerts and returns
- “Only 3 left in stock” message for OpenCart 4
- Out-of-Stock Products Last in OpenCart 4
- OpenCart events by examples
Please let us know if you have any questions or suggestions, and subscribe to our YouTube channel for more OpenCart video tutorials. You can also find us on Twitter and Facebook.







