CorvidReference

Events

Events that are fired from a Wix Store.

Wix Stores events are fired in you site's backend when certain events occur in your site's store. You can write event handlers that react to these events. Event handler functions receive data that corresponds to the event that has occurred. Use event handlers to create custom responses to store events.

To add a store event handler, add an events.js file to the Backend section of your site if one does not already exist. All event handler functions for your site are defined in this file.

Event handler functions are defined using the following pattern:

 export function <wixAppName>_<eventName>(event) { }

For example, an event handler that handles cart abandonment in a Wix Store looks like this:

 export function wixStores_onCartAbandoned(event) { }

Table of Contents

FUNCTIONS

?
Perform actions on an object.
onCartAbandoned( )An event that fires when a visitor abandons a shopping cart.
onCartCompleted( )An event that fires when a visitor completes a purchase from a shopping cart.
onCartCreated( )An event that fires when a visitor adds a product to a shopping cart.
onCartRecovered( )An event that fires when a visitor completes a purchase from an abandoned shopping cart.
onNewOrder( )An event that fires when a new order is placed.

OBJECTS

?
Objects used when setting, getting, or calling the properties and methods listed above.
AddressAn object representing an address.
BuyerInfoAn object representing a visitor who abandoned a shopping cart.
CartAbandonedEventAn object representing a shopping cart that was abandoned.
CartAppliedCouponAn object representing a coupon applied in a shopping cart.
CartCompletedEventAn object representing a shopping cart that was completed.
CartCreatedEventAn object representing a shopping cart that was created.
CartRecoveredEventAn object representing a shopping cart that was recovered.
CartTotalsAn object representing the totals of a shopping cart.
CurrencyAn object representing a currency.
NewOrderEventAn object representing a new order from a store.
OrderTotalsAn object representing an order's totals.
ShippingInfoAn object representing shipping information.

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.

Syntax

function onCartAbandoned(event: CartAbandonedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the cart that was abandoned.

Examples

An event when a shopping cart is abandoned

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onCartAbandoned(event) {
  let cartId = event.cartId;
  let abandonTime = event.abandonTime;
  let buyerEmail = event.buyerInfo.email;
  let formattedTotal = event.totals.formattedTotal;
}

/*  Full event object:
 *  {
 *    "cartId": "60349781-b3hf-4349-8c9e-09492063da9",
 *    "creationTime": "2019-01-23T11:28:22.328Z",
 *    "abandonTime": "2019-01-23T12:28:02.373Z",
 *    "buyerInfo": {
 *      "id": "6g004532-732d-829f-5kf9-f9rk42afpla04m",
 *      "identityType": "MEMBER",
 *      "email": "john.doe@somedomain.com",
 *      "firstName": "John",
 *      "lastName": "Doe",
 *      "phone": "5555555555"
 *    },
 *    "itemsCount": 1,
 *    "couponId": "329a10d8-73a4-4a78-a68f-93a590c83672",
 *    "totals": {
 *      "subtotal": 20,
 *      "total": 20,
 *      "formattedTotal": "$20.00"
 *    },
 *    "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"
 *  }
 */

onCartCompleted( )

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

Description

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

Syntax

function onCartCompleted(event: CartCompletedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the cart that was completed.

Examples

An event with pickup details when a shopping cart is 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"
 *      },
 *    }
 * }
 */

An event with shipping details when a shopping cart is 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": {
 *      "billingAddress": {
 *         "firstName": "John",
 *         "lastName": "Doe"
 *         "email": "john.doe@somedomain.com",
 *         "phone": "5555555555",
 *         "address": "235 W 23rd St, New York, NY 10011, USA"
 *      },
 *    }
 * }
 */

onCartCreated( )

An event that fires when a visitor adds a product to a shopping cart.

Description

The onCartCreated() event handler runs when a visitor adds an item to the shopping cart.

Syntax

