onOrderCanceled( )
An event that triggers when an order is canceled.
Description
The onOrderCanceled()
event handler runs either immediately when an order is canceled IMMEDIATELY
or at the end of the current payment cycle when an order is set to cancel at the NEXT_PAYMENT_DATE
.
The received OrderCanceledEvent
object contains information about the canceled order.
The onOrderCanceled()
event will not trigger immediately when the order is canceled with effectiveAt
as NEXT_PAYMENT_DATE
.
In that case, the onOrderAutoRenewCanceled()
event will trigger immediately and the onOrderCanceled()
event will trigger following the current payment cycle.
Note: Backend events don't work when previewing your site.
Syntax
function onOrderCanceled(event: OrderCanceledEvent): void
onOrderCanceled Parameters
NAME
TYPE
DESCRIPTION
Information about the canceled order and metadata for the event.
Returns
This function does not return anything.
Return Type:
Was this helpful?
An event triggered when an order is canceled
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_onOrderCanceled(event) {6 const orderId = event.data.order._id;7 const eventId = event.metadata.id;8 const eventTime = event.metadata.eventTime;9}1011 /* Full event object:12 * {13 * "metadata": {14 * "id": "b54fa4e8-3739-4554-b884-1aaec298e202",15 * "entityId": "50a888fb-5b07-4b78-b3b9-4e02a7314728",16 * "eventTime": "2022-07-25T06:40:54.814784Z",17 * "triggeredByAnonymizeRequest":false18 * },19 * "data": {20 * "order": {21 * "_id": "50a888fb-5b07-4b78-b3b9-4e02a7314728",22 * "planId": "099e2c86-3b7e-4477-8c27-f77402b8cceb",23 * "subscriptionId": "70a6511f-d929-422a-9478-029dd64b53ea",24 * "wixPayOrderId": "3163cb56-942b-418f-8ff5-700553f1863c",25 * "buyer": {26 * "memberId": "0c9bca47-1f00-4b92-af1c-7852452e949a",27 * "contactId": "0c9bca47-1f00-4b92-af1c-7852452e949a"28 * },29 * "priceDetails": {30 * "subtotal": "74.99",31 * "discount": "0",32 * "total": "74.99",33 * "planPrice": "74.99",34 * "currency": "EUR",35 * "subscription": {36 * "cycleDuration": {37 * "count": 1,38 * "unit": "MONTH"39 * },40 * "cycleCount": 341 * }},42 * "pricing": {43 * "subscription": {44 * "cycleDuration": {45 * "count": 1,46 * "unit": "MONTH"47 * },48 * "cycleCount": 349 * },50 * "prices": [{51 * "duration": {52 * "cycleFrom": 1,53 * "numberOfCycles": 354 * },55 * "price": {56 * "subtotal": "74.99",57 * "discount": "0",58 * "total": "74.99",59 * "currency": "EUR"60 * }61 * }]},62 * "type": "OFFLINE",63 * "orderMethod": "UNKNOWN",64 * "status": "CANCELED",65 * "autoRenewCanceled": true,66 * "cancellation": {67 * "cause": "OWNER_ACTION",68 * "effectiveAt": "IMMEDIATELY"69 * },70 * "lastPaymentStatus": "UNPAID",71 * "startDate": "2022-07-19T12:06:33.259Z",72 * "endDate": "2022-07-25T06:40:54.602Z",73 * "pausePeriods": [],74 * "earliestEndDate": "2022-10-19T12:06:33.259Z",75 * "planName": "Platinum Pro",76 * "planDescription": "",77 * "planPrice": "74.99",78 * "_createdDate": "2022-07-19T12:06:33.259Z",79 * "_updatedDate": "2022-07-25T06:40:54.666Z"80 * }81 * }82 * }83 */