Search.../

onOrderCanceled( )

Triggered when an order is canceled.

Description

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.

Syntax

function wixEcom_onOrderCanceled(event: OrderCanceled): void

onOrderCanceled Parameters

NAME
TYPE
DESCRIPTION
event
Optional
OrderCanceled

Information about the order that was canceled.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event fired when an order is canceled

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