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:
onOrderPurchased()
event handler also runs.onOrderStarted()
event handler also runs.onOrderCanceled()
event handler also runs.onOrderEndDatePostponed()
event handler also runs.onOrderPaused()
or the onOrderResumed()
event handler also runs.onOrderEnded()
event handler also runs.onOrderStartDateChanged()
event handler also runs.onOrderCycleStarted()
event handler also runs.onOrderAutoRenewCanceled()
event handler also runs.Note: Backend events don't work when previewing your site.
function onOrderUpdated(event: OrderUpdatedEvent): void;
Information about the order that was updated and metadata for the event.
// 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"
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.