function onCartCreated(event: CartCreatedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the cart that was created.

Examples

An event when a shopping cart is created

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onCartCreated(event) {
  let total = event.totals.total;
}

/*  Full event object:
 * {
 *    "cartId": "6d158831-1510-44ae-a420-1483a4200852",
 *    "creationTime": "2019-02-27T12:03:22.079Z",
 *    "buyerInfo": {
 *      "id": "4kf9ka09-4e9f-a02d-972f-9a5844d9d9a2",
 *      "email": "john.doe@somedomain.com",
 *      "phone": "5555555555",
 *      "firstName": "John",
 *      "lastName": "Doe"
 *    },
 *    "weightUnit": "LB",
 *    "currency": {
 *       "currency": "USD",
 *       "symbol": "$"
 *    },
 *    "totals": {
 *       "subtotal": 130,
 *       "discount": 0,
 *       "total": 130,
 *       "quantity": 1
 *    }
 * }
 */

onCartRecovered( )

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

Description

The onCartRecovered() event handler runs when a visitor completes a purchase more than 1 hour after items have been added to a shopping cart.

You can use this event to cancel planned communications with the vistor who abandoned the shopping cart.

Syntax

function onCartRecovered(event: CartRecoveredEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the cart that was recovered.

Examples

An event when an abandoned shopping cart is recovered

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onCartRecovered(event) {
  let cartId = event.cartId;
  let recoveredTime = event.recoveredTime;
}

/*  Full event object:
 *  {
 *    "cartId": "60349781-b3hf-4349-8c9e-09492063da9",
 *    "creationTime": "2019-01-23T11:28:22.328Z",
 *    "abandonTime": "2019-01-23T12:28:02.373Z",
 *    "recoveredTime": "2019-01-23T12:58:02.373Z"
 *  }
 */

onNewOrder( )

An event that fires when a new order is placed.

Description

The onNewOrder() event handler runs when a new order is placed in your site's store. The received NewOrderEvent object contains information about the new order that was placed.

Syntax

function onNewOrder(event: NewOrderEvent): void
PARAMETERS
?
Values that you pass to a function.
event
The order data.

Examples

An event when a new order is placed

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onNewOrder(event) {
  let newOrderId = event.orderId;
  let totalPrice = event.totals.total;
}

/*  Full event object:
 *  {
 *    "orderId": "2cd413bd-ddea-4101-b122-e8b146fec05f",
 *    "number": "10005",
 *    "dateCreated": "2018-08-05T12:33:18.938Z",
 *    "buyerInfo": {
 *      "id": "6g004532-732d-829f-5kf9-f9rk42afpla04m",
 *      "identityType": "MEMBER",
 *      "email": "john.doe@somedomain.com",
 *      "firstName": "John",
 *      "lastName": "Doe",
 *      "phone": "5555555555"
 *    },
 *    "currency": "USD",
 *    "weightUnit": "LB",
 *    "totals": {
 *      "subtotal": 99.99,
 *      "shipping": 4.99,
 *      "tax": 8.87,
 *      "discount": 9.99,
 *      "total": 103.86,
 *      "weight": 1.37,
 *      "quantity": 2
 *    },
 *    "paymentStatus": "PAID",
 *    "fulfillmentStatus": "FULFILLED"
 *  }
 */

Address

An object representing an address.

See Also

onCartCompleted( )

Syntax

type Address = {
  addressLine: string
  city: string
  subdivision: string
  country: string
  zipCode: string
}
MEMBERS
?
The properties of an object.
addressLine
string
Address line.
city
string
Address city.
subdivision
string
Country subdivision (state, province, etc.).
country
string
Address country as a two-letter country code.
zipCode
string
Address zip code.

Examples

An event when a shopping cart is 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": {
 *      "billingAddress": {
 *         "firstName": "John",
 *         "lastName": "Doe"
 *         "email": "john.doe@somedomain.com",
 *         "phone": "5555555555",
 *         "address": "235 W 23rd St, New York, NY 10011, USA"
 *      },
 *    }
 * }
 */

BuyerInfo

An object representing a visitor who abandoned a shopping cart.

See Also

onCartAbandoned( )

Syntax

