Search...
onOrderStarted( )
Developer Preview
Triggered when an order reaches its startDate
. Applies to both purchased and free orders.
Syntax
function wixPricingPlans_onOrderStarted(event: OrderStartedEvent): void
onOrderStarted Parameters
NAME
TYPE
DESCRIPTION
event
Optional
OrderStartedEvent
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
onOrderStarted example
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_onOrderStarted(event) {6 const orderId = event.data.order._id;7 const eventTime = event.metadata.eventTime;8 const buyerContactId = event.data.buyer.contactId;9 const planId = event.data.planId;1011 console.log(`New order started: Order ID ${orderId} at ${eventTime} by contact ID ${buyerContactId} to purchase plan ${planId}. Full event object:`, event);12}1314/* Full event object:15 * {16 * "data": {17 * "order": {18 * "_createdDate": "2024-01-25T11:45:05.036Z",19 * "_id": "3b620f8b-33f3-4e29-b1db-c21d7a6afa01",20 * "_updatedDate": "2024-01-25T11:45:05.036Z",21 * "buyer": {22 * "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4",23 * "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4"24 * },25 * "currentCycle": {26 * "index": 1,27 * "startedDate": "2024-01-25T11:45:05.036Z"28 * },29 * "cycles": [30 * {31 * "index": 1,32 * "startedDate": "2024-01-25T11:45:05.036Z"33 * }34 * ],35 * "formData": {36 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",37 * "submissionData": {},38 * "submissionId": "1b282868-0a1e-42c6-9123-3a611b0014bf"39 * },40 * "lastPaymentStatus": "NOT_APPLICABLE",41 * "orderMethod": "UNKNOWN",42 * "pausePeriods": [],43 * "planDescription": "",44 * "planId": "aa0d8e0e-99ad-4c95-ac48-4955e37956c5",45 * "planName": "Default",46 * "planPrice": "0",47 * "priceDetails": {48 * "currency": "EUR",49 * "discount": "0",50 * "planPrice": "0",51 * "singlePaymentUnlimited": true,52 * "subtotal": "0.00",53 * "total": "0"54 * },55 * "pricing": {56 * "prices": [57 * {58 * "duration": {59 * "cycleFrom": 1,60 * "numberOfCycles": 161 * },62 * "price": {63 * "currency": "EUR",64 * "discount": "0",65 * "fees": [],66 * "proration": "0",67 * "subtotal": "0.00",68 * "total": "0"69 * }70 * }71 * ],72 * "singlePaymentUnlimited": true73 * },74 * "startDate": "2024-01-25T11:45:05.036Z",75 * "status": "ACTIVE",76 * "statusNew": "ACTIVE",77 * "subscriptionId": "e9fff457-bc89-4c8c-94c0-1d162711c9a6",78 * "type": "ONLINE"79 * }80 * },81 * "metadata": {82 * "entityId": "3b620f8b-33f3-4e29-b1db-c21d7a6afa01",83 * "eventTime": "2024-01-25T11:45:05.860485075Z",84 * "id": "f02f2b76-5044-4f82-b6de-82548a65b37a",85 * "triggeredByAnonymizeRequest": false86 * }87 * }88 */89