---
title: Configuration
date: 2026-06-13T16:02:00+01:00
author: John Henry Donovan
canonical_url: "https://johnhenry.ie/plugins/order-lifecycle/docs/getting-started/configuration"
section: Plugins
---
esc

↑↓ to navigate↵ to selectesc to close

Menu On this page 

- [Return to top](#)

Documentation

Documentation

# Configuration

Order Lifecycle is configured through the Craft control panel. Head to **Settings → Order Lifecycle** to adjust all the settings.

![](https://johnhenry.ie/images/plugins/docs/order-lifecycle/settings-overview.png)## Event Logging

These toggles control which event categories are recorded. All are enabled by default except "Log All Payment Transactions".

SettingDefaultDescriptionLog Line Item Changes`true`Cart line item additions, removals, and quantity updatesLog Order Status Changes`true`Order status transitionsLog Order Complete Event`true`When an order is marked as completeLog Order Paid Event`true`When an order is fully paidLog Email Sent Events`true`Order-related emails sent and failedLog Coupon/Discount Changes`true`Coupon codes applied or removedLog Address Changes`true`Shipping and billing address set or removedLog Customer Changes`true`Customer email set or removedLog Shipping Method Changes`true`Shipping method selected or changedLog Payment Attempts`true`Each payment attemptLog Payment Authorized`true`Payment authorization eventsLog Payment Captured`true`Payment capture eventsLog Payment Refunded`true`Refund eventsLog All Payment Transactions`false`Every individual transaction state change (high volume - off by default)

## Performance

SettingDefaultDescriptionAsync Queue Logging`false`Write log entries via the Craft queue instead of inline during the order save

By default every log entry is written synchronously inside Commerce's `afterSave` transaction. On a low-to-medium volume store you won't notice it at all. On a high-volume store - flash sales, lots of concurrent checkouts, large carts - it can add measurable latency to checkout.

If you're deploying to a busy or commercially important store, read the dedicated [Performance](https://johnhenry.ie/plugins/order-lifecycle/docs/getting-started/performance) guide before going live - it covers async logging, which event categories to disable, retention, and exactly what this plugin does and doesn't touch on the checkout path.

You can also set this in `config/order-lifecycle.php` to enforce it environment-by-environment:

```php
'asyncLogging' => App::env('QUEUE_LOGGING') === 'true',
```

## Data Collection

SettingDefaultDescriptionCollect User IP Address`true`Store the IP address of the user who triggered each eventCollect User ID`true`Store the logged-in user ID alongside each event

Turn these off to reduce the amount of personally identifiable information stored in logs, if you need to stay on the right side of GDPR or similar privacy regulations.

## Display

SettingDefaultDescriptionShow Lifecycle Statistics Widget`true`Show the statistics dashboard widget

## Log Pruning

SettingDefaultDescriptionAuto-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 trigger it manually via the console:

```php
php craft order-lifecycle/logs/purge --days=90
```

## Integrations

### Anthropic API Key

You'll need this to enable [AI Insights](http://localhost:5174/order-lifecycle/guide/ai-insights.html). Generate a key at [console.anthropic.com](https://console.anthropic.com/) and add it to your environment:

```bash
ANTHROPIC_API_KEY=sk-ant-...
```

Set the **Anthropic API Key** field in **Settings → Order Lifecycle → Integrations** to `$ANTHROPIC_API_KEY`, or configure it directly in `config/order-lifecycle.php`:

```php
'anthropicApiKey' => '$ANTHROPIC_API_KEY',
```

Once that's set, a **Generate insights** button appears in the Order Lifecycle field on every order, and the **Order Lifecycle AI Insights** dashboard widget becomes available. Leave the field blank if you'd rather switch off all AI features.

### Per-Order Insights Style

**Settings → Order Lifecycle → Integrations → Per-Order Insights Style** controls how a single order's AI analysis is presented: **Structured** (a priority-action callout plus labeled Action / Info / Good cards - the default) or **Narrative** (a plain markdown summary). This only affects per-order insights, not the store-wide dashboard widget. Set it in `config/order-lifecycle.php` with:

```php
'orderInsightsStyle' => 'structured', // or 'narrative'
```

### AI Prompt Customisation

The prompts sent to Claude can be overridden in **Settings → Order Lifecycle → Integrations → AI Prompt Customisation**. Each field takes free text with `{placeholder}` tokens that get swapped out for live data before the request goes off. Leave a field blank to fall back on the built-in default.

SettingDescriptionPer-Order Insights PromptPrompt used when the AI Insights button is clicked on an individual orderStore Insights PromptPrompt used by the dashboard AI Insights widget

Can also be set in `config/order-lifecycle.php`:

```php
'orderInsightsPrompt' => 'Your custom prompt with {total}, {eventTimeline}, etc.',
'storeInsightsPrompt' => 'Your custom store prompt with {days}, {conversionRate}, etc.',
```

See the [AI Insights guide](https://johnhenry.ie/plugins/order-lifecycle/docs/guide/ai-insights) for the full list of tokens available for each promp

## Console Commands

The plugin also gives you console commands for log management, independent of the CP settings:

```bash
# 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/optimize
```

## Garbage Collection

The plugin hooks into Craft's built-in garbage collection. When `php craft gc/run` executes, it automatically clears out lifecycle logs for orders that have been deleted or moved to trash. This shows up as:

```bash
> deleting orphaned order lifecycle logs ... done
```

This runs automatically alongside all the other Craft GC tasks, so there's nothing extra to configure.

Lifecycle logs are also removed straight away when an order is deleted (via Commerce's cart purge, manual deletion, or emptying the Craft trash). GC is just there as a safety net for anything that slips through.

On this page
