> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: onOrderCanceled(event: OrderCanceled)

# Method package: wixEcomBackend

# Method menu location: wixEcomBackend --> onOrderCanceled

# Method Link: https://dev.wix.com/docs/velo/events-service-plugins/e-commerce/events/on-order-canceled.md

# Method Description:

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 Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## 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
 *   }
 * }
 *
 */
```

---