Wo WooCommerce Intermediate

DataFirefly Inventory Forecasting — Full guide

Install, configure and operate seasonal stock forecasting for WooCommerce: multiplicative Holt-Winters algorithm, multi-supplier management, native PDF purchase orders, imminent stockout alerts, four daily cron tasks and REST API.

Updated Module version 1.0.0

Overview

DataFirefly Inventory Forecasting is a WooCommerce plugin for stock prediction, automated supplier purchase order generation and stockout alerts. It turns your WordPress back office into a supply chain cockpit, without going through an external SaaS and without per-SKU fees.

The plugin relies on a multiplicative Holt-Winters algorithm that decomposes your sales history into two components: a trend estimated via linear regression on a seven-day moving average, and a seasonality computed as a monthly multiplicative index. Forecasts at 30, 60 and 90 days are then compared to current stock to produce a reorder point, a replenishment quantity (accounting for MOQ and pack size) and a stockout date estimate.

Positioning. Inventory Forecasting is designed as a self-hosted alternative to Veeqo, Cin7 or Lokad. It targets catalogues from 100 to a few thousand SKUs, with or without a stable seasonal history.

Prerequisites and installation

Technical prerequisites

  • WordPress 6.4 or higher
  • WooCommerce 8.0 or higher
  • PHP 8.1 or higher
  • MySQL 5.7 or MariaDB 10.3 minimum
  • WP-Cron enabled (or replaced by a system cron hitting wp-cron.php)

Installation

  1. Download the ZIP archive from your customer account on datafirefly.com.
  2. In WordPress, go to Plugins → Add New → Upload Plugin.
  3. Select the ZIP then click Install Now.
  4. Activate the plugin. On activation, it creates seven tables prefixed wp_dfif_, declares HPOS compatibility and schedules four daily cron tasks.

Post-install check. A new Inventory Forecasting menu appears in the admin sidebar, with a chart icon. Open the dashboard to confirm the KPI counters display at zero.

First run: rebuild history

The plugin needs to know your past sales to calibrate trend and seasonality indices. On first use, click Rebuild history from the dashboard. This walks through completed orders in the configured window (365 days by default) and aggregates sold quantities per product per day in the wp_dfif_sales_daily table.

On a catalogue of a few hundred products with 12 months of history, the operation takes one to five minutes. It is paginated by blocks of 100 orders and HPOS-compatible.

Core concepts

Trend and seasonality

On every forecast cycle, the plugin builds for each product a daily series smoothed by a seven-day moving average. A linear regression on this series gives the trend (slope and intercept). Separately, monthly seasonality indices are computed as the ratio between each calendar month’s sales and the annual average, floored at 0.3 and capped at 3.0 to absorb outliers.

The forecast at horizon H days then combines trend and target month index: forecast_sales = average_sales × (1 + trend × H) × seasonal_index.

Safety stock

Safety stock is computed with the classic formula z × σ × √lead_time, where z is the normal quantile matching the desired service level (1.645 for 95%, 2.326 for 99%), σ the standard deviation of daily sales and lead_time the supplier lead time in days. This buffer absorbs random demand variability during replenishment.

Reorder point and reorder quantity

The reorder point is the stock threshold that triggers an order. It equals average_sales × lead_time + safety_stock. In practice, as soon as current stock drops below this threshold, an order should be placed to avoid stockout.

The reorder quantity is the quantity to order. It is rounded to the pack size multiple, then raised to the MOQ (supplier minimum order quantity) if necessary.

Confidence score

Every forecast comes with a confidence score from 0 to 100%, computed heuristically from the length of the available history, sales regularity and the presence of strong seasonality. Confidence below 40% displays in red and automatically falls back to a naive (moving average) forecast, which is more conservative.

Supplier management

Create a supplier

From the Inventory Forecasting → Suppliers menu, click Add supplier. Fill in at minimum the name and email (used to send purchase orders). Optional fields are: contact person, phone, postal address, billing currency and internal notes.

On the WooCommerce product edit page, an Inventory Forecasting suppliers meta-box appears in the main column. It lets you add one or more suppliers for that product, each with their own parameters:

  • Purchase price excluding tax, used on the purchase order line
  • Supplier SKU, often different from the internal SKU, printed on the PDF
  • Lead time in days, entering the reorder point calculation
  • MOQ, minimum order quantity required by the supplier
  • Pack size, increment by which quantities are rounded
  • Primary supplier, radio button designating the supplier used by automatic purchase order generation

