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.

Note that backend events don't work when previewing your site.

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) { }

Note that backend events don't work when previewing your site.

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.
onCollectionCreated( )An event that fires when a product collection is created.
onCollectionDeleted( )An event that fires when a product collection is deleted.
onCollectionUpdated( )An event that fires when a product collection is updated.
onInventoryItemUpdated( )An event that fires when an inventory item's information is updated.
onInventoryVariantUpdated( )An event that fires when the inventory information of a product variant is updated.
onNewOrder( )An event that fires when a new order is placed.
onProductCreated( )An event that fires when a product is created.
onProductDeleted( )An event that fires when a product is deleted.
onProductUpdated( )An event that fires when a product is updated.
onVariantsUpdated( )An event that fires when variant information for a product is updated.

OBJECTS

?
Objects used when setting, getting, or calling the properties and methods listed above.
CartAbandonedEventAn object representing a shopping cart that was abandoned.
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.
CollectionCreatedEventAn object representing a product collection that was created.
CollectionDeletedEventAn object representing a product collection that was deleted.
CollectionUpdatedEventAn object representing a product collection that was updated.
InventoryItemUpdatedEventAn object representing an inventory item that was updated.
InventoryVariantUpdatedEventAn object representing product variant information that was updated.
MediaItemAn object representing a media item.
NewOrderEventAn object representing a new order from a store.
ProductCreatedEventAn object representing a product that was created.
ProductDeletedEventAn object representing a product that was deleted.
ProductUpdatedEventAn object representing a product that was updated.
UpdatedVariantAn object representing a product variants that was updated.
UpdatedVariantInventoryAn object representing product variant that was updated.
VariantInventoryValueAn object representing a product variant value.
VariantsUpdatedEventAn object representing product variants that were updated.

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
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.

Note

Backend events don't work when previewing your site.

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.

Note

Backend events don't work when previewing your site.

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 visitor who abandoned the shopping cart.

Note

Backend events don't work when previewing your site.

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"
 *  }
 */

onCollectionCreated( )

An event that fires when a product collection is created.

Description

The onCollectionCreated() event handler runs when a product collection is added to a store.

Note

Backend events don't work when previewing your site.

Syntax