type BuyerInfo = {
  id: string
  email: string
  firstName: string
  lastName: string
  identityType: string
  phone: string
}
MEMBERS
?
The properties of an object.
id
string
Buyer's unique ID.
email
string
Buyer's email address.
firstName
string
Buyer's first name.
lastName
string
Buyer's last name.
identityType
string

Buyer's identity. One of:

  • "ADMIN": Buyer is the site owner.
  • "MEMBER": Buyer is a logged-in site member.
  • "VISITOR": Buyer is not logged in.
  • "CONTACT": A contact has been created for the buyer.
phone
string
Buyer's phone number.

Examples

An event when a shopping cart is abandoned

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onCartAbandoned(event) {
  let cartId = event.cartId;
  let abandonTime = event.abandonTime;
  let buyerEmail = event.buyerInfo.email;
  let formattedTotal = event.totals.formattedTotal;
}

/*  Full event object:
 *  {
 *    "cartId": "60349781-b3hf-4349-8c9e-09492063da9",
 *    "creationTime": "2019-01-23T11:28:22.328Z",
 *    "abandonTime": "2019-01-23T12:28:02.373Z",
 *    "buyerInfo": {
 *      "id": "6g004532-732d-829f-5kf9-f9rk42afpla04m",
 *      "identityType": "MEMBER",
 *      "email": "john.doe@somedomain.com",
 *      "firstName": "John",
 *      "lastName": "Doe",
 *      "phone": "5555555555"
 *    },
 *    "itemsCount": 1,
 *    "couponId": "329a10d8-73a4-4a78-a68f-93a590c83672",
 *    "totals": {
 *      "subtotal": 20,
 *      "total": 20,
 *      "formattedTotal": "$20.00"
 *    },
 *    "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"
 *  }
 */

CartAbandonedEvent

An object representing a shopping cart that was abandoned.

See Also

onCartAbandoned( )

Syntax

type CartAbandonedEvent = {
  abandonTime: Date
  cartId: string
  checkoutUrl: string
  couponId: string
  creationTime: Date
  buyerInfo: BuyerInfo
  itemsCount: number
  totals: CartTotals
}
MEMBERS
?
The properties of an object.
abandonTime
Date
Time the abandoned cart was abandoned.
cartId
string
Unique identifier of the shopping cart that was abandoned.
checkoutUrl
string
URL of the abandoned cart's checkout page.
couponId
string
Unique identity of coupon used in the abandoned cart.
creationTime
Date
Time the abandoned cart was created.
buyerInfo
Information about the vistor who abandoned the shopping cart.
itemsCount
number
Number of items in the abandoned cart.
totals
Abandoned cart totals.

Examples

An event when a shopping cart is abandoned

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onCartAbandoned(event) {
  let cartId = event.cartId;
  let abandonTime = event.abandonTime;
  let buyerEmail = event.buyerInfo.email;
  let formattedTotal = event.totals.formattedTotal;
}

/*  Full event object:
 *  {
 *    "cartId": "60349781-b3hf-4349-8c9e-09492063da9",
 *    "creationTime": "2019-01-23T11:28:22.328Z",
 *    "abandonTime": "2019-01-23T12:28:02.373Z",
 *    "buyerInfo": {
 *      "id": "6g004532-732d-829f-5kf9-f9rk42afpla04m",
 *      "identityType": "MEMBER",
 *      "email": "john.doe@somedomain.com",
 *      "firstName": "John",
 *      "lastName": "Doe",
 *      "phone": "5555555555"
 *    },
 *    "itemsCount": 1,
 *    "couponId": "329a10d8-73a4-4a78-a68f-93a590c83672",
 *    "totals": {
 *      "subtotal": 20,
 *      "total": 20,
 *      "formattedTotal": "$20.00"
 *    },
 *    "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"
 *  }
 */

CartAppliedCoupon

An object representing a coupon applied in a shopping cart.

See Also

onCartCompleted( )

Syntax

type CartAppliedCoupon = {
  code: string
  couponId: string
  couponType: string
  discountValue: string
  name: string
}
MEMBERS
?
The properties of an object.
code
string
Coupon code.
couponId
string
Coupon unique identifier.
couponType
string