Multi-supplier. The same product can be linked to several suppliers, for example a cheaper primary and a fallback secondary. Only the primary is used by automatic generation, but you can switch manually to another from the product page.

Forecasts and horizons

The Inventory Forecasting → Forecasts page lists all products with, for each, the forecast at the selected horizon, the reorder point, the quantity to order, the estimated stockout date and the confidence level.

Filters

  • Horizon: 30, 60 or 90 days (all three are computed in parallel by the cron)
  • Severity: critical (stockout within 7 days), warning (stockout within 14 days), normal
  • Search: by product title or SKU

Manual recompute

The Recompute forecasts button on the dashboard forces an immediate cycle without waiting for the 2:30 cron. Useful after a parameter change (service level, history window size) or after a bulk order import.

Supplier purchase orders

Purchase order lifecycle

  1. Draft: created but not sent, editable
  2. Sent: PDF generated and emailed to the supplier
  3. Partially received: at least one line but not all quantities received
  4. Received: all quantities recorded
  5. Cancelled: order abandoned before reception

Manual generation

From Inventory Forecasting → Purchase orders, the Generate from forecasts button walks through products below reorder point, groups them by primary supplier and creates a draft purchase order per supplier. You can then edit quantities, add or remove lines, and send.

Automatic generation

The 4 a.m. cron can generate purchase orders automatically, with or without immediate sending. This option is disabled by default. Once enabled in settings, two modes are possible: draft creation (manual send after review) or immediate sending.

Recommendation. Keep automatic sending disabled for at least two weeks after installation. Verify forecast relevance before trusting full automation, otherwise you risk ordering too early or in excessive quantities.

Native PDF

The PDF is generated by an embedded pure-PHP engine (Helvetica font, A4 format, about 250 lines of code). It includes your company header, supplier contact details, the lines table with supplier SKU and purchase price, the ex-tax total, and a customisable footer. No Dompdf, TCPDF or mPDF dependency is required.

Goods receiving

On the purchase order detail view, every line has a Received quantity field. Entering the received value updates the WooCommerce stock of the product by the delta versus the previous value. This logic prevents double-counting if you correct a receipt after the fact.

Stockout alerts

The plugin detects four situation types daily and assigns each a severity level.

Alert types

  • IMMINENT: stockout expected within 7 days (configurable), critical severity
  • WARNING: stockout expected within 14 days (configurable), warning severity
  • OVERSTOCK: stock coverage above 180 days, info severity
  • REORDER: stock dropped below reorder point, warning severity

Lifecycle

An alert is created with status active. On the next cycle, if the situation persists, it is marked pending_recheck; if it has cleared, it moves to resolved with a timestamp. This mechanism prevents spammy repetitive alerts.

Email notifications

A daily digest is sent to the address configured in settings, listing new critical and warning alerts. The email body is a plain HTML table, filterable by severity.

Settings

The Inventory Forecasting → Settings page groups four sections.

Forecasts

  • History window: 365 days by default. The longer the window, the more robust seasonality, but the sales_daily table grows.
  • Forecast horizons: comma-separated list, 30, 60, 90 by default. You can add for example 14 or 180.
  • Service level: 95% by default. Translated to z = 1.645 through inverse normal. Move to 99% (z = 2.326) for critical stock, to 90% (z = 1.282) for non-strategic items.

Alerts

  • Warning anticipation days: 14 by default
  • Critical anticipation days: 7 by default
  • Daily digest recipient email

Purchase orders

  • Auto-generation enabled: unchecked by default
  • Numbering prefix: PO- by default, produces identifiers like PO-2026-00042
  • Currency: inherited from WooCommerce, overridable per supplier

Company

Your company details printed on purchase order PDF headers: legal name, address, VAT or tax number, email, phone, logo.

Cron tasks

