Search.../

onCartCompleted( )

Deprecated. This event will continue to work until September 4, 2024, but a newer version is available at wix-ecom-backend.Events.onCheckoutCompleted().

We recommend you migrate to the new Wix eCommerce APIs as soon as possible.

Description

An event that fires when a visitor completes a purchase from a shopping cart.

The onCartCompleted() event handler runs when a visitor completes a purchase from a shopping cart.

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

Syntax

function onCartCompleted(event: CartCompletedEvent): void

onCartCompleted Parameters

NAME
TYPE
DESCRIPTION
event
CartCompletedEvent

Information about the cart that was completed.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event with pickup details when a shopping cart is completed

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3
4export function wixStores_onCartCompleted(event) {
5 let total = event.totals.total;
6}
7
8/* Full event object:
9 *
10 * {
11 * "cartId": "6d158831-1510-44ae-a420-1483a4200852",
12 * "completedTime": "2019-02-27T12:08:16.160Z",
13 * "buyerInfo": {
14 * "id": "091a8443-ab85-480c-918b-777156358dfc",
15 * "firstName": "John",
16 * "lastName": "Doe"
17 * "email": "john.doe@somedomain.com",
18 * "phone": "5555555555",
19 * "identityType": "CONTACT"
20 * },
21 * "weightUnit": "LB",
22 * "buyerNote": "This is a note from the buyer.",
23 * "billingAddress": {
24 * "firstName": "John",
25 * "lastName": "Doe"
26 * "email": "john.doe@somedomain.com",
27 * "phone": "5555555555",
28 * "address": "235 W 23rd St, New York, NY 10011, USA"
29 * },
30 * "currency": {
31 * "currency": "USD",
32 * "symbol": "$"
33 * },
34 * "appliedCoupon": {
35 * "couponId": "e81e9c48-f954-4044-ba64-ccfe5c103c8f",
36 * "name": "Summer Sale",
37 * "code": "SummerSale",
38 * "discountValue": "$10.00",
39 * "couponType": "MoneyOff"
40 * },
41 * "totals": {
42 * "subtotal": 250,
43 * "discount": 10,
44 * "total": 240,
45 * "quantity": 2
46 * },
47 * "shippingInfo": {
48 * "pickupDetails": {
49 * "firstName": "John",
50 * "lastName": "Doe"
51 * "email": "john.doe@somedomain.com",
52 * "phone": "5555555555",
53 * "address": "235 W 23rd St, New York, NY 10011, USA"
54 * },
55 * }
56 * }
57 *
58 */
An event with shipping details when a shopping cart is completed

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3
4export function wixStores_onCartCompleted(event) {
5 let total = event.totals.total;
6}
7
8/* Full event object:
9 *
10 * {
11 * "cartId": "6d158831-1510-44ae-a420-1483a4200852",
12 * "completedTime": "2019-02-27T12:08:16.160Z",
13 * "buyerInfo": {
14 * "id": "091a8443-ab85-480c-918b-777156358dfc",
15 * "firstName": "John",
16 * "lastName": "Doe"
17 * "email": "john.doe@somedomain.com",
18 * "phone": "5555555555",
19 * "identityType": "CONTACT"
20 * },
21 * "weightUnit": "LB",
22 * "buyerNote": "This is a note from the buyer.",
23 * "billingAddress": {
24 * "firstName": "John",
25 * "lastName": "Doe"
26 * "email": "john.doe@somedomain.com",
27 * "phone": "5555555555",
28 * "address": "235 W 23rd St, New York, NY 10011, USA"
29 * },
30 * "currency": {
31 * "currency": "USD",
32 * "symbol": "$"
33 * },
34 * "appliedCoupon": {
35 * "couponId": "e81e9c48-f954-4044-ba64-ccfe5c103c8f",
36 * "name": "Summer Sale",
37 * "code": "SummerSale",
38 * "discountValue": "$10.00",
39 * "couponType": "MoneyOff"
40 * },
41 * "totals": {
42 * "subtotal": 250,
43 * "discount": 10,
44 * "total": 240,
45 * "quantity": 2
46 * },
47 * "shippingInfo": {
48 * "billingAddress": {
49 * "firstName": "John",
50 * "lastName": "Doe"
51 * "email": "john.doe@somedomain.com",
52 * "phone": "5555555555",
53 * "address": "235 W 23rd St, New York, NY 10011, USA"
54 * },
55 * }
56 * }
57 *
58 */