Type of coupon. One of:

  • "BuyXGetY"
  • "FixedPriceAmount"
  • "FreeShipping"
  • "MoneyOffAmount"
  • "PercentOffRate"
discountValue
string
Value of the coupon discount.
name
string
Coupon name.

Examples

An event when a shopping cart is 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": {
 *      "billingAddress": {
 *         "firstName": "John",
 *         "lastName": "Doe"
 *         "email": "john.doe@somedomain.com",
 *         "phone": "5555555555",
 *         "address": "235 W 23rd St, New York, NY 10011, USA"
 *      },
 *    }
 * }
 */

CartCompletedEvent

An object representing a shopping cart that was completed.

See Also

onCartCreated( )

Syntax

type CartCompletedEvent = {
  cartId: string
  completedTime: Date
  buyerInfo: BuyerInfo
  buyerNote: string
  appliedCoupon: CartAppliedCoupon
  billingAddress: Address
  currency: Currency
  weightUnit: string
  totals: OrderTotals
  shippingInfo: ShippingInfo
}
MEMBERS
?
The properties of an object.
cartId
string
Unique identifier of the shopping cart that was completed.
completedTime
Date
Time the shopping cart was completed.
buyerInfo
The buyer's information.
buyerNote
string
Message from the buyer.
appliedCoupon
Coupon applied in the shopping cart.
billingAddress
Billing address.
currency
Currency of the shopping cart.
weightUnit
string
The order's units of weight. One of: "KG", "LB", or "UNSPECIFIED_WEIGHT_UNIT".
totals
The shopping cart's totals.
shippingInfo
The shopping cart's shipping information.

Examples

An event with shipping details when a shopping cart is 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": {
 *      "billingAddress": {
 *         "firstName": "John",
 *         "lastName": "Doe"
 *         "email": "john.doe@somedomain.com",
 *         "phone": "5555555555",
 *         "address": "235 W 23rd St, New York, NY 10011, USA"
 *      },
 *    }
 * }
 */

An event with pickup details when a shopping cart is 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"
 *      },
 *    }
 * }
 */

CartCreatedEvent

An object representing a shopping cart that was created.

See Also

onCartCreated( )

Syntax

type CartCreatedEvent = {
  cartId: string
  buyerInfo: BuyerInfo
  creationTime: Date
  weightUnit: string
  currency: Currency
  totals: OrderTotals
}
MEMBERS
?
The properties of an object.
cartId
string
Unique identifier of the shopping cart that was created.
buyerInfo
The buyer's information.
creationTime
Date
Time the shopping cart was created.
weightUnit
string
The order's units of weight. One of: "KG", "LB", or "UNSPECIFIED_WEIGHT_UNIT".
currency
Currency of the shopping cart.
totals
The shopping cart's totals.

Examples

An event when a shopping cart is created

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onCartCreated(event) {
  let total = event.totals.total;
}

/*  Full event object:
 * {
 *    "cartId": "6d158831-1510-44ae-a420-1483a4200852",
 *    "creationTime": "2019-02-27T12:03:22.079Z",
 *    "buyerInfo": {
 *      "id": "4kf9ka09-4e9f-a02d-972f-9a5844d9d9a2",
 *      "email": "john.doe@somedomain.com",
 *      "phone": "5555555555",
 *      "firstName": "John",
 *      "lastName": "Doe"
 *    },
 *    "weightUnit": "LB",
 *    "currency": {
 *       "currency": "USD",
 *       "symbol": "$"
 *    },
 *    "totals": {
 *       "subtotal": 130,
 *       "discount": 0,
 *       "total": 130,
 *       "quantity": 1
 *    }
 * }
 */

CartRecoveredEvent

An object representing a shopping cart that was recovered.

See Also

onCartRecovered( )

Syntax

type CartRecoveredEvent = {
  abandonedTime: Date
  cartId: string
  recoveredTime: Date
  creationTime: Date
}
MEMBERS
?
The properties of an object.
abandonedTime
Date
Time the recovered cart was abandoned.
cartId
string
Unique identifier of the shopping cart that was abandoned.
recoveredTime
Date
Time the cart was recovered.
creationTime
Date
Time the recovered cart was originally created.

