Introduction

Wix eCommerce events are fired on your site's backend when certain events occur related to eCommerce carts, current carts, checkouts, orders, and more. You can write event handlers that react to these events. Event handler functions receive data that corresponds to the event that fired. Use event handlers to create custom responses to eCommerce events.

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

To add an eCommerce (ecom) 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:

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

For example, an event handler that handles the creation of a cart looks like this:

Copy
export function wixEcom_onCartCreated(event) {}
Did this help?

onDiscountRuleCreated( )


An event that is triggered when a discount rule is created.

The onDiscountRuleCreated() event handler runs when a discount rule is created. The DiscountRuleCreated object contains information about the discount rule that was created.

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

Method Declaration
Copy
function wixEcomDiscounts_onDiscountRuleCreated(
  event: DiscountRuleCreated,
): void;
Method Parameters
eventDiscountRuleCreated

Information about the discount rule that was created.

onDiscountRuleCreated example
JavaScript
export function wixEcomDiscounts_onDiscountRuleCreated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onDiscountRuleDeleted( )


An event that is triggered when a discount rule is deleted.

The onDiscountRuleDeleted() event handler runs when a discount rule is deleted. The received DiscountRuleDeleted object contains event metadata.

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

Method Declaration
Copy
function wixEcomDiscounts_onDiscountRuleDeleted(
  event: DiscountRuleDeleted,
): void;
Method Parameters
eventDiscountRuleDeleted

Information about the discount rule that was deleted.

