Search.../

onCartAbandoned( )

An event that fires when a visitor abandons a shopping cart.

Description

The onCartAbandoned() event handler runs when a visitor adds an item to the shopping cart, but does not complete the purchase within 1 hour.

If the visitor completes the purchase after it has been abandoned, an onCartRecovered event is fired.

You can use this event to reach out to the visitor who abandoned the shopping cart.

Note: Backend events don't work when previewing your site.

Syntax

function onCartAbandoned(event: CartAbandonedEvent): void

onCartAbandoned Parameters

NAME
TYPE
DESCRIPTION
event

CartAbandonedEvent

Information about the cart that was abandoned.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event when a shopping cart is abandoned

Code Example

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3
4export function wixStores_onCartAbandoned(event) {
5 let cartId = event.cartId;
6 let abandonTime = event.abandonTime;
7 let buyerEmail = event.buyerInfo.email;
8 let formattedTotal = event.totals.formattedTotal;
9}
10
11/* Full event object:
12 * {
13 * "cartId": "60349781-b3hf-4349-8c9e-09492063da9",
14 * "creationTime": "2019-01-23T11:28:22.328Z",
15 * "abandonTime": "2019-01-23T12:28:02.373Z",
16 * "buyerInfo": {
17 * "id": "6g004532-732d-829f-5kf9-f9rk42afpla04m",
18 * "identityType": "MEMBER",
19 * "email": "john.doe@somedomain.com",
20 * "firstName": "John",
21 * "lastName": "Doe",
22 * "phone": "5555555555"
23 * },
24 * "itemsCount": 1,
25 * "couponId": "329a10d8-73a4-4a78-a68f-93a590c83672",
26 * "totals": {
27 * "subtotal": 20,
28 * "total": 20,
29 * "formattedTotal": "$20.00"
30 * },
31 * "checkoutUrl": "https://mysite.com/checkout?appSectionParams=%7B%22a11y%22%3Afalse%2C%22cartId%22%3A%2260819781-b3cf-4179-9c9e-4958kd89a9%22%2C%22storeUrl%22%3A%22https%3A%2F%2Fmysite.com%22%2C%22isFastFlow%22%3Afalse%2C%22isPickupFlow%22%3Afalse%7D&linkSource=acMail"
32 * }
33 */