function onCollectionCreated(event: CollectionCreatedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the product collection that was created.

Examples

An event when a product collection is created

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

export function wixStores_onCollectionCreated(event) {
  let collectionId = event._id;
}

/*  Full event object:
 *  { 
 *    "name": "New Collection",
 *    "_id": "a7698dfb-12e8-1bd6-cdc1-0116554f18d1",
 *    "mainMedia": "wix:image://v1/c...8.jpg/file.jpg#originWidth=2700&originHeight=2186"
 *  }
 */

onCollectionDeleted( )

An event that fires when a product collection is deleted.

Description

The onCollectionDeleted() event handler runs when a product collection is deleted from a store.

Note

Backend events don't work when previewing your site.

Syntax

function onCollectionDeleted(event: CollectionDeletedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the product collection that was deleted.

Examples

An event when a product collection is deleted

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

export function wixStores_onProductDeleted(event) {
  let collectionId = event.collectionId;
}

/*  Full event object:
 *  {
 *    "collectionId": "a7698dfb-12e8-1bd6-cdc1-0116554f18d1"
 *  }
 */

onCollectionUpdated( )

An event that fires when a product collection is updated.

Description

The onCollectionUpdated() event handler runs when a product collection is updated in a store.

Note

Backend events don't work when previewing your site.

Syntax

function onCollectionUpdated(event: CollectionUpdatedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the product collection that was updated.

Examples

An event when a product collection is updated

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

export function wixStores_onCollectionUpdated(event) {
  let collectionId = event.collectionId;
  let firstUpdatedField = event.updateFields[0];
}

/*  Full event object:
 *  {
 *    "collectionId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",
 *    "updatedFields": [
 *      "name",
 *      "media"
 *    ]
 *  }
 */

onInventoryItemUpdated( )

An event that fires when an inventory item's information is updated.

Description

The onInventoryItemUpdated() event handler runs when information for an inventory item is updated in a store.

Note

Backend events don't work when previewing your site.

Syntax

function onInventoryItemUpdated(event: InventoryItemUpdatedEvent): void

Examples

An event when an inventory item's information is updated

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

export function wixStores_onVariantsUpdated(event) {
  let inventoryItemId = event.inventoryItemId;
}

/*  Full event object:
 *  { 
 *    "externalId":"8fe8f05f-951e-1563-b917-88adf8284543",
 *    "trackInventory":true,
 *    "inventoryItemId":"70170fa0-6ae1-ea9c-46e8-775207d7babc"
 *  }
 */

onInventoryVariantUpdated( )

An event that fires when the inventory information of a product variant is updated.

Description

The onInventoryVariantUpdated() event handler runs when inventory information for a product variant is updated in a store.

Note

Backend events don't work when previewing your site.

Syntax

function onInventoryVariantUpdated(event: InventoryVariantUpdatedEvent): void

Examples

An event when product variant inventory information is updated

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

export function wixStores_onInventoryVariantUpdated(event) {
  let inventoryItemId = event.inventoryItemId;
  let firstVariant = event.variants[0];
  let firstNewQuantity = firstVariant.newValue.quantity;
}

/*  Full event object:
 *  { 
 *    "variants": [
 *      { 
 *        "oldValue": {
 *          "inStock": true,
 *          "quantity": 10
 *        },
 *        "newValue": {
 *          "inStock": true,
 *          "quantity": 50
 *        },
 *        "id": "00000000-0000-0000-0000-000000000000"
 *      }
 *    ],
 *    "externalId": "8fe8f05f-951e-1563-b917-88adf8284543",
 *    "inventoryItemId": "70170fa0-6ae1-ea9c-46e8-775207d7babc"
 *  }
 */

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.

Note

Backend events don't work when previewing your site.

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"
 *  }
 */

onProductCreated( )

An event that fires when a product is created.

Description

The onProductCreated() event handler runs when a new product is added to a store.

Note

Backend events don't work when previewing your site.

Syntax

function onProductCreated(event: ProductCreatedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the product that was created.

Examples

An event when a product is created

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

export function wixStores_onProductCreated(event) {
  let productId = event._id;
}

/*  Full event object:
 *  { 
 *    "name": "New Product",
 *    "sku": "abc123",
 *    "formattedDiscountedPrice": "$100.00",
 *    "visible": true,
 *    "mainMedia": "wix:image://v1/6...6.jpg/file.jpg#originWidth=2700&originHeight=2186",
 *    "_id": "5096485f-0239-3881-3f6a-63955708a4ec",
 *    "discountedPrice": 100,
 *    "formattedPrice": "$100.00",
 *    "price": 100,
 *    "mediaItems": [ 
 *      { 
 *        "description": "Main Image",
 *        "id": "6b678d2e696a4c50813508043ca33b26.jpg",
 *        "src": "wix:image://v1/6...6.jpg/file.jpg#originWidth=2700&originHeight=2186",
 *        "title": "Main Image",
 *        "type": "Image"
 *      }
 *    ],
 *    "currency": "USD",
 *    "productPageUrl": "/product-page/new-product"
 *  }
 */

onProductDeleted( )

An event that fires when a product is deleted.

Description

The onProductDeleted() event handler runs when a product is deleted from a store.

Note

Backend events don't work when previewing your site.

Syntax

function onProductDeleted(event: ProductDeletedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the product that was deleted.

Examples

An event when a product is deleted

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

export function wixStores_onProductDeleted(event) {
  let productId = event.productId;
}

/*  Full event object:
 *  { 
 *    "productId": "5096485f-0239-3881-3f6a-63955708a4ec"
 *  }
 */

onProductUpdated( )

An event that fires when a product is updated.

Description

The onProductUpdated() event handler runs when a product is updated in a store.

Note

Backend events don't work when previewing your site.

Syntax

function onProductUpdated(event: ProductUpdatedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the product that was updated.

Examples

An event when a product is updated

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

export function wixStores_onProductUpdated(event) {
  let productId = event.productId;
  let firstUpdatedField = event.updateFields[0];
}

/*  Full event object:
 *  {
 *    "productId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",
 *    "updatedFields": [
 *      "name",
 *      "productOptions",
 *      "description",
 *      "price",
 *      "slug",
 *      "ribbons",
 *      "customTextFields",
 *      "media",
 *      "productPageUrl",
 *      "manageVariants",
 *      "discount",
 *      "additionalInfoSections"
 *    ]
 *  }
 */

onVariantsUpdated( )

An event that fires when variant information for a product is updated.

Description

The onVariantsUpdated() event handler runs when variant information for a product is updated in a store.

Note

Backend events don't work when previewing your site.

Syntax

function onVariantsUpdated(event: VariantsUpdatedEvent): void
PARAMETERS
?
Values that you pass to a function.
event
Information about the product collection that was deleted.

Examples

An event when a product variant information is updated

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

export function wixStores_onVariantsUpdated(event) {
  let productId = event.productId;
  let firstVariant = event.variants[0];
}

/*  Full event object:
 *  { 
 *   "variants":[ 
 *     { 
 *       "updatedFields":[ 
 *         "price"
 *       ],
 *       "choices":{ 
 *         "Color":"Red"
 *       },
 *       "variantId":"00000000-0000-0001-0005-970d993bafe9"
 *     }, { 
 *       "updatedFields":[ 
 *         "sku"
 *       ],
 *       "choices":{ 
 *         "Color":"Blue"
 *       },
 *       "variantId":"00000000-0000-0002-0005-970d993bafe9"
 *     }
 *   ],
 *   "productId":"1a2d7e83-4bef-31d5-09e1-3326ee271c09"
 * }
 */

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
ID of the shopping cart that was abandoned.
checkoutUrl
string
URL of the abandoned cart's checkout page.
couponId
string
ID of coupon used in the abandoned cart.
creationTime
Date
Time the abandoned cart was created.
buyerInfo
Information about the visitor 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"
 *  }
 */

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: AppliedCoupon
  billingAddress: Address
  currency: Currency
  weightUnit: string
  totals: OrderTotals
  shippingInfo: ShippingInfo
}
MEMBERS
?
The properties of an object.
cartId
string
ID 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
ID 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
ID 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"
 *  }
 */

CollectionCreatedEvent

An object representing a product collection that was created.

Syntax

type CollectionCreatedEvent = {
  name: string
  _id: string
  mainMedia: string
}
MEMBERS
?
The properties of an object.
name
string
Collection name.
_id
string
ID of the created collection.
mainMedia
string
Main product media item (image) URL.

Examples

An event when a product collection is created

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

export function wixStores_onCollectionCreated(event) {
  let collectionId = event._id;
}

/*  Full event object:
 *  { 
 *    "name": "New Collection",
 *    "_id": "a7698dfb-12e8-1bd6-cdc1-0116554f18d1",
 *    "mainMedia": "wix:image://v1/c...8.jpg/file.jpg#originWidth=2700&originHeight=2186"
 *  }
 */

CollectionDeletedEvent

An object representing a product collection that was deleted.

Syntax

type CollectionDeletedEvent = {
  collectionId: string
}
MEMBERS
?
The properties of an object.
collectionId
string
ID of the delete collection.

Examples

An event when a product collection is deleted

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

export function wixStores_onProductDeleted(event) {
  let collectionId = event.collectionId;
}

/*  Full event object:
 *  {
 *    "collectionId": "a7698dfb-12e8-1bd6-cdc1-0116554f18d1"
 *  }
 */

CollectionUpdatedEvent

An object representing a product collection that was updated.

Syntax

type CollectionUpdatedEvent = {
  collectionId: string
  updatedFields: Array<string>
}
MEMBERS
?
The properties of an object.
collectionId
string
ID of the updated collection.
updatedFields
Array<string>
Names of the collection fields that were updated.

Examples

An event when a product collection is updated

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

export function wixStores_onCollectionUpdated(event) {
  let collectionId = event.collectionId;
  let firstUpdatedField = event.updateFields[0];
}

/*  Full event object:
 *  {
 *    "collectionId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",
 *    "updatedFields": [
 *      "name",
 *      "media"
 *    ]
 *  }
 */

InventoryItemUpdatedEvent

An object representing an inventory item that was updated.

Syntax

type InventoryItemUpdatedEvent = {
  inventoryItemId: string
  externalId: string
  trackInventory: boolean
}
MEMBERS
?
The properties of an object.
inventoryItemId
string
ID of the inventory item.
externalId
string

External ID of the inventory item. For example, the product ID for inventory items which are store products.

trackInventory
boolean
Whether the item's inventory is tracked.

Examples

An event when product inventory information is updated

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

export function wixStores_onVariantsUpdated(event) {
  let inventoryItemId = event.inventoryItemId;
}

/*  Full event object:
 *  { 
 *    "externalId":"8fe8f05f-951e-1563-b917-88adf8284543",
 *    "trackInventory":true,
 *    "inventoryItemId":"70170fa0-6ae1-ea9c-46e8-775207d7babc"
 *  }
 */

InventoryVariantUpdatedEvent

An object representing product variant information that was updated.

Syntax

type InventoryVariantUpdatedEvent = {
  inventoryItemId: string
  externalId: string
  variants: Array<UpdatedVariantInventory>
}
MEMBERS
?
The properties of an object.
inventoryItemId
string
ID of the inventory item.
externalId
string

External ID of the inventory item. For example, the product ID for inventory items which are store products.

variants
List of variants that were updated.

Examples

An event when product variant inventory information is updated

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

export function wixStores_onInventoryVariantUpdated(event) {
  let inventoryItemId = event.inventoryItemId;
  let firstVariant = event.variants[0];
  let firstNewQuantity = firstVariant.newValue.quantity;
}

/*  Full event object:
 *  { 
 *    "variants": [
 *      { 
 *        "oldValue": {
 *          "inStock": true,
 *          "quantity": 10
 *        },
 *        "newValue": {
 *          "inStock": true,
 *          "quantity": 50
 *        },
 *        "id": "00000000-0000-0000-0000-000000000000"
 *      }
 *    ],
 *    "externalId": "8fe8f05f-951e-1563-b917-88adf8284543",
 *    "inventoryItemId": "70170fa0-6ae1-ea9c-46e8-775207d7babc"
 *  }
 */

MediaItem

An object representing a media item.

Syntax

type MediaItem = {
  description: string
  id: string
  src: string
  title: string
  type: string
}
MEMBERS
?
The properties of an object.
description
string
Media item description.
id
string
Media item ID.
src
string
Media item URL.
title
string
Media item title.
type
string
Media items type.

Examples

An event when a product is created

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

export function wixStores_onProductCreated(event) {
  let productId = event._id;
}

/*  Full event object:
 *  { 
 *    "name": "New Product",
 *    "sku": "abc123",
 *    "formattedDiscountedPrice": "$100.00",
 *    "visible": true,
 *    "mainMedia": "wix:image://v1/6...6.jpg/file.jpg#originWidth=2700&originHeight=2186",
 *    "_id": "5096485f-0239-3881-3f6a-63955708a4ec",
 *    "discountedPrice": 100,
 *    "formattedPrice": "$100.00",
 *    "price": 100,
 *    "mediaItems": [ 
 *      { 
 *        "description": "Main Image",
 *        "id": "6b678d2e696a4c50813508043ca33b26.jpg",
 *        "src": "wix:image://v1/6...6.jpg/file.jpg#originWidth=2700&originHeight=2186",
 *        "title": "Main Image",
 *        "type": "Image"
 *      }
 *    ],
 *    "currency": "USD",
 *    "productPageUrl": "/product-page/new-product"
 *  }
 */

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"
 *  }
 */

ProductCreatedEvent

An object representing a product that was created.

Syntax

type ProductCreatedEvent = {
  _id: string
  name: string
  sku: string
  formattedDiscountedPrice: string
  visible: boolean
  mainMedia: string
  discountedPrice: number
  formattedPrice: string
  price: number
  mediaItems: Array<MediaItem>
  currency: string
  productPageUrl: string
}
MEMBERS
?
The properties of an object.
_id
string
Product ID.
name
string
Product name.
sku
string
Product stock keeping unit.
formattedDiscountedPrice
string
Discounted product price formatted with the currency.
visible
boolean
Whether the product is shown in the store.
mainMedia
string
Main product media item (image or video) URL.
discountedPrice
number
Discounted product price.
formattedPrice
string
Product price formatted with the currency.
price
number
Product price.
mediaItems
Array<MediaItem>
Product media items.
currency
string
Product currency.
productPageUrl
string
URL to the product's page.

Examples

An event when a product is created

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

export function wixStores_onProductCreated(event) {
  let productId = event._id;
}

/*  Full event object:
 *  { 
 *    "name": "New Product",
 *    "sku": "abc123",
 *    "formattedDiscountedPrice": "$100.00",
 *    "visible": true,
 *    "mainMedia": "wix:image://v1/6...6.jpg/file.jpg#originWidth=2700&originHeight=2186",
 *    "_id": "5096485f-0239-3881-3f6a-63955708a4ec",
 *    "discountedPrice": 100,
 *    "formattedPrice": "$100.00",
 *    "price": 100,
 *    "mediaItems": [ 
 *      { 
 *        "description": "Main Image",
 *        "id": "6b678d2e696a4c50813508043ca33b26.jpg",
 *        "src": "wix:image://v1/6...6.jpg/file.jpg#originWidth=2700&originHeight=2186",
 *        "title": "Main Image",
 *        "type": "Image"
 *      }
 *    ],
 *    "currency": "USD",
 *    "productPageUrl": "/product-page/new-product"
 *  }
 */

ProductDeletedEvent

An object representing a product that was deleted.

Syntax

type ProductDeletedEvent = {
  productId: string
}
MEMBERS
?
The properties of an object.
productId
string
ID of the deleted product.

Examples

An event when a product is deleted

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

export function wixStores_onProductDeleted(event) {
  let productId = event.productId;
}

/*  Full event object:
 *  { 
 *    "productId": "5096485f-0239-3881-3f6a-63955708a4ec"
 *  }
 */

ProductUpdatedEvent

An object representing a product that was updated.

Syntax

type ProductUpdatedEvent = {
  productId: string
  updatedFields: Array<string>
}
MEMBERS
?
The properties of an object.
productId
string
ID of the updated product.
updatedFields
Array<string>
Names of the product fields that were updated.

Examples

An event when a product is updated

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

export function wixStores_onProductUpdated(event) {
  let productId = event.productId;
  let firstUpdatedField = event.updateFields[0];
}

/*  Full event object:
 *  {
 *    "productId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",
 *    "updatedFields": [
 *      "name",
 *      "productOptions",
 *      "description",
 *      "price",
 *      "slug",
 *      "ribbons",
 *      "customTextFields",
 *      "media",
 *      "productPageUrl",
 *      "manageVariants",
 *      "discount",
 *      "additionalInfoSections"
 *    ]
 *  }
 */

UpdatedVariant

An object representing a product variants that was updated.

Syntax

type UpdatedVariant = {
  variantId: string
  updatedFields: Array<string>
  choices: ProductChoices
}
MEMBERS
?
The properties of an object.
variantId
string
ID of the variant that was updated.
updatedFields
Array<string>
Names of the product variant fields that were updated.

Examples

An event when a product variant information is updated

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

export function wixStores_onVariantsUpdated(event) {
  let productId = event.productId;
  let firstVariant = event.variants[0];
}

/*  Full event object:
 *  { 
 *   "variants":[ 
 *     { 
 *       "updatedFields":[ 
 *         "price"
 *       ],
 *       "choices":{ 
 *         "Color":"Red"
 *       },
 *       "variantId":"00000000-0000-0001-0005-970d993bafe9"
 *     }, { 
 *       "updatedFields":[ 
 *         "sku"
 *       ],
 *       "choices":{ 
 *         "Color":"Blue"
 *       },
 *       "variantId":"00000000-0000-0002-0005-970d993bafe9"
 *     }
 *   ],
 *   "productId":"1a2d7e83-4bef-31d5-09e1-3326ee271c09"
 * }
 */

UpdatedVariantInventory

An object representing product variant that was updated.

Syntax

type UpdatedVariantInventory = {
  id: string
  oldValue: VariantInventoryValue
  newValue: VariantInventoryValue
}

Examples

An event when product variant inventory information is updated

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

export function wixStores_onInventoryVariantUpdated(event) {
  let inventoryItemId = event.inventoryItemId;
  let firstVariant = event.variants[0];
  let firstNewQuantity = firstVariant.newValue.quantity;
}

/*  Full event object:
 *  { 
 *    "variants": [
 *      { 
 *        "oldValue": {
 *          "inStock": true,
 *          "quantity": 10
 *        },
 *        "newValue": {
 *          "inStock": true,
 *          "quantity": 50
 *        },
 *        "id": "00000000-0000-0000-0000-000000000000"
 *      }
 *    ],
 *    "externalId": "8fe8f05f-951e-1563-b917-88adf8284543",
 *    "inventoryItemId": "70170fa0-6ae1-ea9c-46e8-775207d7babc"
 *  }
 */

VariantInventoryValue

An object representing a product variant value.

Syntax

type VariantInventoryValue = {
  inStock: boolean
  quantity: number
}
MEMBERS
?
The properties of an object.
inStock
boolean
Whether the variant is in stock.
quantity
number
Number of items in stock.

Examples

An event when product variant inventory information is updated

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

export function wixStores_onInventoryVariantUpdated(event) {
  let inventoryItemId = event.inventoryItemId;
  let firstVariant = event.variants[0];
  let firstNewQuantity = firstVariant.newValue.quantity;
}

/*  Full event object:
 *  { 
 *    "variants": [
 *      { 
 *        "oldValue": {
 *          "inStock": true,
 *          "quantity": 10
 *        },
 *        "newValue": {
 *          "inStock": true,
 *          "quantity": 50
 *        },
 *        "id": "00000000-0000-0000-0000-000000000000"
 *      }
 *    ],
 *    "externalId": "8fe8f05f-951e-1563-b917-88adf8284543",
 *    "inventoryItemId": "70170fa0-6ae1-ea9c-46e8-775207d7babc"
 *  }
 */

VariantsUpdatedEvent

An object representing product variants that were updated.

Syntax

type VariantsUpdatedEvent = {
  productId: string
  variants: Array<UpdatedVariant>
}
MEMBERS
?
The properties of an object.
productId
string
ID of the product in which variants were updated.
variants
Variants that were updated.

Examples

An event when a product variant information is updated

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

export function wixStores_onVariantsUpdated(event) {
  let productId = event.productId;
  let firstVariant = event.variants[0];
}

/*  Full event object:
 *  { 
 *   "variants":[ 
 *     { 
 *       "updatedFields":[ 
 *         "price"
 *       ],
 *       "choices":{ 
 *         "Color":"Red"
 *       },
 *       "variantId":"00000000-0000-0001-0005-970d993bafe9"
 *     }, { 
 *       "updatedFields":[ 
 *         "sku"
 *       ],
 *       "choices":{ 
 *         "Color":"Blue"
 *       },
 *       "variantId":"00000000-0000-0002-0005-970d993bafe9"
 *     }
 *   ],
 *   "productId":"1a2d7e83-4bef-31d5-09e1-3326ee271c09"
 * }
 */