Search.../

onOrderUpdated( )

Triggered when an order is updated.

Description

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.

Syntax

function wixEcom_onOrderUpdated(event: OrderUpdated): void

onOrderUpdated Parameters

NAME
TYPE
DESCRIPTION
event
Optional
OrderUpdated

Information about the order that was updated.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event fired when an order is updated

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3// Add the file if it doesn't exist.
4
5export function wixEcom_onOrderUpdated(event) {
6 const orderId = event.data.order._id;
7 const orderTotalPrice = event.data.order.priceSummary.totalPrice.amount;
8 const eventId = event.metadata.id;
9 console.log('Order updated', event)
10}
11
12
13/* Full event object:
14 *
15 * {
16 * "metadata": {
17 * "id": "69020d87-07b4-4e0b-9a7e-c0b607152e28",
18 * "entityId": "7a8b195e-ab73-4138-b9da-cdf5e864a451",
19 * "eventTime": "2023-01-16T13:53:13.143235Z",
20 * "triggeredByAnonymizeRequest": false
21 * },
22 * "entity": {
23 * "_id": "7a8b195e-ab73-4138-b9da-cdf5e864a451",
24 * "number": "10003",
25 * "_createdDate": "2023-01-16T13:53:10.776Z",
26 * "_updatedDate": "2023-01-16T13:53:13.099Z",
27 * "lineItems": [
28 * {
29 * "_id": "00000000-0000-0000-0000-000000000001",
30 * "productName": {
31 * "original": "Watch",
32 * "translated": "Watch"
33 * },
34 * "catalogReference": {
35 * "catalogItemId": "1a2d7e83-4bef-31d5-09e1-3326ee271c09",
36 * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",
37 * "options": {
38 * "options": {
39 * "Size": "Medium",
40 * "Color": "Black"
41 * },
42 * "variantId": "e309b2f2-2166-4927-a137-0e5dfb870627"
43 * }
44 * },
45 * "quantity": 1,
46 * "totalDiscount": {
47 * "amount": "0",
48 * "formattedAmount": "$0.00"
49 * },
50 * "descriptionLines": [
51 * {
52 * "name": {
53 * "original": "Size",
54 * "translated": "Size"
55 * },
56 * "plainText": {
57 * "original": "Medium",
58 * "translated": "Medium"
59 * },
60 * "lineType": "PLAIN_TEXT",
61 * "plainTextValue": {
62 * "original": "Medium",
63 * "translated": "Medium"
64 * }
65 * },
66 * {
67 * "name": {
68 * "original": "Color",
69 * "translated": "Color"
70 * },
71 * "colorInfo": {
72 * "original": "Black",
73 * "translated": "Black"
74 * },
75 * "lineType": "COLOR",
76 * "color": "Black"
77 * }
78 * ],
79 * "image": "wix:image://v1/3c76e2_8891bbe3372a428aac976ac59aa0ac74~mv2.jpg#originWidth=1000&originHeight=1000",
80 * "physicalProperties": {
81 * "sku": "217537123517253",
82 * "shippable": true
83 * },
84 * "itemType": {
85 * "preset": "PHYSICAL"
86 * },
87 * "refundQuantity": 0,
88 * "price": {
89 * "amount": "30.00",
90 * "formattedAmount": "$30.00"
91 * },
92 * "priceBeforeDiscounts": {
93 * "amount": "30.00",
94 * "formattedAmount": "$30.00"
95 * },
96 * "totalPriceBeforeTax": {
97 * "amount": "30.00",
98 * "formattedAmount": "$30.00"
99 * },
100 * "totalPriceAfterTax": {
101 * "amount": "30.00",
102 * "formattedAmount": "$30.00"
103 * },
104 * "paymentOption": "FULL_PAYMENT_ONLINE",
105 * "taxDetails": {
106 * "taxableAmount": {
107 * "amount": "30.00",
108 * "formattedAmount": "$30.00"
109 * },
110 * "taxRate": "0.0",
111 * "totalTax": {
112 * "amount": "0.0",
113 * "formattedAmount": "$0.00"
114 * }
115 * }
116 * }
117 * ],
118 * "buyerInfo": {
119 * "contactId": "24de6f0b-60ce-4faa-9138-2e39f1415615",
120 * "email": "janedoe@gmail.com",
121 * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7"
122 * },
123 * "paymentStatus": "NOT_PAID",
124 * "fulfillmentStatus": "NOT_FULFILLED",
125 * "buyerLanguage": "en",
126 * "weightUnit": "KG",
127 * "currency": "USD",
128 * "taxIncludedInPrices": false,
129 * "priceSummary": {
130 * "subtotal": {
131 * "amount": "30.00",
132 * "formattedAmount": "$30.00"
133 * },
134 * "shipping": {
135 * "amount": "10.0",
136 * "formattedAmount": "$10.00"
137 * },
138 * "tax": {
139 * "amount": "0.0",
140 * "formattedAmount": "$0.00"
141 * },
142 * "discount": {
143 * "amount": "0.0",
144 * "formattedAmount": "$0.00"
145 * },
146 * "totalPrice": {
147 * "amount": "40.00",
148 * "formattedAmount": "$40.00"
149 * },
150 * "total": {
151 * "amount": "40.00",
152 * "formattedAmount": "$40.00"
153 * },
154 * "totalWithGiftCard": {
155 * "amount": "40.00",
156 * "formattedAmount": "$40.00"
157 * },
158 * "totalWithoutGiftCard": {
159 * "amount": "40.00",
160 * "formattedAmount": "$40.00"
161 * },
162 * "totalAdditionalFees": {
163 * "amount": "0",
164 * "formattedAmount": "$0.00"
165 * }
166 * },
167 * "billingInfo": {
168 * "address": {
169 * "addressLine1": "525 5th Avenue",
170 * "city": "New York",
171 * "subdivision": "US-NY",
172 * "country": "US",
173 * "postalCode": "10173"
174 * },
175 * "contactDetails": {
176 * "firstName": "Jane",
177 * "lastName": "Doe",
178 * "phone": "0555555555"
179 * }
180 * },
181 * "shippingInfo": {
182 * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc",
183 * "code": "ed5bbce2-9533-dff4-7db0-13702fd139c5",
184 * "title": "Standard US Shipping",
185 * "logistics": {
186 * "deliveryTime": "",
187 * "shippingDestination": {
188 * "address": {
189 * "addressLine1": "525 5th Avenue",
190 * "city": "New York",
191 * "subdivision": "US-NY",
192 * "country": "US",
193 * "postalCode": "10173"
194 * },
195 * "contactDetails": {
196 * "firstName": "Jane",
197 * "lastName": "Doe",
198 * "phone": "0555555555"
199 * }
200 * }
201 * },
202 * "cost": {
203 * "price": {
204 * "amount": "10",
205 * "formattedAmount": "$10.00"
206 * },
207 * "totalPriceBeforeTax": {
208 * "amount": "10",
209 * "formattedAmount": "$10.00"
210 * },
211 * "totalPriceAfterTax": {
212 * "amount": "10.0",
213 * "formattedAmount": "$10.00"
214 * },
215 * "taxDetails": {
216 * "taxRate": "0.0",
217 * "totalTax": {
218 * "amount": "0.0",
219 * "formattedAmount": "$0.00"
220 * }
221 * },
222 * "discount": {
223 * "amount": "0",
224 * "formattedAmount": "$0.00"
225 * }
226 * },
227 * "region": {
228 * "name": "USA shipping"
229 * }
230 * },
231 * "status": "APPROVED",
232 * "archived": false,
233 * "taxSummary": {
234 * "totalTax": {
235 * "amount": "0.0",
236 * "formattedAmount": "$0.00"
237 * }
238 * },
239 * "appliedDiscounts": [],
240 * "activities": [
241 * {
242 * "_createdDate": "2023-01-16T13:53:10.776Z",
243 * "type": "ORDER_PLACED"
244 * }
245 * ],
246 * "attributionSource": "UNSPECIFIED",
247 * "createdBy": {
248 * "visitorId": "4c7ce95c-9fb3-417d-9f02-b41e82b841f7"
249 * },
250 * "channelInfo": {
251 * "type": "WEB"
252 * },
253 * "seenByAHuman": false,
254 * "checkoutId": "9f24eba1-5b05-4c9e-90c5-1789a8239912",
255 * "customFields": [],
256 * "cartId": "eb8086a0-9389-4e92-91cb-5ce7bd9b3db8",
257 * "payNow": {
258 * "subtotal": {
259 * "amount": "30.00",
260 * "formattedAmount": "$30.00"
261 * },
262 * "shipping": {
263 * "amount": "10.0",
264 * "formattedAmount": "$10.00"
265 * },
266 * "tax": {
267 * "amount": "0.0",
268 * "formattedAmount": "$0.00"
269 * },
270 * "discount": {
271 * "amount": "0.0",
272 * "formattedAmount": "$0.00"
273 * },
274 * "totalPrice": {
275 * "amount": "40.00",
276 * "formattedAmount": "$40.00"
277 * },
278 * "total": {
279 * "amount": "40.00",
280 * "formattedAmount": "$40.00"
281 * },
282 * "totalWithGiftCard": {
283 * "amount": "40.00",
284 * "formattedAmount": "$40.00"
285 * },
286 * "totalWithoutGiftCard": {
287 * "amount": "40.00",
288 * "formattedAmount": "$40.00"
289 * }
290 * },
291 * "balanceSummary": {
292 * "balance": {
293 * "amount": "40.00",
294 * "formattedAmount": "$40.00"
295 * }
296 * },
297 * "additionalFees": []
298 * }
299 * }
300 *
301 */