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.
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.
function onCartCompleted(event: CartCompletedEvent): void;
Information about the cart that was completed.
// Place this code in the events.js file
// of your site's Backend section.
export function wixStores_onCartCompleted(event) {
let total = event.totals.total;
}
/* Full event object:
*
* {
* "cartId": "6d158831-1510-44ae-a420-1483a4200852",
* "completedTime": "2019-02-27T12:08:16.160Z",
* "buyerInfo": {
* "id": "091a8443-ab85-480c-918b-777156358dfc",
* "firstName": "John",
* "lastName": "Doe"
* "email": "john.doe@somedomain.com",
* "phone": "5555555555",
* "identityType": "CONTACT"
* },
* "weightUnit": "LB",
* "buyerNote": "This is a note from the buyer.",
* "billingAddress": {
* "firstName": "John",
* "lastName": "Doe"
* "email": "john.doe@somedomain.com",
* "phone": "5555555555",
* "address": "235 W 23rd St, New York, NY 10011, USA"
* },
* "currency": {
* "currency": "USD",
* "symbol": "$"
* },
* "appliedCoupon": {
* "couponId": "e81e9c48-f954-4044-ba64-ccfe5c103c8f",
* "name": "Summer Sale",
* "code": "SummerSale",
* "discountValue": "$10.00",
* "couponType": "MoneyOff"
* },
* "totals": {
* "subtotal": 250,
* "discount": 10,
* "total": 240,
* "quantity": 2
* },
* "shippingInfo": {
* "pickupDetails": {
* "firstName": "John",
* "lastName": "Doe"
* "email": "john.doe@somedomain.com",
* "phone": "5555555555",
* "address": "235 W 23rd St, New York, NY 10011, USA"
* },
* }
* }
*
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.