WooCommerce

WooCommerce Analytics Showing Zero: The Lookup Table Sync

Orders exist, revenue reports say zero. How WooCommerce Analytics builds its numbers from lookup tables, why the sync stops, and how to re-import safely.

5 min read
WooCommerceAnalyticsDebugging
914 words5 min read

The symptom

WooCommerce, Analytics, Revenue shows zero for last month. Or the numbers are a fraction of what the Orders screen plainly shows. Or the dashboard's "performance" tiles are stuck at a date weeks ago. The orders are real and paid. The reports do not see them.

This is not a data loss. WooCommerce Analytics does not read the orders directly; it reads a set of summary tables that are populated from the orders by a background process, and that process has stopped or fallen behind.

How Analytics gets its numbers

The Analytics screens query lookup tables: wp_wc_order_stats, wp_wc_order_product_lookup, wp_wc_order_tax_lookup, wp_wc_order_coupon_lookup, wp_wc_customer_lookup. Each order, when created or changed, schedules an action (via Action Scheduler) that writes or updates its row in those tables. Reports aggregate the tables, which is fast even for a large store.

So the chain is: order changes → action scheduled → Action Scheduler runs it → lookup row written → report reads it. Zero in the report means a break somewhere after the order.

Why the sync stops

Action Scheduler is not running. The most common cause by far. If the queue is stalled (usually because WP-Cron is not firing on a cached site and no server cron replaces it), the wc-admin_import_orders actions pile up as pending and no lookup rows are written. The Orders screen is fine; Analytics is frozen at the moment the queue stopped.

The queue is running but overwhelmed. A busy store or a bulk import queues thousands of import actions; the runner processes a few dozen per minute; Analytics lags by hours or days.

Import actions failing. A plugin conflict or a corrupt order causes the import action to error; Action Scheduler retries then marks it failed; that order never appears.

The tables were never populated. A store migrated from another platform, or one where Analytics was disabled and re-enabled, has orders with no lookup rows and nothing scheduled to create them.

Order status excluded. Analytics settings let you exclude statuses (for instance, pending or on-hold). If orders sit in an excluded status because of a separate gateway problem, they are not counted, correctly.

Date range or caching. The reports cache aggressively; a stale cache after a re-import shows old numbers until cleared. And a date range set to "last month" on the first of the month is a classic misread.

HPOS sync. Stores mid-migration to High-Performance Order Storage with sync enabled can have lookup imports reading from the table the data is not in yet, depending on version. Recent versions handle it; older ones did not.

Diagnosing in five minutes

  1. WooCommerce, Status, Scheduled Actions. Filter by hook wc-admin_import_orders. Pending or past-due in the hundreds or thousands: the queue is the problem. Failed: open one and read the log.
  2. WooCommerce, Analytics, Settings. Scroll to "Import historical data". The status line shows whether an import is running and when the last completed. Check the excluded statuses list.
  3. A quick query, on staging or read-only:
SQL
SELECT COUNT(*) FROM wp_wc_order_stats;
SELECT COUNT(*) FROM wp_wc_orders WHERE status IN ('wc-processing','wc-completed');
-- or wp_posts WHERE post_type='shop_order' on non-HPOS stores

If the second is much larger than the first, orders are missing from the lookup. 4. Site Health, Info, WooCommerce, for the Action Scheduler and cron status.

Fixing it

Get the queue running. If Action Scheduler is stalled, the fix is the server cron: DISABLE_WP_CRON in wp-config.php and a system cron running wp action-scheduler run every minute. Once it runs, the pending imports process and the reports fill in on their own, possibly over a few hours for a large backlog.

Re-import historical data. Analytics, Settings, Import historical data. Choose a date range (or all), tick "skip previously imported" if you only need gaps filled, and start. This queues import actions for every order in range. With the queue healthy, a store with ten thousand orders imports in an hour or two. Do it at a quiet time; it is database-heavy.

Clear the report cache. Analytics caches report results in transients. After a re-import, WooCommerce, Status, Tools, "Clear Analytics cache" (or clear transients) so the reports read fresh.

Fix failed imports. If specific orders fail repeatedly, open the failed action's log. Typical causes: an order referencing a deleted product or customer in a way a plugin's hook does not handle; a corrupt meta value. Fix the order or exclude it, then re-import.

Check excluded statuses. If orders are stuck in on-hold because the gateway webhook is failing, fix the gateway; Analytics is correctly reporting that they are not complete.

Keeping it healthy

  • A server cron for Action Scheduler, always. It is the fix for this problem and for late emails and stalled renewals, which are the same queue.
  • A monthly glance at Scheduled Actions for anything past due.
  • After any bulk order operation (import, migration, mass status change), expect the import queue to spike and let it drain before trusting the reports.
  • After an HPOS migration, run a historical re-import to be sure.

Where this sits

Analytics showing zero is a symptom we see on most stores that arrive without maintenance, and the cause is almost always the queue. Setting up the cron and running the re-import is part of onboarding a store onto a care plan, and the Scheduled Actions screen is the second thing we open in any WooCommerce diagnosis, because so many "WooCommerce is broken" reports are one stalled queue wearing different symptoms.

All writingHire me for this