Skip to main content

Advanced Reports & Analytics

Goal​

Report on sales, customers and inventory beyond what WooCommerce shows by default, keep periodic snapshots so trends survive, export a report, and email one on a schedule.

Tier and entitlement​

FieldValue
TierPremium
Entitlement keyreporting
Admin tabreporting
Module keyreporting
Settings prefixaiowc_rep_

Hooks register only when aiowc_module_enabled_reporting is true and the licence permits the reporting entitlement.

Reports​

Three services produce the figures: SalesReportService, CustomerReportService and InventoryReportService. The export layer recognises eleven report types:

GroupReport types
Salessales_overview, revenue_by_period, top_products, top_categories
Customersnew_customers, customer_ltv, customer_segments
Inventorylow_stock, out_of_stock, stock_value, stock_movement

The sales and customer endpoints take a start_date, an end_date and a group_by; the inventory endpoint takes a stock threshold.

Export formats — what actually happens​

Service/ExportService.php builds an HTML table for the chosen report, then:

  • If the TCPDF class is available, it renders a landscape A4 PDF from that HTML.
  • If it is not, it returns the HTML itself, for the client to print to PDF.

TCPDF is not a dependency of this plugin. It is absent from composer.json and from the vendor tree, and the module manifest records the gap as missing classes: TCPDF. So on a stock install a PDF export returns printable HTML, not a PDF file. A site that installs TCPDF independently gets the PDF path.

Settings​

Read through ModuleSettings with the aiowc_rep_ prefix; defaults are ReportingModule::DEFAULTS.

SettingDefaultMeaning
snapshot_frequencydailyHow often a snapshot is taken
email_reportsfalseWhether scheduled report emails are sent
default_date_range30Days a report covers when no range is given
currency_displaysymbolWhether amounts show a currency symbol or a code
cleanup_days90Age at which report working data is pruned
snapshot_retention365Days snapshots are kept

Admin screen​

Admin tab reporting. It shows the sales, customer and inventory reports over a chosen date range, manages email schedules, and carries the settings form.

The module also contributes a Store Overview card to the WordPress dashboard, registered through the plugin's shared DashboardCardRegistry. The registry owns the wp_dashboard_setup hook and the capability gate; the module supplies only the card.

Database schema​

Created by Schema/DatabaseSchema.php at schema version 1.0.0.

TableHolds
{prefix}aiowc_report_snapshotsPeriodic snapshots of report figures
{prefix}aiowc_report_schedulesScheduled report emails: type, frequency, recipients and format

REST endpoints​

Namespace aiowc/v1. All responses use the shared envelope.

Reports​

Permission: view.

MethodPathPurposeRequired args
GET/reporting/salesSales figures over start_date–end_date, grouped by group_by—
GET/reporting/customersCustomer figures over the same parameters—
GET/reporting/inventoryInventory figures at a stock threshold—

Export and schedules​

Permission: manage.

MethodPathPurposeRequired args
GET/reporting/exportExport one report_type in a format, over an optional date rangereport_type
GET/reporting/schedulesList email schedules—
POST/reporting/schedulesCreate a schedule; also accepts frequency and formatreport_type, recipients
DELETE/reporting/schedules/{id}Delete a schedule—
GET/reporting/settingsRead settings—
PUT / PATCH / POST/reporting/settingsUpdate settings—

There is no endpoint to update an existing schedule; a change means deleting and recreating it.

WooCommerce and WordPress integration​

The module registers no storefront hook, no shortcode and no block. It reads WooCommerce order and product data through the report services and contributes the dashboard card described above.

Background jobs​

All three run through Action Scheduler in the aiowc group, on fixed intervals defined as constants in the jobs rather than as settings.

HookIntervalPurpose
aiowc_report_snapshot6 hours (21,600s)Writes a snapshot row
aiowc_report_email1 hour (3,600s)Sends due scheduled reports
aiowc_report_cleanup24 hours (86,400s)Prunes snapshots and working data past their retention

The snapshot_frequency setting describes the intended cadence; the snapshot job's own recurrence is the fixed 6-hour interval above.

Entitlement limits​

The reporting entitlement gates the module as a whole. No cap on report runs, schedules or snapshot rows is implemented in the module's code; retention is governed by cleanup_days and snapshot_retention.