Abandoned Cart

Marks idle Payload carts abandoned, sends a timed recovery email sequence, and attributes the orders that come back.

Community 0 MIT v1.0.0

Installation

pnpm add payload-abandoned-cart

About

This plugin extends `@payloadcms/plugin-ecommerce` for stores that want to recover abandoned baskets. It records an `abandonedAt` timestamp on carts that have been idle past a configurable window, then sends a timed sequence of recovery messages and writes the sale back onto the order when a customer returns through a recovery link. The link points at an endpoint that validates an expiring token and redirects to the storefront, carrying the cart secret so a guest can pick the basket back up. Integration is by fields and endpoints, not by replacing anything the ecommerce plugin defines. The plugin adds fields to the carts and orders collections, plus a `GET /abandoned-cart/recover` endpoint and a `POST /abandoned-cart/sweep` endpoint. The sweep does the marking and sending in one pass, so you point a cron job at it with a bearer secret. The same work is exported as `markAbandonedCarts`, `sendRecoveryEmails`, and `runAbandonedCartSweep` if you prefer to call it from your own code. There is no scheduler dependency and no mail library: every message goes out through `payload.sendEmail`, which means whatever email adapter the host already configured. The recovery sequence is a list of steps, each with a `delayMinutes` counted from `abandonedAt` rather than from the previous message, so the schedule stays readable as steps are added or removed. A step's template is either a pair of strings carrying `{{placeholder}}` tokens or a function that receives a context object with `cartID`, `itemCount`, `subtotalFormatted`, `recoveryURL`, `step`, and the rest. The defaults are two plain text messages, at one hour and 24 hours. Token lifetime (`tokenTtlHours`, default 336), attribution window (`attributionWindowHours`, default 168), and the idle threshold (`idleMinutes`, default 60) are all configurable. A `disabled` option stops marking, sending, and attributing while leaving every field in place, so an existing database keeps its shape. The plugin must be added after `ecommercePlugin`, because it extends the collections that plugin defines. Sending requires an address: it reads `customerEmail` on the cart first, then falls back to the customer record, so a guest cart needs the storefront to capture the address at the start of checkout. Order attribution relies on the ecommerce plugin creating the order and marking the cart purchased inside one request, since the order carries no link back to the cart. If the orders slug is absent, recovered sales are still marked on the cart but not on any order.

Package info

Package name
payload-abandoned-cart
Latest version
1.0.0
Unpacked size
53 kB
License
MIT
Last publish
Aug 20, 2026

More from Poseidonas

View profile