Examples

An event when an abandoned shopping cart is recovered

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onCartRecovered(event) {
  let cartId = event.cartId;
  let recoveredTime = event.recoveredTime;
}

/*  Full event object:
 *  {
 *    "cartId": "60349781-b3hf-4349-8c9e-09492063da9",
 *    "creationTime": "2019-01-23T11:28:22.328Z",
 *    "abandonTime": "2019-01-23T12:28:02.373Z",
 *    "recoveredTime": "2019-01-23T12:58:02.373Z"
 *  }
 */

CartTotals

An object representing the totals of a shopping cart.

See Also

onCartAbandoned( )

Syntax

type CartTotals = {
  subtotal: number
  total: number
  formattedTotal: string
}
MEMBERS
?
The properties of an object.
subtotal
number
Subtotal of all the line items in the abandoned cart, not including shipping and tax.
total
number
Total of all the line items in the abandoned cart, including shipping and tax.
formattedTotal
string
Total formatted with currency symbol.

Examples

An event when a shopping cart is abandoned

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onCartAbandoned(event) {
  let cartId = event.cartId;
  let abandonTime = event.abandonTime;
  let buyerEmail = event.buyerInfo.email;
  let formattedTotal = event.totals.formattedTotal;
}

/*  Full event object:
 *  {
 *    "cartId": "60349781-b3hf-4349-8c9e-09492063da9",
 *    "creationTime": "2019-01-23T11:28:22.328Z",
 *    "abandonTime": "2019-01-23T12:28:02.373Z",
 *    "buyerInfo": {
 *      "id": "6g004532-732d-829f-5kf9-f9rk42afpla04m",
 *      "identityType": "MEMBER",
 *      "email": "john.doe@somedomain.com",
 *      "firstName": "John",
 *      "lastName": "Doe",
 *      "phone": "5555555555"
 *    },
 *    "itemsCount": 1,
 *    "couponId": "329a10d8-73a4-4a78-a68f-93a590c83672",
 *    "totals": {
 *      "subtotal": 20,
 *      "total": 20,
 *      "formattedTotal": "$20.00"
 *    },
 *    "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"
 *  }
 */

Currency

An object representing a currency.

See Also

onCartCreated( )

Syntax

type Currency = {
  currency: string
  symbol: string
}
MEMBERS
?
The properties of an object.
currency
string
The currency code.
symbol
string
The currency symbol.

Examples

An event when a shopping cart is created

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onCartCreated(event) {
  let total = event.totals.total;
}

/*  Full event object:
 * {
 *    "cartId": "6d158831-1510-44ae-a420-1483a4200852",
 *    "creationTime": "2019-02-27T12:03:22.079Z",
 *    "buyerInfo": {
 *      "id": "4kf9ka09-4e9f-a02d-972f-9a5844d9d9a2",
 *      "email": "john.doe@somedomain.com",
 *      "phone": "5555555555",
 *      "firstName": "John",
 *      "lastName": "Doe"
 *    },
 *    "weightUnit": "LB",
 *    "currency": {
 *       "currency": "USD",
 *       "symbol": "$"
 *    },
 *    "totals": {
 *       "subtotal": 130,
 *       "discount": 0,
 *       "total": 130,
 *       "quantity": 1
 *    }
 * }
 */

NewOrderEvent

An object representing a new order from a store.

See Also

onNewOrder( )

Syntax

type NewOrderEvent = {
  orderId: string
  number: string
  buyerInfo: BuyerInfo
  currency: string
  weightUnit: string
  totals: OrderTotals
  paymentStatus: string
  fulfillmentStatus: string
  dateCreated: Date
}
MEMBERS
?
The properties of an object.
orderId
string
The ID of the order, auto-generated when an order is created an unique within all Wix Stores.
number
string
Running order number unique to the current store.
buyerInfo
The buyer's information.
currency
string
The currency code for all of the order's prices.
weightUnit
string
The order's units of weight. One of: "KG", "LB", or "UNSPECIFIED_WEIGHT_UNIT".
totals
The order's totals.
paymentStatus
string
The order's payment status. One of: "PAID" or "NOT_PAID".
fulfillmentStatus
string
The order's fulfillment status. One of: "FULFILLED" or "NOT_FULFILLED".
dateCreated
Date
The date the order was created.

