Search...
onOrderUpdated( )
An event that triggers when an order is changed.
Description
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()
event handler also runs. - An order reaches its start date. In this case, the
onOrderStarted()
event handler also runs. - An order is canceled. In this case, the
onOrderCanceled()
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()
or theonOrderResumed()
event handler also runs. - An order expired by reaching its end date. In this case, the
onOrderEnded()
event handler also runs. - The start date of an order has changed. In this case, the
onOrderStartDateChanged()
event handler also runs. - The payment cycle of an order starts. In this case, the
onOrderCycleStarted()
event handler also runs. - The auto-renewal of an order is stopped. In this case, the
onOrderAutoRenewCanceled()
event handler also runs.
Note: Backend events don't work when previewing your site.
Syntax
function onOrderUpdated(event: OrderUpdatedEvent): void
onOrderUpdated Parameters
NAME
TYPE
DESCRIPTION
event
OrderUpdatedEvent
Information about the order that was updated and metadata for the event.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
An event triggered when an order is changed
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.3// Add the file if it doesn't exist.45export function wixPricingPlans_onOrderUpdated(event) {6 const orderId = event.entity._id;7 const eventId = event.metadata.id;8 const eventTime = event.metadata.eventTime;9}1011/* Full event object:12 * {13 * "metadata": {14 * "id":"7af51145-c023-43ba-a0b3-52e434af0476",15 * "entityId":"beaf5979-536b-4659-b3fc-78cc08579eab",16 * "eventTime":"2022-07-26T15:19:06.124503Z",17 * "triggeredByAnonymizeRequest":false18 * },19 * "entity": {20 * "_id":"beaf5979-536b-4659-b3fc-78cc08579eab",21 * "planId":"a4d57b6c-42eb-4416-b8dd-196f1c321b78",22 * "subscriptionId":"09c34718-6735-435c-8dd4-9ba7d7dcaa3e",23 * "wixPayOrderId":"c83359a7-833f-4689-8451-0f1211bdf184",24 * "buyer": {25 * "memberId":"ea3d74df-b7dc-4ca1-a7c9-c416b9017a86",26 * "contactId":"ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"27 * },28 * "priceDetails": {29 * "subtotal":"33",30 * "discount":"0",31 * "total":"33",32 * "planPrice":"33",33 * "currency":"EUR",34 * "singlePaymentForDuration": {35 * "count":6,36 * "unit":"MONTH"37 * }},38 * "pricing": {39 * "singlePaymentForDuration": {40 * "count":6,41 * "unit":"MONTH"42 * },43 * "prices": [{44 * "duration": {45 * "cycleFrom":1,46 * "numberOfCycles":147 * },48 * "price": {49 * "subtotal":"33",50 * "discount":"0",51 * "total":"33",52 * "currency":"EUR"53 * }54 * }]},55 * "type":"OFFLINE",56 * "orderMethod":"UNKNOWN",57 * "status":"PENDING",58 * "lastPaymentStatus":"UNPAID",59 * "startDate":"2022-08-01T16:23:00.000Z",60 * "endDate":"2023-02-01T16:23:00.000Z",61 * "pausePeriods":[],62 * "earliestEndDate":"2023-02-01T16:23:00.000Z",63 * "planName":"One and Done",64 * "planDescription":"",65 * "planPrice":"33",66 * "_createdDate":"2022-07-24T08:17:04.278Z",67 * "_updatedDate":"2022-07-24T08:17:05.117Z"68 * }69 * }70 */