Configuration beta
Order Lifecycle is configured via the Craft control panel. Navigate to Settings → Order Lifecycle to adjust all settings.
Event Logging
These toggles control which event categories are recorded. All are enabled by default except "Log All Payment Transactions".
| Setting | Default | Description |
|---|---|---|
| Log Line Item Changes | true | Cart line item additions, removals, and quantity updates |
| Log Order Status Changes | true | Order status transitions |
| Log Order Complete Event | true | When an order is marked as complete |
| Log Order Paid Event | true | When an order is fully paid |
| Log Email Sent Events | true | Order-related emails sent and failed |
| Log Coupon/Discount Changes | true | Coupon codes applied or removed |
| Log Address Changes | true | Shipping and billing address set or removed |
| Log Customer Changes | true | Customer email set or removed |
| Log Shipping Method Changes | true | Shipping method selected or changed |
| Log Payment Attempts | true | Each payment attempt |
| Log Payment Authorized | true | Payment authorization events |
| Log Payment Captured | true | Payment capture events |
| Log Payment Refunded | true | Refund events |
| Log All Payment Transactions | false | Every individual transaction state change (high volume - off by default) |
Performance
| Setting | Default | Description |
|---|---|---|
| Async Queue Logging | false | Write log entries via the Craft queue instead of inline during the order save |
When to enable async logging
By default every log entry is written synchronously inside Commerce's afterSave transaction. On a low-to-medium volume store this is imperceptible. On a high-volume store - flash sales, high concurrent checkout - this adds measurable latency to every order save.
Enabling Async Queue Logging moves the DB INSERT out of the request cycle entirely. The snapshot and change description are still computed synchronously (they are fast, in-memory operations), then a lightweight queue job handles the write.
Requirements before enabling:
- Your Craft queue worker must be running continuously (
php craft queue/listenor a supervisor process). If the queue stalls, logs will be delayed or lost. - Do not enable this on development environments where queues are not processed automatically - logs will appear to be missing.
Can also be set in config/order-lifecycle.php to enforce it environment-by-environment:
'asyncLogging' => App::env('QUEUE_LOGGING') === 'true',Data Collection
| Setting | Default | Description |
|---|---|---|
| Collect User IP Address | true | Store the IP address of the user who triggered each event |
| Collect User ID | true | Store the logged-in user ID alongside each event |
Disable these settings to reduce personally identifiable information stored in logs, in compliance with GDPR or similar privacy regulations.
Display
| Setting | Default | Description |
|---|---|---|
| Show Lifecycle Statistics Widget | true | Show the statistics dashboard widget |
Log Pruning
| Setting | Default | Description |
|---|---|---|
| Auto-Prune Logs After (Days) | 0 | Automatically delete logs older than this many days. 0 disables pruning. Maximum 365. |
Pruning runs on the next request after midnight. You can also run it manually via the console:
php craft order-lifecycle/logs/purge --days=90Integrations
Anthropic API Key
Required to enable AI Insights. Generate a key at console.anthropic.com and add it to your environment:
ANTHROPIC_API_KEY=sk-ant-...Set the Anthropic API Key field in Settings → Order Lifecycle → Integrations to $ANTHROPIC_API_KEY, or configure it in config/order-lifecycle.php:
'anthropicApiKey' => '$ANTHROPIC_API_KEY',When configured, an AI Insights button appears in the Order Lifecycle field on every order, and the Order Lifecycle AI Insights dashboard widget becomes available. Leave this blank to disable all AI features.
AI Prompt Customisation
The prompts sent to Claude can be overridden in Settings → Order Lifecycle → Integrations → AI Prompt Customisation. Each field accepts free text with {placeholder} tokens that are substituted with live data before the request is sent. Leave a field blank to use the built-in default.
| Setting | Description |
|---|---|
| Per-Order Insights Prompt | Prompt used when the AI Insights button is clicked on an individual order |
| Store Insights Prompt | Prompt used by the dashboard AI Insights widget |
Can also be set in config/order-lifecycle.php:
'orderInsightsPrompt' => 'Your custom prompt with {total}, {eventTimeline}, etc.',
'storeInsightsPrompt' => 'Your custom store prompt with {days}, {conversionRate}, etc.',See the AI Insights guide for the full list of available tokens for each prompt.
Console Commands
The plugin provides console commands for log management independent of the CP settings:
# Delete logs older than 90 days
php craft order-lifecycle/logs/purge --days=90
# Dry run (shows count without deleting)
php craft order-lifecycle/logs/purge --days=90 --dry-run
# Delete logs for orders that no longer exist (deleted or trashed)
php craft order-lifecycle/logs/purge-orphaned
# Dry run orphan cleanup
php craft order-lifecycle/logs/purge-orphaned --dry-run
# Show log statistics
php craft order-lifecycle/logs/stats
# Optimise the logs database table
php craft order-lifecycle/logs/optimizeGarbage Collection
The plugin integrates with Craft's built-in garbage collection. When php craft gc/run executes, the plugin automatically removes lifecycle logs for orders that have been deleted or moved to trash. This appears as:
> deleting orphaned order lifecycle logs ... doneThis runs automatically alongside all other Craft GC tasks. No additional configuration is needed.
Lifecycle logs are also removed immediately when an order is deleted (via Commerce's cart purge, manual deletion, or emptying the Craft trash). GC serves as a safety net for any that are missed.