Search.../

onOrderUpdated( )

Developer Preview

Triggered when an order is updated.

Description

This is a general webhook that is triggered when any update is made to an order. More specific webhooks are also triggered for the same originating events.

Order eventAlso triggered
Order is paid for.Order Purchased Webhook
Free or offline order is created.Order Purchased Webhook
Order reaches its startDate.Order Started Webhook
Order reaches its endDate.Order Ended Webhook
New payment cycle of an order starts.Order Cycle Started Webhook
Offline order is marked as paid.Order Marked As Paid Webhook
endDate of the order is postponed.Order End Date Postponed Webhook
Order is paused.Order Paused Webhook
Paused order is resumed.Order Resumed Webhook
Order is canceled.Order Canceled Webhook
Order is canceled and effectiveAt is set to NEXT_PAYMENT_DATE.Order Auto Renew Canceled Webhook

Syntax

function wixPricingPlans_onOrderUpdated(event: OrderUpdated): void

onOrderUpdated Parameters

NAME
TYPE
DESCRIPTION
event
Optional
OrderUpdated

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

onOrderUpdated example

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 wixPricingPlans_onOrderUpdated(event) {
6 const orderId = event.data.order._id;
7 const eventTime = event.metadata.eventTime;
8 const buyerContactId = event.data.buyer.contactId;
9
10 console.log(`Order update: Order ID ${orderId} was updated at ${eventTime} by contact ID ${buyerContactId}. Full event object:`, event);
11}
12
13/* Full event object:
14 * {
15 * "entity": {
16 * "_createdDate": "2024-02-06T06:56:57.193Z",
17 * "_id": "537a3f44-57bf-4658-9833-47357198d88d",
18 * "_updatedDate": "2024-02-06T06:57:24.932Z",
19 * "buyer": {
20 * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b",
21 * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b"
22 * },
23 * "currentCycle": {
24 * "index": 1,
25 * "startedDate": "2024-02-06T06:56:57.193Z"
26 * },
27 * "cycles": [
28 * {
29 * "index": 1,
30 * "startedDate": "2024-02-06T06:56:57.193Z"
31 * }
32 * ],
33 * "formData": {
34 * "submissionData": {}
35 * },
36 * "lastPaymentStatus": "PAID",
37 * "orderMethod": "UNKNOWN",
38 * "pausePeriods": [],
39 * "planDescription": "Full feature enablement - lifetime plan",
40 * "planId": "e901222b-c137-4bc7-adc3-c1efa3c880a2",
41 * "planName": "Quality Plan - Lifetime",
42 * "planPrice": "1500",
43 * "priceDetails": {
44 * "coupon": {
45 * "_id": "07de4c3a-536b-4c30-adb9-991935da1681",
46 * "amount": "1500.00",
47 * "code": "sale-day"
48 * },
49 * "currency": "USD",
50 * "discount": "1500.00",
51 * "planPrice": "1500",
52 * "singlePaymentUnlimited": true,
53 * "subtotal": "1500.00",
54 * "tax": {
55 * "amount": "0",
56 * "includedInPrice": false,
57 * "name": "Tax",
58 * "rate": "6.5"
59 * },
60 * "total": "0"
61 * },
62 * "pricing": {
63 * "prices": [
64 * {
65 * "duration": {
66 * "cycleFrom": 1,
67 * "numberOfCycles": 1
68 * },
69 * "price": {
70 * "currency": "USD",
71 * "discount": "1500.00",
72 * "fees": [],
73 * "proration": "0",
74 * "subtotal": "1500.00",
75 * "tax": {
76 * "amount": "0",
77 * "includedInPrice": false,
78 * "name": "Tax",
79 * "rate": "6.5"
80 * },
81 * "total": "0"
82 * }
83 * }
84 * ],
85 * "singlePaymentUnlimited": true
86 * },
87 * "startDate": "2024-02-06T06:56:57.193Z",
88 * "status": "ACTIVE",
89 * "statusNew": "ACTIVE",
90 * "subscriptionId": "24bd018a-a4a2-4ca4-b83b-b4af9d6d8eb4",
91 * "type": "ONLINE",
92 * "wixPayOrderId": "2e0c2738-8541-43f5-842b-37c7e94e9f4c"
93 * },
94 * "metadata": {
95 * "entityId": "537a3f44-57bf-4658-9833-47357198d88d",
96 * "eventTime": "2024-02-06T06:57:26.229867928Z",
97 * "id": "5212464e-f2c6-423f-b768-05401295b94d",
98 * "triggeredByAnonymizeRequest": false
99 * }
100 * }
101 */
102
103