onCartAbandoned( )
Deprecated.
This event will continue to work until September 4, 2024, but a newer version is available at
wix-ecom-backend.Events.onAbandonedCheckoutCreated()
.
We recommend you migrate to the new Wix eCommerce APIs as soon as possible.
Description
An event that fires when a visitor abandons a shopping cart.
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
Information about the cart that was abandoned.
Returns
This function does not return anything.
Return Type:
Was this helpful?
An event when a shopping cart is abandoned
1// Place this code in the events.js file2// of your site's Backend section.34export 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}1011/* Full event object:12 *13 * {14 * "cartId": "60349781-b3hf-4349-8c9e-09492063da9",15 * "creationTime": "2019-01-23T11:28:22.328Z",16 * "abandonTime": "2019-01-23T12:28:02.373Z",17 * "buyerInfo": {18 * "id": "6g004532-732d-829f-5kf9-f9rk42afpla04m",19 * "identityType": "MEMBER",20 * "email": "john.doe@somedomain.com",21 * "firstName": "John",22 * "lastName": "Doe",23 * "phone": "5555555555"24 * },25 * "itemsCount": 1,26 * "couponId": "329a10d8-73a4-4a78-a68f-93a590c83672",27 * "totals": {28 * "subtotal": 20,29 * "total": 20,30 * "formattedTotal": "$20.00"31 * },32 * "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"33 * }34 *35 */