> 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: onOrderUpdated(event: OrderUpdatedEvent)

# Method package: wixPricingPlansBackend

# Method menu location: wixPricingPlansBackend --> Events --> onOrderUpdated

# Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-updated.md

# Method Description:

An event that triggers when an order is changed.

The `onOrderUpdated()` event handler runs when an order has changed.
 The received `OrderUpdatedEvent`
 object contains information about the order that was updated.

 An order is considered changed and the `onOrderUpdated()` event handler runs
 if any of the following happens: 
 + An order is paid.  In this case, the [`onOrderPurchased()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-purchased.md) event handler also runs.
 + An order reaches its start date.  In this case, the [`onOrderStarted()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-started.md) event handler also runs.
 + An order is canceled. In this case, the [`onOrderCanceled()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-canceled.md) event handler also runs.
 + The end date of an order is postponed or brought forward. In this case, the `onOrderEndDatePostponed()` event handler also runs. 
 + An order is paused or resumed. In this case, the [`onOrderPaused()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-paused.md) or the [`onOrderResumed()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-resumed.md) event handler also runs.
 + An order expired by reaching its end date. In this case, the [`onOrderEnded()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-ended.md) event handler also runs.
 + The start date of an order has changed. In this case, the [`onOrderStartDateChanged()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-start-date-changed.md) event handler also runs.
 + The payment cycle of an order starts. In this case, the [`onOrderCycleStarted()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-cycle-started.md) event handler also runs.
 + The auto-renewal of an order is stopped. In this case, the [`onOrderAutoRenewCanceled()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-auto-renew-canceled.md) event handler also runs.

 > **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 triggered when an order is changed

```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 wixPricingPlans_onOrderUpdated(event) {
  const orderId = event.entity._id;
  const eventId = event.metadata.id;
  const eventTime = event.metadata.eventTime;
}

/* Full event object:
 * {
 *   "metadata": {
 *     "id":"7af51145-c023-43ba-a0b3-52e434af0476", 
 *     "entityId":"beaf5979-536b-4659-b3fc-78cc08579eab",
 *     "eventTime":"2022-07-26T15:19:06.124503Z",
 *     "triggeredByAnonymizeRequest":false
 *   },
 *   "entity": {
 *     "_id":"beaf5979-536b-4659-b3fc-78cc08579eab",
 *     "planId":"a4d57b6c-42eb-4416-b8dd-196f1c321b78",
 *     "subscriptionId":"09c34718-6735-435c-8dd4-9ba7d7dcaa3e",
 *     "wixPayOrderId":"c83359a7-833f-4689-8451-0f1211bdf184",
 *     "buyer": {
 *       "memberId":"ea3d74df-b7dc-4ca1-a7c9-c416b9017a86",
 *       "contactId":"ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"
 *     },
 *     "priceDetails": {
 *       "subtotal":"33",
 *       "discount":"0",
 *       "total":"33",
 *       "planPrice":"33",
 *       "currency":"EUR",
 *       "singlePaymentForDuration": {
 *         "count":6,
 *         "unit":"MONTH"
 *       }},
 *     "pricing": {
 *       "singlePaymentForDuration": {
 *         "count":6,
 *         "unit":"MONTH"
 *       },
 *       "prices": [{
 *         "duration": {
 *           "cycleFrom":1,
 *           "numberOfCycles":1
 *         },
 *         "price": {
 *           "subtotal":"33",
 *           "discount":"0",
 *           "total":"33",
 *           "currency":"EUR" 
 *         }
 *       }]},
 *     "type":"OFFLINE",
 *     "orderMethod":"UNKNOWN",
 *     "status":"PENDING",
 *     "lastPaymentStatus":"UNPAID",
 *     "startDate":"2022-08-01T16:23:00.000Z",
 *     "endDate":"2023-02-01T16:23:00.000Z",
 *     "pausePeriods":[],
 *     "earliestEndDate":"2023-02-01T16:23:00.000Z",
 *     "planName":"One and Done",
 *     "planDescription":"",
 *     "planPrice":"33",
 *     "_createdDate":"2022-07-24T08:17:04.278Z",
 *     "_updatedDate":"2022-07-24T08:17:05.117Z"
 *   }
 * }
 */
```

---