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.
function wixEcom_onOrderUpdated(event: OrderUpdated): void;
Information about the order that was updated.
// 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": []
* }
* }
*
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.