# @pinelab/vendure-plugin-order-cleanup

> [Official documentation here](https://plugins.pinelab.studio/plugin/vendure-plugin-order-cleanup)

Latest version **2.0.0** (published 2026-09-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pinelab/vendure-plugin-order-cleanup
pnpm add @pinelab/vendure-plugin-order-cleanup
yarn add @pinelab/vendure-plugin-order-cleanup
bun add @pinelab/vendure-plugin-order-cleanup
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-09-24 |
| First published | 2025-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 26.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 138 |
| Author | Martijn van de Brug |
| Maintainers | mbrug |

## Links

- npm: https://www.npmjs.com/package/@pinelab/vendure-plugin-order-cleanup
- Repository: https://github.com/Pinelab-studio/pinelab-vendure-plugins
- Homepage: https://github.com/Pinelab-studio/pinelab-vendure-plugins#readme
- Issues: https://github.com/Pinelab-studio/pinelab-vendure-plugins/issues
- npm.io page: https://npm.io/package/@pinelab/vendure-plugin-order-cleanup

## Dependencies (2)

- [croner](https://npm.io/package/croner.md) ^10.0.1
- [catch-unknown](https://npm.io/package/catch-unknown.md) ^2.0.0

## Recent versions

- 2.0.0 (latest) — 2026-09-24
- 1.2.0 — 2026-02-05
- 1.1.2 — 2025-11-13
- 1.1.1 — 2025-11-06
- 1.1.0 — 2025-06-04
- 1.0.0 — 2025-05-21

## README

# Vendure Order Cleanup Plugin

[Official documentation here](https://plugins.pinelab.studio/plugin/vendure-plugin-order-cleanup)

This plugin automatically empties stale active orders so their items are released without deleting the orders or changing their current state.

## Behavior

Each cleanup run selects non-empty orders that:

- have not been updated for longer than `olderThanDays`;
- are in `AddingItems`, `Created`, or `ArrangingPayment`; and
- still contain at least one order line.

Every selected order is preserved in its existing state while all of its order lines are removed and its totals are recalculated. Already-empty orders are not selected again. If one order cannot be emptied, the error is logged and the run continues with the remaining orders.

Cleanup uses bounded pages, processes orders in configurable concurrent batches, and attempts at most 10,000 orders per run. Any remaining work is deferred to the next scheduled run.

## Getting started

Vendure's scheduled-task system requires a scheduler strategy. Add `DefaultSchedulerPlugin` if your application does not already configure one:

```ts
import { DefaultSchedulerPlugin, VendureConfig } from '@vendure/core';
import { OrderCleanupPlugin } from '@pinelab/vendure-plugin-order-cleanup';

export const config: VendureConfig = {
  // ...
  plugins: [
    OrderCleanupPlugin.init({
      olderThanDays: 30,
    }),
    DefaultSchedulerPlugin.init(),
  ],
};
```

When `DefaultSchedulerPlugin` is added to an existing application, follow Vendure's scheduled-task documentation and generate the scheduler-table migration required by that plugin. The order-cleanup plugin itself adds no entities or database migration.

## Configuration

```ts
OrderCleanupPlugin.init({
  // Required: orders older than this cutoff are eligible.
  olderThanDays: 30,

  // Optional, default 10. Use 1 for SQLite.
  batchSize: 10,

  schedule: {
    // Optional five-field cron expression. Default: daily at 03:00.
    cron: '0 3 * * *',

    // Optional IANA timezone. Default: Europe/Amsterdam.
    timezone: 'Europe/Amsterdam',

    // Optional Vendure task timeout. Default: 1 hour.
    timeout: '1h',
  },
});
```

Cron matching is timezone-aware and handles daylight-saving changes. Vendure 3.6 does not expose a timezone option for an individual `ScheduledTask`, so the plugin registers a lightweight once-per-minute Vendure task and only queries orders when the configured cron expression matches in the configured timezone.

Invalid ages, batch sizes, five-field cron expressions, or IANA timezones fail during configuration.

## Upgrading from 1.x

Version 2.0.0 contains two breaking changes:

1. Stale orders are emptied and preserved in their current state instead of being cancelled.
2. `GET /order-cleanup/trigger` has been removed. Delete external cron jobs or scripts that call this endpoint and configure Vendure scheduling as shown above.

Before upgrading, ensure a Vendure scheduler strategy is configured and any migration required by `DefaultSchedulerPlugin` has been generated and deployed through your application's normal migration process.

---
_Source: https://npm.io/package/@pinelab/vendure-plugin-order-cleanup · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