Examples

An event when a new order is placed

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onNewOrder(event) {
  let newOrderId = event.orderId;
  let totalPrice = event.totals.total;
}

/*  Full event object:
 *  {
 *    "orderId": "2cd413bd-ddea-4101-b122-e8b146fec05f",
 *    "number": "10005",
 *    "dateCreated": "2018-08-05T12:33:18.938Z",
 *    "buyerInfo": {
 *      "id": "6g004532-732d-829f-5kf9-f9rk42afpla04m",
 *      "identityType": "MEMBER",
 *      "email": "john.doe@somedomain.com",
 *      "firstName": "John",
 *      "lastName": "Doe",
 *      "phone": "5555555555"
 *    },
 *    "currency": "USD",
 *    "weightUnit": "LB",
 *    "totals": {
 *      "subtotal": 99.99,
 *      "shipping": 4.99,
 *      "tax": 8.87,
 *      "discount": 9.99,
 *      "total": 103.86,
 *      "weight": 1.37,
 *      "quantity": 2
 *    },
 *    "paymentStatus": "PAID",
 *    "fulfillmentStatus": "FULFILLED"
 *  }
 */

OrderTotals

An object representing an order's totals.

See Also

onNewOrder( ), NewOrderEvent, onCartCreated( ), CartCreatedEvent, onCartCompleted( ), CartCompletedEvent

Syntax

type OrderTotals = {
  subtotal: number
  shipping: number
  tax: string
  discount: number
  total: number
  weight: number
  quantity: number
}
MEMBERS
?
The properties of an object.
subtotal
number
The subtotal of all the order's line items, excluding tax.
shipping
number
The total shipping price, including tax.
tax
string
The total amount of tax.
discount
number
The total calculated discount amount.
total
number
The total price.
weight
number
The total weight of the order's items.
quantity
number
The total quantity of the the order's line items.

Examples

An event when a new order is placed

// Place this code in the events.js file
// of your site's Backend section.

export function wixStores_onNewOrder(event) {
  let newOrderId = event.orderId;
  let totalPrice = event.totals.total;
}

/*  Full event object:
 *  {
 *    "orderId": "2cd413bd-ddea-4101-b122-e8b146fec05f",
 *    "number": "10005",
 *    "dateCreated": "2018-08-05T12:33:18.938Z",
 *    "buyerInfo": {
 *      "id": "6g004532-732d-829f-5kf9-f9rk42afpla04m",
 *      "identityType": "MEMBER",
 *      "email": "john.doe@somedomain.com",
 *      "firstName": "John",
 *      "lastName": "Doe",
 *      "phone": "5555555555"
 *    },
 *    "currency": "USD",
 *    "weightUnit": "LB",
 *    "totals": {
 *      "subtotal": 99.99,
 *      "shipping": 4.99,
 *      "tax": 8.87,
 *      "discount": 9.99,
 *      "total": 103.86,
 *      "weight": 1.37,
 *      "quantity": 2
 *    },
 *    "paymentStatus": "PAID",
 *    "fulfillmentStatus": "FULFILLED"
 *  }
 */

ShippingInfo

An object representing shipping information.

See Also

onCartCompleted( )

Syntax

type ShippingInfo = {
  shippingAddress: Address
  pickupInfo: Address
}
MEMBERS
?
The properties of an object.
shippingAddress(Optional)
Shipment address.
pickupInfo(Optional)
Pickup address.

Examples

An event with shipping details when a shopping cart is 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": {
 *      "billingAddress": {
 *         "firstName": "John",
 *         "lastName": "Doe"
 *         "email": "john.doe@somedomain.com",
 *         "phone": "5555555555",
 *         "address": "235 W 23rd St, New York, NY 10011, USA"
 *      },
 *    }
 * }
 */

An event with pickup details when a shopping cart is 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"
 *      },
 *    }
 * }
 */