onDiscountRuleDeleted example
JavaScript
export function wixEcomDiscounts_onDiscountRuleDeleted(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onDiscountRuleUpdated( )


An event that is triggered when a discount rule is updated.

The onDiscountRuleUpdated() event handler runs when a discount rule is updated. The received DiscountRuleUpdated object contains information about the discount rule that was updated.

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

Method Declaration
Copy
function wixEcomDiscounts_onDiscountRuleUpdated(
  event: DiscountRuleUpdated,
): void;
Method Parameters
eventDiscountRuleUpdated

Information about the discount rule that was updated.

onDiscountRuleUpdated example
JavaScript
export function wixEcomDiscounts_onDiscountRuleUpdated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onAbandonedCheckoutRecovered( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

An event that triggers when an abandoned checkout is recovered (the customer completes the checkout).

The onAbandonedCheckoutCreated() event handler runs when an abandoned checkout is recovered. The AbandonedCheckoutRecoveredEvent object contains information about the abandoned checkout that was recovered, and the event metadata.

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

Method Declaration
Copy
function wixEcom_onAbandonedCheckoutRecovered(
  event: AbandonedCheckoutRecoveredEvent,
): void;
Method Parameters
eventAbandonedCheckoutRecoveredEvent

Information about the abandoned checkout that was recovered.

An event fired when an abandoned checkout is recovered
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onAbandonedCheckoutRecovered(event) { const abandonedCheckoutId = event.metadata.entityId; const buyerEmail = event.data.abandonedCheckout.buyerInfo.email; console.log("Abandoned checkout recovered", event); } /* Full event object: * { * "entity": { * "_createdDate": "2021-10-12T00:18:03.045Z", * "_id": "bea905ef-d7cb-49b9-bce7-19342d3e7ab3", * "_updatedDate": "2022-06-17T00:18:03.046Z", * "activities": [ * { * "createdDate": "2022-09-10T11:49:08.538Z", * "type": "SCHEDULED" * }, * { * "createdDate": "2023-04-30T11:55:01.969Z", * "type": "EMAIL_SENT" * } * ], * "buyerInfo": { * "contactId": "77efeff1f-02c3-4a3b-bd7a-2cb4ab8e9a67", * "email":"mabel@go.com", * "visitorId":"ea24a72d-4084-4ecd-b36c-541c5d0a82c9" * }, * "buyerLanguage": "en", * "cartId": "10cd2c69-20ea-48b8-a015-a943d295392a", * "checkoutId": "a778cd2c69-20ea-48b8-a015-b56912", * "checkoutRecoveredDate": "2023-12-30T11:55:01.969Z" * "checkoutUrl": "http://www.wixapis.com/ecom/v1/abandoned-checkout/7-9665-bb42bf3b8e86/redirect-to-checkout?metasiteId=548f24ea-a663fb0f-9e2e-f431506133" * "contactDetails": { * "firstName": "Mabel", * "lastName": "Goza" * }, * "conversionCurrency": "EUR", * "currency":"EUR", * "totalPrice": { * "amount": "45", * "convertedAmount": "45", * "formattedAmount": "€45.00", * "formattedConvertedAmount": "€45.00" * } * "metadata": { * "entityId": "c434acce-84f8-4f67-9665-bb42bf448e86", * "eventTime":"2023-12-13T13:16:11.629738Z", * "id": "9b1a7beb-6beb-4591-8e3a-280b5972c548", * "triggeredByAnonymizeRequest": false * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onBackInStockNotificationRequestCreated( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Triggered when a back in stock notification request is created.

The onBackInStockNotificationRequestCreated() event handler runs when a back in stock notification request is created. The received BackInStockNotificationRequestCreated object contains information about the back in stock notification request that was created and event metadata.

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

Method Declaration
Copy
function wixEcom_onBackInStockNotificationRequestCreated(
  event: BackInStockNotificationRequestCreated,
): void;
Method Parameters
eventBackInStockNotificationRequestCreated

Information about the back in stock notification request that was created.

onBackInStockNotificationRequestCreated example
JavaScript
export function wixEcom_onBackInStockNotificationRequestCreated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onBackInStockNotificationRequestDeleted( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Triggered when a back in stock notification request is deleted.

The onBackInStockNotificationRequestDeleted() event handler runs when a back in stock notification request is deleted. The received BackInStockNotificationRequestDeleted object contains event metadata.

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

Method Declaration
Copy
function wixEcom_onBackInStockNotificationRequestDeleted(
  event: BackInStockNotificationRequestDeleted,
): void;
Method Parameters
eventBackInStockNotificationRequestDeleted

Information about the back in stock notification request that was deleted.

onBackInStockNotificationRequestDeleted example
JavaScript
export function wixEcom_onBackInStockNotificationRequestDeleted(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onBackInStockNotificationRequestUpdated( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Triggered when a back in stock notification request is updated.

The onBackInStockNotificationRequestUpdated() event handler runs when a back in stock notification request is updated. The received BackInStockNotificationRequestUpdated object contains information about the back in stock notification request that was updated and event metadata.

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

Method Declaration
Copy
function wixEcom_onBackInStockNotificationRequestUpdated(
  event: BackInStockNotificationRequestUpdated,
): void;
Method Parameters
eventBackInStockNotificationRequestUpdated

Information about the back in stock notification request that was updated.

onBackInStockNotificationRequestUpdated example
JavaScript
export function wixEcom_onBackInStockNotificationRequestUpdated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCartCreated( )


An event that triggers when a new cart is created.

The onCartCreated() event handler runs when a new cart is created. The received CartCreated object contains information about the cart that was created and event metadata.

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

Method Declaration
Copy
function wixEcom_onCartCreated(event: CartCreated): void;
Method Parameters
eventCartCreated

Information about the cart that was created and event metadata.

An event fired when a cart is created
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onCartCreated(event) { const cartSubtotal = event.entity.subtotal.amount; const cartId = event.entity._id; const eventId = event.metadata.id; console.log("Cart created", event); } /* Full event object: * * { * "metadata": { * "id": "ba8e0c2e-dd90-4060-b83c-2590aa075b65", * "entityId": "1c68f377-4e8f-47c1-bc72-01b18a23cb08", * "eventTime": "2022-07-04T12:47:21.376865Z", * "triggeredByAnonymizeRequest": false * }, * "entity": { * "_id": "1c68f377-4e8f-47c1-bc72-01b18a23cb08", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 3, * "catalogReference": { * "catalogItemId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "variantId": "e62fee23-7878-437a-bf0e-292f17d11cb5" * } * }, * "productName": { * "original": "Shoe", * "translated": "Shoe" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "fullPrice": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "priceBeforeDiscounts": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Black", * "translated": "Black", * "code": "#000" * }, * "lineType": "UNRECOGNISED" * } * ], * "image": "wix:image://v1/3c76e2_bf235c38610f4d2a905db71095b351cf~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE", * "quantityAvailable": 30 * }, * "physicalProperties": { * "sku": "364215376135191", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE" * } * ], * "buyerInfo": { * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7" * }, * "currency": "USD", * "conversionCurrency": "USD", * "buyerLanguage": "en", * "siteLanguage": "en", * "taxIncludedInPrices": false, * "weightUnit": "KG", * "subtotal": { * "amount": "255", * "convertedAmount": "255", * "formattedAmount": "$255.00", * "formattedConvertedAmount": "$255.00" * }, * "appliedDiscounts": [], * "inSync": false, * "_createdDate": "2022-07-04T12:47:21.371Z", * "_updatedDate": "2022-07-04T12:47:21.371Z" * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCartDeleted( )


An event that triggers when a cart is deleted.

The onCartDeleted() event handler runs when a cart is deleted. The received CartDeleted object contains event metadata.

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

Method Declaration
Copy
function wixEcom_onCartDeleted(event: CartDeleted): void;
Method Parameters
eventCartDeleted

Event metadata.

An event fired when a cart is deleted
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onCartDeleted(event) { const cartId = event.metadata.entityId; console.log("Cart deleted", event); } /* Full event object: * * { * "metadata": { * "id": "c3500825-f582-4755-81b3-fa55b8585e5c", * "entityId": "19716650-fd62-4e3a-b98b-7e196d0e88a3", * "eventTime": "2022-07-28T08:36:02.227138Z", * "triggeredByAnonymizeRequest": false * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCartUpdated( )


An event that triggers when a cart is updated.

The onCartUpdated() event handler runs when a cart is updated. The received CartUpdated object contains information about the cart that was updated and event metadata.

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

Method Declaration
Copy
function wixEcom_onCartUpdated(event: CartUpdated): void;
Method Parameters
eventCartUpdated

Information about the cart that was updated and event metadata.

An event fired when a cart is updated
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onCartUpdated(event) { const cartSubtotal = event.entity.subtotal.amount; const cartId = event.entity._id; const eventId = event.metadata.id; console.log("Cart updated", event); } /* Full event object: * * { * "metadata": { * "id": "e508b5f9-a7d2-4b37-94ce-2b7767cfa49c", * "entityId": "b79fd177-ec98-4245-b9f6-f09e7afa9d04", * "eventTime": "2022-10-27T11:42:17.211724Z", * "triggeredByAnonymizeRequest": false * }, * "entity": { * "_id": "b79fd177-ec98-4245-b9f6-f09e7afa9d04", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 2, * "catalogReference": { * "catalogItemId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "variantId": "e62fee23-7878-437a-bf0e-292f17d11cb5" * } * }, * "productName": { * "original": "Shoe", * "translated": "Shoe" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "fullPrice": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "priceBeforeDiscounts": { * "amount": "85", * "convertedAmount": "85", * "formattedAmount": "$85.00", * "formattedConvertedAmount": "$85.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Black", * "translated": "Black", * "code": "#000" * }, * "lineType": "UNRECOGNISED" * } * ], * "image": "wix:image://v1/3c76e2_bf235c38610f4d2a905db71095b351cf~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE", * "quantityAvailable": 30 * }, * "physicalProperties": { * "sku": "364215376135191", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "df19c1f7-07d8-a265-42f8-e8dfa824cc6e" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE" * }, * { * "_id": "00000000-0000-0000-0000-000000000002", * "quantity": 3, * "catalogReference": { * "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "variantId": "132b84e8-aab8-47a1-a1f6-2c47557b64a4" * } * }, * "productName": { * "original": "Watch", * "translated": "Watch" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "fullPrice": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "priceBeforeDiscounts": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Size", * "translated": "Size" * }, * "plainText": { * "original": "Medium", * "translated": "Medium" * }, * "lineType": "UNRECOGNISED" * }, * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Grey", * "translated": "Grey", * "code": "rgb(128, 128, 128)" * }, * "lineType": "UNRECOGNISED" * } * ], * "image": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE" * }, * "physicalProperties": { * "sku": "217537123517253", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE" * } * ], * "buyerInfo": { * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7" * }, * "currency": "USD", * "conversionCurrency": "USD", * "buyerLanguage": "en", * "siteLanguage": "en", * "taxIncludedInPrices": false, * "weightUnit": "KG", * "subtotal": { * "amount": "260", * "convertedAmount": "260", * "formattedAmount": "$260.00", * "formattedConvertedAmount": "$260.00" * }, * "appliedDiscounts": [], * "inSync": false, * "_createdDate": "2022-06-22T11:32:29.601Z", * "_updatedDate": "2022-07-03T13:19:26.450Z" * }, * "metadata": { * "id": "cac6f823-0ec7-4dd0-9147-48738c76134c", * "entityId": "b79fd177-ec98-4245-b9f6-f09e7afa9d04", * "eventTime": "2022-07-03T13:19:26.458843Z", * "triggeredByAnonymizeRequest": false * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCheckoutCompleted( )


An event that triggers when a checkout is completed. This happens either when an order is created from a checkout, or after using markCheckoutAsCompleted().

The onCheckoutCompleted() event handler runs when a checkout is completed. The received CheckoutCompleted object contains information about the checkout that was completed and event metadata.

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

Method Declaration
Copy
function wixEcom_onCheckoutCompleted(event: CheckoutCompleted): void;
Method Parameters
eventCheckoutCompleted

Information about the checkout that was completed and event metadata.

An event fired when a checkout is completed
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onCheckoutCompleted(event) { const checkoutSubtotal = event.entity.subtotal.amount; const checkoutId = event.entity._id; const checkoutComplete = event.entity.completed; const eventId = event.metadata.id; console.log("Checkout completed", event); } /* Full event object: * * { * "metadata": { * "id": "d94b500b-3906-434f-bd90-92c521e4f0e3", * "entityId": "81b73bc6-d403-4afe-8464-226f9505b1c2", * "eventTime": "2022-10-27T11:58:12.667470Z", * "triggeredByAnonymizeRequest": false * }, * "data": { * "checkout": { * "_id": "81b73bc6-d403-4afe-8464-226f9505b1c2", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 3, * "catalogReference": { * "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e" * }, * "productName": { * "original": "Shirt", * "translated": "Shirt" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "lineItemPrice": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "fullPrice": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "priceBeforeDiscounts": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "totalPriceAfterTax": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "totalPriceBeforeTax": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "taxDetails": { * "taxableAmount": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "taxRate": "0", * "totalTax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "rateBreakdown": [] * }, * "discount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "descriptionLines": [], * "media": "wix:image://v1/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE" * }, * "physicalProperties": { * "sku": "364115376135191", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "c8539b66-7a44-fe18-affc-afec4be8562a" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "rootCatalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a" * } * ], * "shippingInfo": { * "carrierServiceOptions": [] * }, * "buyerInfo": { * "contactId": "f7dc17a6-825a-466e-a78e-c4abea0217db", * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "conversionCurrency": "USD", * "priceSummary": { * "subtotal": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "shipping": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "total": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "calculationErrors": { * "orderValidationErrors": [] * }, * "appliedDiscounts": [ * { * "discountType": "GLOBAL", * "lineItemIds": [], * "coupon": { * "_id": "fbb94b06-7447-4161-9c48-59bfcdc39e77", * "code": "SUMMERSALE10", * "amount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "name": "SUMMERSALE10", * "couponType": "MoneyOff" * } * } * ], * "customFields": [], * "weightUnit": "KG", * "currency": "USD", * "channelType": "WEB", * "siteLanguage": "en", * "buyerLanguage": "en", * "completed": true, * "taxIncludedInPrice": false, * "createdBy": { * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "_createdDate": "2022-10-27T11:42:17.059Z", * "_updatedDate": "2022-10-27T11:58:12.657Z", * "payNow": { * "subtotal": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "shipping": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "total": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "payLater": { * "subtotal": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "shipping": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "total": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "membershipOptions": { * "eligibleMemberships": [], * "invalidMemberships": [], * "selectedMemberships": { * "memberships": [] * } * }, * "additionalFees": [] * } * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCheckoutCreated( )


An event that triggers when a new checkout is created. For example, when a checkout is created from a cart or after using createCheckout().

The onCheckoutCreated() event handler runs when a new checkout is created. The received CheckoutCreated object contains information about the checkout that was created and event metadata.

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

Method Declaration
Copy
function wixEcom_onCheckoutCreated(event: CheckoutCreated): void;
Method Parameters
eventCheckoutCreated

Information about the checkout that was created and event metadata.

An event fired when a checkout is created
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onCheckoutCreated(event) { const checkoutSubtotal = event.entity.subtotal.amount; const checkoutId = event.entity._id; const eventId = event.metadata.id; console.log("Checkout created", event); } /* Full event object: * * { * "metadata": { * "id": "10fca682-f0e5-4392-9f1e-ba26a28ec077", * "entityId": "0939cbe9-72eb-47ad-bcbc-7c1ff0e0c9da", * "eventTime": "2022-10-27T11:25:35.848718Z", * "triggeredByAnonymizeRequest": false * }, * "entity": { * "_id": "0939cbe9-72eb-47ad-bcbc-7c1ff0e0c9da", * "_createdDate": "2022-10-27T11:25:35.840Z", * "_updatedDate": "2022-10-27T11:25:35.840Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 3, * "catalogReference": { * "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e" * }, * "productName": { * "original": "Shirt", * "translated": "Shirt" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "lineItemPrice": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "fullPrice": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "priceBeforeDiscounts": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "totalPriceAfterTax": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "totalPriceBeforeTax": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "taxDetails": { * "taxableAmount": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "taxRate": "0", * "totalTax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "rateBreakdown": [] * }, * "discount": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "descriptionLines": [], * "media": "wix:image://v1/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE" * }, * "physicalProperties": { * "sku": "364115376135191", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "c8539b66-7a44-fe18-affc-afec4be8562a" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "rootCatalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a" * } * ], * "shippingInfo": { * "carrierServiceOptions": [] * }, * "buyerInfo": { * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "conversionCurrency": "USD", * "priceSummary": { * "subtotal": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "shipping": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "total": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "calculationErrors": { * "orderValidationErrors": [] * }, * "appliedDiscounts": [], * "customFields": [], * "weightUnit": "KG", * "currency": "USD", * "channelType": "WEB", * "siteLanguage": "en", * "buyerLanguage": "en", * "completed": false, * "taxIncludedInPrice": false, * "createdBy": { * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "payNow": { * "subtotal": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "shipping": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "total": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "payLater": { * "subtotal": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "shipping": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "total": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "membershipOptions": { * "eligibleMemberships": [], * "invalidMemberships": [], * "selectedMemberships": { * "memberships": [] * } * }, * "additionalFees": [] * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCheckoutUpdated( )


An event that triggers when a checkout is updated. A checkout is updated when, for example, items are added or a coupon is removed.

The onCheckoutUpdated() event handler runs when a new checkout is updated. The received CheckoutUpdated object contains information about the checkout that was updated and event metadata.

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

Method Declaration
Copy
function wixEcom_onCheckoutUpdated(event: CheckoutUpdated): void;
Method Parameters
eventCheckoutUpdated

Information about the checkout that was updated and event metadata.

An event fired when a checkout is updated
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onCheckoutUpdated(event) { const checkoutSubtotal = event.entity.subtotal.amount; const checkoutId = event.entity._id; const eventId = event.metadata.id; console.log("Checkout updated", event); } /* Full event object: * * { * "metadata": { * "id": "e508b5f9-a7d2-4b37-94ce-2b7767cfa49c", * "entityId": "81b73bc6-d403-4afe-8464-226f9505b1c2", * "eventTime": "2022-10-27T11:42:17.211724Z", * "triggeredByAnonymizeRequest": false * }, * "entity": { * "_id": "81b73bc6-d403-4afe-8464-226f9505b1c2", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 3, * "catalogReference": { * "catalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e" * }, * "productName": { * "original": "Shirt", * "translated": "Shirt" * }, * "url": "https://example.wixsite.com", * "price": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "lineItemPrice": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "fullPrice": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "priceBeforeDiscounts": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "totalPriceAfterTax": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "totalPriceBeforeTax": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "taxDetails": { * "taxableAmount": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "taxRate": "0", * "totalTax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "rateBreakdown": [] * }, * "discount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "descriptionLines": [], * "media": "wix:image://v1/3c76e2_c5331f937348492a97df87b0a3b34ea4~mv2.jpg#originWidth=1000&originHeight=1000", * "availability": { * "status": "AVAILABLE" * }, * "physicalProperties": { * "sku": "364115376135191", * "shippable": true * }, * "couponScopes": [ * { * "namespace": "stores", * "group": { * "name": "collection", * "entityId": "00000000-000000-000000-000000000001" * } * }, * { * "namespace": "stores", * "group": { * "name": "product", * "entityId": "c8539b66-7a44-fe18-affc-afec4be8562a" * } * } * ], * "itemType": { * "preset": "PHYSICAL" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "rootCatalogItemId": "c8539b66-7a44-fe18-affc-afec4be8562a" * } * ], * "shippingInfo": { * "carrierServiceOptions": [] * }, * "buyerInfo": { * "contactId": "f7dc17a6-825a-466e-a78e-c4abea0217db", * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "conversionCurrency": "USD", * "priceSummary": { * "subtotal": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "shipping": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "total": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "calculationErrors": { * "orderValidationErrors": [] * }, * "appliedDiscounts": [ * { * "discountType": "GLOBAL", * "lineItemIds": [], * "coupon": { * "_id": "fbb94b06-7447-4161-9c48-59bfcdc39e77", * "code": "SUMMERSALE10", * "amount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "name": "SUMMERSALE10", * "couponType": "MoneyOff" * } * } * ], * "customFields": [], * "weightUnit": "KG", * "currency": "USD", * "channelType": "WEB", * "siteLanguage": "en", * "buyerLanguage": "en", * "completed": false, * "taxIncludedInPrice": false, * "createdBy": { * "memberId": "c43190d2-eea3-493e-b6e8-f146850c6873" * }, * "_createdDate": "2022-10-27T11:42:17.059Z", * "_updatedDate": "2022-10-27T11:42:17.201Z", * "payNow": { * "subtotal": { * "amount": "30", * "convertedAmount": "30", * "formattedAmount": "$30.00", * "formattedConvertedAmount": "$30.00" * }, * "shipping": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "10", * "convertedAmount": "10", * "formattedAmount": "$10.00", * "formattedConvertedAmount": "$10.00" * }, * "total": { * "amount": "20", * "convertedAmount": "20", * "formattedAmount": "$20.00", * "formattedConvertedAmount": "$20.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "payLater": { * "subtotal": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "shipping": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "tax": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "discount": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "total": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * }, * "additionalFees": { * "amount": "0", * "convertedAmount": "0", * "formattedAmount": "$0.00", * "formattedConvertedAmount": "$0.00" * } * }, * "membershipOptions": { * "eligibleMemberships": [], * "invalidMemberships": [], * "selectedMemberships": { * "memberships": [] * } * }, * "additionalFees": [] * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCheckoutSettingsUpdated( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Triggered when checkout settings are updated.

The onCheckoutSettingsUpdated() event handler runs when checkout settings are updated. The received CheckoutSettingsUpdated object contains information about the checkout settings that were updated and event metadata.

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

Method Declaration
Copy
function wixEcom_onCheckoutSettingsUpdated(
  event: CheckoutSettingsUpdated,
): void;
Method Parameters
eventCheckoutSettingsUpdated

Information about the checkout settings that were updated and event metadata.

onCheckoutSettingsUpdated example
JavaScript
export function wixEcom_onCheckoutSettingsUpdated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCheckoutTemplateCreated( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Triggered when a checkout template is created.

The onCheckoutTemplateCreated() event handler runs when a checkout template is created. The received CheckoutTemplateCreated object contains information about the checkout template that was created and event metadata.

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

Method Declaration
Copy
function wixEcom_onCheckoutTemplateCreated(
  event: CheckoutTemplateCreated,
): void;
Method Parameters
eventCheckoutTemplateCreated

Information about the checkout template that was created and event metadata.

onCheckoutTemplateCreated example
JavaScript
export function wixEcom_onCheckoutTemplateCreated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCheckoutTemplateDeleted( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Triggered when a checkout template is deleted.

The onCheckoutTemplateDeleted() event handler runs when a checkout template is deleted. The received CheckoutTemplateDeleted object contains information about the checkout template that was deleted and event metadata.

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

Method Declaration
Copy
function wixEcom_onCheckoutTemplateDeleted(
  event: CheckoutTemplateDeleted,
): void;
Method Parameters
eventCheckoutTemplateDeleted

Information about the checkout template that was deleted and event metadata.

onCheckoutTemplateDeleted example
JavaScript
export function wixEcom_onCheckoutTemplateDeleted(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCheckoutTemplateUpdated( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Triggered when a checkout template is updated.

The onCheckoutTemplateUpdated() event handler runs when a checkout template is updated. The received CheckoutTemplateUpdated object contains information about the checkout template that was updated and event metadata.

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

Method Declaration
Copy
function wixEcom_onCheckoutTemplateUpdated(
  event: CheckoutTemplateUpdated,
): void;
Method Parameters
eventCheckoutTemplateUpdated

Information about the checkout template that was updated and event metadata.

onCheckoutTemplateUpdated example
JavaScript
export function wixEcom_onCheckoutTemplateUpdated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onCheckoutTemplateUsed( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Triggered when a checkout template is used to create a checkout.

The onCheckoutTemplateUsed() event handler runs when a checkout template is created. The received CheckoutTemplateUsedEvent object contains information about the checkout template that was used, the checkout that was created, and event metadata.

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

Method Declaration
Copy
function wixEcom_onCheckoutTemplateUsed(event: CheckoutTemplateUsedEvent): void;
Method Parameters
eventCheckoutTemplateUsedEvent

Information about the checkout template that was used to create a checkout and event metadata.

onCheckoutTemplateUsed example
JavaScript
export function wixEcom_onCheckoutTemplateUsed(event) { const eventId = event.metadata.id; const entityId = event.data.checkoutTemplate._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onFulfillmentsUpdated( )


An event that triggers when one or more of an order's fulfillments are created, updated, or deleted.

The onFulfillmentsUpdated() event handler runs when a fulfillment is updated. The received object contains information about the fulfillment that was updated and event metadata.

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

Method Declaration
Copy
function wixEcom_onFulfillmentsUpdated(event: FulfillmentsUpdated): void;
Method Parameters
eventFulfillmentsUpdated

Information about the fulfillments that were updated.

An event fired when an order fulfillment is updated
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onFulfillmentsUpdated(event) { const orderId = event.entity.orderId; const fulfillmentId = event.entity.fulfillments[0]._id; const eventId = event.metadata.id; console.log("Fulfillment updated", event); } /* Full event object: * * { * "metadata": { * "id": "aa6bf186-a19f-4085-8726-11fde6b629f7", * "entityId": "a6c3a817-579d-4cb5-8521-2fe53b2c4bf1", * "eventTime": "2023-03-08T11:04:15.512044Z", * "triggeredByAnonymizeRequest": false * }, * "entity": { * "orderId": "a6c3a817-579d-4cb5-8521-2fe53b2c4bf1", * "fulfillments": [ * { * "_id": "a838877d-3f13-49f3-ab29-1cde478e0949", * "_createdDate": "2023-03-07T14:30:21.535Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "quantity": 1 * } * ], * "trackingInfo": { * "trackingNumber": "12345", * "shippingProvider": "usps", * "trackingLink": "https://tools.usps.com/go/TrackConfirmAction.action?tLabels=12345" * } * } * ] * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onOrderApproved( )


An event that triggers when an order is approved.

The onOrderApproved() event handler runs when an order is created and its status is updated to "APPROVED". The received OrderApprovedEvent object contains information about the order that was approved and event metadata.

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

Method Declaration
Copy
function wixEcom_onOrderApproved(event: OrderApprovedEvent): void;
Method Parameters
eventOrderApprovedEvent

Information about the order that was approved and metadata for the event.

An event fired when an order is approved
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onOrderApproved(event) { const orderId = event.data.order._id; const orderTotalPrice = event.data.order.priceSummary.totalPrice.amount; const eventId = event.metadata.id; console.log("Order approved", event); } /* Full event object: * * { * "metadata": { * "id": "8f0a09a4-1fd1-4ff2-976a-21f1b2e0fe2f", * "entityId": "67668940-527d-4465-94c6-5475d8c7a412", * "eventTime": "2022-07-31T13:42:20.141721Z", * "triggeredByAnonymizeRequest": false * }, * "data": { * "order": { * "_id": "67668940-527d-4465-94c6-5475d8c7a412", * "number": "10124", * "_createdDate": "2022-07-31T13:42:13.136Z", * "_updatedDate": "2022-07-31T13:42:20.026Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "productName": { * "original": "Brazilian Arabica", * "translated": "Brazilian Arabica" * }, * "catalogReference": { * "catalogItemId": "0614129c-8777-9f3b-4dfe-b80a54df10d5", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "options": { * "Weight": "500g", * "Ground for": "Stovetop" * }, * "variantId": "00000000-0000-003f-0005-a316f7c67df7", * "customTextFields": { * "What would you like written on the custom label?": "Enjoy our finest coffee." * } * } * }, * "quantity": 1, * "totalDiscount": { * "amount": "0", * "formattedAmount": "$0.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Weight", * "translated": "Weight" * }, * "plainText": { * "original": "500g", * "translated": "500g" * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "500g", * "translated": "500g" * } * }, * { * "name": { * "original": "Ground for", * "translated": "Ground for" * }, * "plainText": { * "original": "Stovetop", * "translated": "Stovetop" * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "Stovetop", * "translated": "Stovetop" * } * }, * { * "name": { * "original": "What would you like written on the custom label?", * "translated": "What would you like written on the custom label?" * }, * "plainText": { * "original": "Enjoy our finest coffee.", * "translated": "Enjoy our finest coffee." * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "Enjoy our finest coffee.", * "translated": "Enjoy our finest coffee." * } * } * ], * "image": "wix:image://v1/nsplsh_306d666a306a4a74306459~mv2_d_4517_2992_s_4_2.jpg#originWidth=4517&originHeight=2992", * "physicalProperties": { * "weight": 0.5, * "shippable": true * }, * "itemType": { * "preset": "PHYSICAL" * }, * "fulfillerId": "85e29287-a5bf-4c25-b303-a2ddc9d975e2", * "refundQuantity": 0, * "price": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "priceBeforeDiscounts": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "totalPriceBeforeTax": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "totalPriceAfterTax": { * "amount": "50.70", * "formattedAmount": "$50.70" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "taxDetails": { * "taxableAmount": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "taxRate": "0.04", * "totalTax": { * "amount": "1.95", * "formattedAmount": "$1.95" * } * } * } * ], * "buyerInfo": { * "contactId": "f61f30cd-7474-47b7-95a2-339c0fcacbd3", * "email": "janedoe@gmail.com", * "visitorId": "b52ec002-40dd-469c-9f9f-833988e8048d" * }, * "paymentStatus": "PAID", * "fulfillmentStatus": "NOT_FULFILLED", * "buyerLanguage": "en", * "weightUnit": "LB", * "currency": "USD", * "taxIncludedInPrices": false, * "priceSummary": { * "subtotal": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "shipping": { * "amount": "5.0", * "formattedAmount": "$5.00" * }, * "tax": { * "amount": "1.95", * "formattedAmount": "$1.95" * }, * "discount": { * "amount": "0", * "formattedAmount": "$0.00" * }, * "totalPrice": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "totalWithGiftCard": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "totalWithoutGiftCard": { * "amount": "55.70", * "formattedAmount": "$55.70" * } * }, * "billingInfo": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * }, * "shippingInfo": { * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc", * "code": "a0fde0a4-6f4e-3716-64be-c0acbde1696a", * "title": "U.S Shipping", * "logistics": { * "deliveryTime": "3 - 5 business days", * "shippingDestination": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * } * }, * "cost": { * "price": { * "amount": "5", * "formattedAmount": "$5.00" * }, * "totalPriceBeforeTax": { * "amount": "5", * "formattedAmount": "$5.00" * }, * "totalPriceAfterTax": { * "amount": "5.0", * "formattedAmount": "$5.00" * }, * "taxDetails": { * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * }, * "discount": { * "amount": "0", * "formattedAmount": "$0.00" * } * }, * "region": { * "name": "Region 3" * } * }, * "buyerNote": "This is a buyerNote", * "status": "APPROVED", * "archived": false, * "taxSummary": { * "totalTax": { * "amount": "1.95", * "formattedAmount": "$1.95" * }, * "manualTaxRate": "0.04" * }, * "appliedDiscounts": [], * "activities": [ * { * "_createdDate": "2022-07-31T13:42:13.136Z", * "type": "ORDER_PLACED" * } * ], * "attributionSource": "UNSPECIFIED", * "createdBy": { * "visitorId": "b52ec002-40dd-469c-9f9f-833988e8048d" * }, * "channelInfo": { * "type": "WEB" * }, * "seenByAHuman": false, * "checkoutId": "62d01935-e0d3-4063-9e78-da099462e90c", * "customFields": [], * "cartId": "52fec024-4379-4a96-9237-9660030be6fe", * "payNow": { * "subtotal": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "shipping": { * "amount": "5.0", * "formattedAmount": "$5.00" * }, * "tax": { * "amount": "1.95", * "formattedAmount": "$1.95" * }, * "discount": { * "amount": "0", * "formattedAmount": "$0.00" * }, * "totalPrice": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "totalWithGiftCard": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "totalWithoutGiftCard": { * "amount": "55.70", * "formattedAmount": "$55.70" * } * }, * "balanceSummary": { * "balance": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * } * } * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onOrderCanceled( )


Triggered when an order is canceled.

The onOrderCanceled() event handler runs when an order is canceled. The received OrderCanceled object contains information about the order that was canceled, details related to the cancelation, and event metadata.

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

Method Declaration
Copy
function wixEcom_onOrderCanceled(event: OrderCanceled): void;
Method Parameters
eventOrderCanceled

Information about the order that was canceled.

An event fired when an order is canceled
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onOrderCanceled(event) { const orderId = event.data.order._id; const orderStatus = event.data.order.status; const restockAllItems = event.data.restockAllItems; const eventId = event.metadata.id; console.log("Order canceled", event); } /* Full event object: * * { * "metadata": { * "id": "a9a15029-aee6-4a74-9744-6a0ee5cc7258", * "entityId": "7a8b195e-ab73-4138-b9da-cdf5e864a451", * "eventTime": "2023-01-16T14:44:37.686245Z", * "triggeredByAnonymizeRequest": false * }, * "data": { * "order": { * "_id": "7a8b195e-ab73-4138-b9da-cdf5e864a451", * "number": "10003", * "_createdDate": "2023-01-16T13:53:10.776Z", * "_updatedDate": "2023-01-16T14:44:37.554Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "productName": { * "original": "Watch", * "translated": "Watch" * }, * "catalogReference": { * "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "options": { * "Size": "Medium", * "Color": "Black" * }, * "variantId": "e309b2f2-2166-4927-a137-0e5dfb870627" * } * }, * "quantity": 1, * "totalDiscount": { * "amount": "0", * "formattedAmount": "$0.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Size", * "translated": "Size" * }, * "plainText": { * "original": "Medium", * "translated": "Medium" * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "Medium", * "translated": "Medium" * } * }, * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Black", * "translated": "Black" * }, * "lineType": "COLOR", * "color": "Black" * } * ], * "image": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000", * "physicalProperties": { * "sku": "217537123517253", * "shippable": true * }, * "itemType": { * "preset": "PHYSICAL" * }, * "refundQuantity": 0, * "restockQuantity": 1, * "price": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "priceBeforeDiscounts": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "totalPriceBeforeTax": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "totalPriceAfterTax": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "taxDetails": { * "taxableAmount": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * } * } * ], * "buyerInfo": { * "contactId": "24de6f0b-60ce-4faa-9138-2e39f1415615", * "email": "janedoe8@gmail.com", * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7" * }, * "paymentStatus": "FULLY_REFUNDED", * "fulfillmentStatus": "NOT_FULFILLED", * "buyerLanguage": "en", * "weightUnit": "KG", * "currency": "USD", * "taxIncludedInPrices": false, * "priceSummary": { * "subtotal": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "shipping": { * "amount": "10.0", * "formattedAmount": "$10.00" * }, * "tax": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "discount": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "totalPrice": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "total": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithoutGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalAdditionalFees": { * "amount": "0", * "formattedAmount": "$0.00" * } * }, * "billingInfo": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * }, * "shippingInfo": { * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc", * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "", * "shippingDestination": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * } * }, * "cost": { * "price": { * "amount": "10", * "formattedAmount": "$10.00" * }, * "totalPriceBeforeTax": { * "amount": "10", * "formattedAmount": "$10.00" * }, * "totalPriceAfterTax": { * "amount": "10.0", * "formattedAmount": "$10.00" * }, * "taxDetails": { * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * }, * "discount": { * "amount": "0", * "formattedAmount": "$0.00" * } * }, * "region": { * "name": "USA shipping" * } * }, * "status": "CANCELED", * "archived": false, * "taxSummary": { * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * }, * "appliedDiscounts": [], * "activities": [ * { * "_createdDate": "2023-01-16T13:53:10.776Z", * "type": "ORDER_PLACED" * }, * { * "_createdDate": "2023-01-16T14:38:48.249Z", * "type": "EMAIL_EDITED" * }, * { * "_createdDate": "2023-01-16T14:40:02.184Z", * "type": "ORDER_PAID" * }, * { * "_createdDate": "2023-01-16T14:44:36.766Z", * "orderRefunded": { * "manual": true, * "amount": { * "amount": "40", * "formattedAmount": "$40.00" * }, * "reason": "" * }, * "type": "ORDER_REFUNDED" * }, * { * "_createdDate": "2023-01-16T14:44:37.554Z", * "type": "ORDER_CANCELED" * } * ], * "attributionSource": "UNSPECIFIED", * "createdBy": { * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7" * }, * "channelInfo": { * "type": "WEB" * }, * "seenByAHuman": true, * "checkoutId": "9f24eba1-5b05-4c9e-90c5-1789a8239912", * "customFields": [], * "cartId": "eb8086a0-9389-4e92-91cb-5ce7bd9b3db8", * "payNow": { * "subtotal": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "shipping": { * "amount": "10.0", * "formattedAmount": "$10.00" * }, * "tax": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "discount": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "totalPrice": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "total": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithoutGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * } * }, * "balanceSummary": { * "balance": { * "amount": "40.00", * "formattedAmount": "$40.00" * } * }, * "additionalFees": [] * }, * "restockAllItems": true, * "sendOrderCanceledEmail": false * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onOrderCreated( )


Triggered when an order is created.

The onOrderCreated() event handler runs when an order is created. The received OrderCreated object contains information about the order that was created and event metadata.

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

Method Declaration
Copy
function wixEcom_onOrderCreated(event: OrderCreated): void;
Method Parameters
eventOrderCreated

Information about the order that was created.

onOrderCreated example
JavaScript
export function wixEcom_onOrderCreated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onOrderPaymentStatusUpdated( )


Triggered when an order's payment status is updated.

The onOrderPaymentStatusUpdated() event handler runs when an order's payment status is updated. The received OrderPaymentStatusUpdated object contains information about the order, the previous payment status, and event metadata.

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

Method Declaration
Copy
function wixEcom_onOrderPaymentStatusUpdated(
  event: OrderPaymentStatusUpdated,
): void;
Method Parameters
eventOrderPaymentStatusUpdated

Information about the updated order.

An event fired when an order's payment status is updated
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onOrderPaymentStatusUpdated(event) { const orderId = event.data.order._id; const currentPaymentStatus = event.data.order.paymentStatus; const previousPaymentStatus = event.data.previousPaymentStatus; const orderTotalPrice = event.data.order.priceSummary.totalPrice.amount; const eventId = event.metadata.id; console.log("Order payment status updated", event); } /* Full event object: * * { * "metadata": { * "id": "5a521f73-0824-40b8-af4c-86da30219db8", * "entityId": "7a8b195e-ab73-4138-b9da-cdf5e864a451", * "eventTime": "2023-01-16T14:40:02.119716Z", * "triggeredByAnonymizeRequest": false * }, * "data": { * "order": { * "_id": "7a8b195e-ab73-4138-b9da-cdf5e864a451", * "number": "10003", * "_createdDate": "2023-01-16T13:53:10.776Z", * "_updatedDate": "2023-01-16T14:40:01.997Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "productName": { * "original": "Watch", * "translated": "Watch" * }, * "catalogReference": { * "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "options": { * "Size": "Medium", * "Color": "Black" * }, * "variantId": "e309b2f2-2166-4927-a137-0e5dfb870627" * } * }, * "quantity": 1, * "totalDiscount": { * "amount": "0", * "formattedAmount": "$0.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Size", * "translated": "Size" * }, * "plainText": { * "original": "Medium", * "translated": "Medium" * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "Medium", * "translated": "Medium" * } * }, * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Black", * "translated": "Black" * }, * "lineType": "COLOR", * "color": "Black" * } * ], * "image": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000", * "physicalProperties": { * "sku": "217537123517253", * "shippable": true * }, * "itemType": { * "preset": "PHYSICAL" * }, * "refundQuantity": 0, * "price": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "priceBeforeDiscounts": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "totalPriceBeforeTax": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "totalPriceAfterTax": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "taxDetails": { * "taxableAmount": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * } * } * ], * "buyerInfo": { * "contactId": "24de6f0b-60ce-4faa-9138-2e39f1415615", * "email": "janedoe8@gmail.com", * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7" * }, * "paymentStatus": "PAID", * "fulfillmentStatus": "NOT_FULFILLED", * "buyerLanguage": "en", * "weightUnit": "KG", * "currency": "USD", * "taxIncludedInPrices": false, * "priceSummary": { * "subtotal": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "shipping": { * "amount": "10.0", * "formattedAmount": "$10.00" * }, * "tax": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "discount": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "totalPrice": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "total": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithoutGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalAdditionalFees": { * "amount": "0", * "formattedAmount": "$0.00" * } * }, * "billingInfo": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * }, * "shippingInfo": { * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc", * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "", * "shippingDestination": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * } * }, * "cost": { * "price": { * "amount": "10", * "formattedAmount": "$10.00" * }, * "totalPriceBeforeTax": { * "amount": "10", * "formattedAmount": "$10.00" * }, * "totalPriceAfterTax": { * "amount": "10.0", * "formattedAmount": "$10.00" * }, * "taxDetails": { * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * }, * "discount": { * "amount": "0", * "formattedAmount": "$0.00" * } * }, * "region": { * "name": "USA shipping" * } * }, * "status": "APPROVED", * "archived": false, * "taxSummary": { * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * }, * "appliedDiscounts": [], * "activities": [ * { * "_createdDate": "2023-01-16T13:53:10.776Z", * "type": "ORDER_PLACED" * }, * { * "_createdDate": "2023-01-16T14:38:48.249Z", * "type": "EMAIL_EDITED" * } * ], * "attributionSource": "UNSPECIFIED", * "createdBy": { * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7" * }, * "channelInfo": { * "type": "WEB" * }, * "seenByAHuman": true, * "checkoutId": "9f24eba1-5b05-4c9e-90c5-1789a8239912", * "customFields": [], * "cartId": "eb8086a0-9389-4e92-91cb-5ce7bd9b3db8", * "payNow": { * "subtotal": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "shipping": { * "amount": "10.0", * "formattedAmount": "$10.00" * }, * "tax": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "discount": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "totalPrice": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "total": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithoutGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * } * }, * "balanceSummary": { * "balance": { * "amount": "0.00", * "formattedAmount": "$0.00" * } * }, * "additionalFees": [] * }, * "previousPaymentStatus": "NOT_PAID" * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onOrderUpdated( )


Triggered when an order is updated.

The onOrderUpdated() event handler runs when an order is updated. The received OrderUpdated object contains information about the order that was updated and event metadata.

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

Method Declaration
Copy
function wixEcom_onOrderUpdated(event: OrderUpdated): void;
Method Parameters
eventOrderUpdated

Information about the order that was updated.

An event fired when an order is updated
JavaScript
// Place this code in the events.js file // of your site's Backend section. // Add the file if it doesn't exist. export function wixEcom_onOrderUpdated(event) { const orderId = event.data.order._id; const orderTotalPrice = event.data.order.priceSummary.totalPrice.amount; const eventId = event.metadata.id; console.log("Order updated", event); } /* Full event object: * * { * "metadata": { * "id": "69020d87-07b4-4e0b-9a7e-c0b607152e28", * "entityId": "7a8b195e-ab73-4138-b9da-cdf5e864a451", * "eventTime": "2023-01-16T13:53:13.143235Z", * "triggeredByAnonymizeRequest": false * }, * "entity": { * "_id": "7a8b195e-ab73-4138-b9da-cdf5e864a451", * "number": "10003", * "_createdDate": "2023-01-16T13:53:10.776Z", * "_updatedDate": "2023-01-16T13:53:13.099Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "productName": { * "original": "Watch", * "translated": "Watch" * }, * "catalogReference": { * "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "options": { * "Size": "Medium", * "Color": "Black" * }, * "variantId": "e309b2f2-2166-4927-a137-0e5dfb870627" * } * }, * "quantity": 1, * "totalDiscount": { * "amount": "0", * "formattedAmount": "$0.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Size", * "translated": "Size" * }, * "plainText": { * "original": "Medium", * "translated": "Medium" * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "Medium", * "translated": "Medium" * } * }, * { * "name": { * "original": "Color", * "translated": "Color" * }, * "colorInfo": { * "original": "Black", * "translated": "Black" * }, * "lineType": "COLOR", * "color": "Black" * } * ], * "image": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000", * "physicalProperties": { * "sku": "217537123517253", * "shippable": true * }, * "itemType": { * "preset": "PHYSICAL" * }, * "refundQuantity": 0, * "price": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "priceBeforeDiscounts": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "totalPriceBeforeTax": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "totalPriceAfterTax": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "taxDetails": { * "taxableAmount": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * } * } * ], * "buyerInfo": { * "contactId": "24de6f0b-60ce-4faa-9138-2e39f1415615", * "email": "janedoe@gmail.com", * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7" * }, * "paymentStatus": "NOT_PAID", * "fulfillmentStatus": "NOT_FULFILLED", * "buyerLanguage": "en", * "weightUnit": "KG", * "currency": "USD", * "taxIncludedInPrices": false, * "priceSummary": { * "subtotal": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "shipping": { * "amount": "10.0", * "formattedAmount": "$10.00" * }, * "tax": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "discount": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "totalPrice": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "total": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithoutGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalAdditionalFees": { * "amount": "0", * "formattedAmount": "$0.00" * } * }, * "billingInfo": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * }, * "shippingInfo": { * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc", * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5", * "title": "Standard US Shipping", * "logistics": { * "deliveryTime": "", * "shippingDestination": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * } * }, * "cost": { * "price": { * "amount": "10", * "formattedAmount": "$10.00" * }, * "totalPriceBeforeTax": { * "amount": "10", * "formattedAmount": "$10.00" * }, * "totalPriceAfterTax": { * "amount": "10.0", * "formattedAmount": "$10.00" * }, * "taxDetails": { * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * }, * "discount": { * "amount": "0", * "formattedAmount": "$0.00" * } * }, * "region": { * "name": "USA shipping" * } * }, * "status": "APPROVED", * "archived": false, * "taxSummary": { * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * }, * "appliedDiscounts": [], * "activities": [ * { * "_createdDate": "2023-01-16T13:53:10.776Z", * "type": "ORDER_PLACED" * } * ], * "attributionSource": "UNSPECIFIED", * "createdBy": { * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7" * }, * "channelInfo": { * "type": "WEB" * }, * "seenByAHuman": false, * "checkoutId": "9f24eba1-5b05-4c9e-90c5-1789a8239912", * "customFields": [], * "cartId": "eb8086a0-9389-4e92-91cb-5ce7bd9b3db8", * "payNow": { * "subtotal": { * "amount": "30.00", * "formattedAmount": "$30.00" * }, * "shipping": { * "amount": "10.0", * "formattedAmount": "$10.00" * }, * "tax": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "discount": { * "amount": "0.0", * "formattedAmount": "$0.00" * }, * "totalPrice": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "total": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * }, * "totalWithoutGiftCard": { * "amount": "40.00", * "formattedAmount": "$40.00" * } * }, * "balanceSummary": { * "balance": { * "amount": "40.00", * "formattedAmount": "$40.00" * } * }, * "additionalFees": [] * } * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onOrderTransactionsUpdated( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Triggered when a payment or refund is added to an order, or when an existing payment is updated.

The onOrderTransactionsUpdated() event handler runs when a new a payment or refund is added to an order, or when an existing payment is updated. The received OrderTransactionsUpdated object contains information about the updated order transactions, and event metadata.

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

Method Declaration
Copy
function wixEcom_onOrderTransactionsUpdated(
  event: OrderTransactionsUpdated,
): void;
Method Parameters
eventOrderTransactionsUpdated

Information about the transaction that was updated and event metadata.

onOrderTransactionsUpdated example
JavaScript
export function wixEcom_onOrderTransactionsUpdated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?

onOrdersSettingsUpdated( )


Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Triggered when order settings are updated.

The onOrdersSettingsUpdated() event handler runs when order settings are updated. The received OrdersSettingsUpdated object contains information about the order settings that were updated and event metadata.

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

Method Declaration
Copy
function wixEcom_onOrdersSettingsUpdated(event: OrdersSettingsUpdated): void;
Method Parameters
eventOrdersSettingsUpdated

Information about the orders settings that were updated and event metadata.

onOrdersSettingsUpdated example
JavaScript
export function wixEcom_onOrdersSettingsUpdated(event) { const eventId = event.metadata.id; const entityId = event.entity._id; }
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?