Four tasks are scheduled automatically on plugin activation, in the site timezone.

  • 02:00History rebuild: aggregates the previous day’s orders into the sales_daily table. Light, a few seconds.
  • 02:30Forecast computation: recomputes trend, seasonality and reorder points. Heavier, one to five minutes depending on catalogue size.
  • 03:00Alert detection: creates and resolves alerts according to thresholds. Fast.
  • 04:00Automatic purchase order generation: runs only if the option is enabled in settings.

WP-Cron. By default, WP-Cron only fires on a visitor hit. On a low-traffic site, this can delay nightly tasks. Prefer configuring a system cron calling wp-cron.php every 15 minutes, or disable WP-Cron in wp-config.php and drive everything from a system cron.

REST API

The plugin exposes several REST routes under the dfif/v1 namespace. All require the manage_woocommerce capability and the WordPress wp_rest nonce.

POST /wp-json/dfif/v1/run-forecast
POST /wp-json/dfif/v1/rebuild-history
POST /wp-json/dfif/v1/detect-alerts
POST /wp-json/dfif/v1/generate-pos
POST /wp-json/dfif/v1/send-po/{id}
POST /wp-json/dfif/v1/po/{id}/items/{item_id}/receive
GET  /wp-json/dfif/v1/stats

These routes are used internally by the dashboard buttons (via wp.apiFetch with X-WP-Nonce header) and can also be called from any client authenticated via WordPress cookies or application passwords.

WordPress hooks

The main steps of the plugin emit actions and filters you can intercept:

do_action('dfif_forecast_calculated', $product_id, $forecast_data);
do_action('dfif_purchase_order_created', $po_id, $supplier_id);
do_action('dfif_purchase_order_sent', $po_id);
do_action('dfif_alert_triggered', $alert_id, $alert_type);
apply_filters('dfif_reorder_qty', $qty, $product_id, $supplier_id);
apply_filters('dfif_pdf_company_info', $info);

Troubleshooting

Forecasts stay at zero

Check that history rebuild has been run and that the sales_daily table contains rows. If you have no completed or processing orders in the configured window, the plugin cannot predict anything. Also verify that WooCommerce is active.

Forecasts look inconsistent

Two frequent causes: too short a history (below 30 days, the plugin falls back to a naive forecast) or extreme, unrepresentative seasonality (isolated Black Friday). Look at the displayed confidence: below 40%, the forecast should be treated with caution.

PDF is not generated

Verify that the wp-content/uploads/dfif-po/ directory is writable. The plugin drops PDFs there before sending. An .htaccess file is deposited automatically to prevent direct public access.

Email is not sent

The plugin uses wp_mail, which is sometimes unreliable on certain hosts. Install an SMTP plugin (WP Mail SMTP, FluentSMTP) and configure a deliverability service (Postmark, SendGrid, Mailjet, Brevo). Also check that the supplier email is entered and valid.

Cron is not running

Use the WP Crontrol plugin to list scheduled hooks and see their next execution. The four hooks are prefixed dfif_. If you don’t see them, deactivate and reactivate Inventory Forecasting.

Uninstall

On deactivation, crons are unscheduled but tables and data are preserved. On full uninstall via Plugins → Delete, two behaviours are possible depending on the dfif_delete_data_on_uninstall option in settings:

  • Unchecked by default: tables are preserved, you can reinstall without losing history.
  • Checked: the seven tables and the wp-content/uploads/dfif-po/ directory are deleted.

FAQ

Can I use the plugin on a variable catalogue (product variations)?

Yes. Forecasts and purchase orders operate at the individual variation level. Each variation can have its own suppliers and its own parameters.

Is the plugin multisite-compatible?

Yes, but each site in the network manages its own catalogue, suppliers and forecasts. There is no cross-site pooling.

Can I export the data?

All tables are accessible via standard SQL. A native CSV export is planned for a future version. In the meantime, a simple SELECT INTO OUTFILE or a plugin like WP All Export will do.

Does the plugin block the admin if cron hasn’t run?

No. The plugin always works, forecasts displayed may simply be a few days old. A Last cron badge on the dashboard indicates data freshness.

How does the plugin behave on a catalogue of several thousand SKUs?

History rebuild and forecast computation remain linear in the number of active products. On 5,000 SKUs with 12 months of history, expect 10 to 30 minutes of nightly processing depending on server power. No front-office performance impact: all computations are asynchronous.

Was this page helpful?

Still stuck? Contact support