Search.../

onOrderInitiated( )

A backend event that fires when a ticket order is initiated.

Description

The onOrderInitiated() event handler runs when a ticket order is initiated. The received OrderInitiatedEvent object contains information about the initiated ticket order.

Note: Backend events are not fired when previewing your site.

Syntax

function onOrderInitiated(event: OrderInitiatedEvent): void

onOrderInitiated Parameters

NAME
TYPE
DESCRIPTION
event
OrderInitiatedEvent

Information about the ticket order that was initiated.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

A backend event that occurs when a ticket order is initiated

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 wixEvents_onOrderInitiated(event) {
6 let eventId = event.eventId;
7 let orderNumber = event.orderNumber;
8 let status = event.status;
9
10 let buyerFirstName = event.firstName;
11 let buyerLastName = event.lastName;
12 let buyerEmail = event.email;
13
14 let invoice = event.invoice;
15 let grandTotal = invoice.grandTotal;
16}
17
18
19/* Full event object:
20 * {
21 * "timestamp": "2020-04-28T12:23:51.523Z",
22 * "eventId": "566e7be9-1410-4095-ae7a-349a4ac95c6b",
23 * "orderNumber": "FMXC-BZG3-OT",
24 * "firstName": "John",
25 * "lastName": "Doe",
26 * "email": "john.doe@somedomain.com",
27 * "status": "INITIATED",
28 * "checkoutForm": {
29 * "inputValues": [
30 * {
31 * "inputName": "firstName",
32 * "value": "John",
33 * "values": []
34 * },
35 * {
36 * "inputName": "lastName",
37 * "value": "Doe",
38 * "values": []
39 * },
40 * {
41 * "inputName": "email",
42 * "value": "john.doe@somedomain.com",
43 * "values": []
44 * }
45 * ]
46 * },
47 * "invoice": {
48 * "items": [
49 * {
50 * "id": "d72874cb-012a-4ad2-afbb-57fe8cf1e308",
51 * "quantity": 1,
52 * "name": "VIP",
53 * "price": {
54 * "amount": "123.00",
55 * "currency": "USD"
56 * },
57 * "total": {
58 * "amount": "123.00",
59 * "currency": "USD"
60 * },
61 * "fees": [
62 * {
63 * "type": "FEE_INCLUDED",
64 * "rate": "2.5",
65 * "amount": {
66 * "amount": "3.08",
67 * "currency": "USD"
68 * }
69 * }
70 * ]
71 * },
72 * {
73 * "id": "9c3dc432-f1a6-408f-82d8-4f64c7ff581b",
74 * "quantity": 1,
75 * "name": "Free",
76 * "price": {
77 * "amount": "0.00",
78 * "currency": "USD"
79 * },
80 * "total": {
81 * "amount": "0.00",
82 * "currency": "USD"
83 * },
84 * "fees": [
85 * {
86 * "rate": "2.5",
87 * "amount": {
88 * "amount": "0.00",
89 * "currency": "USD"
90 * }
91 * }
92 * ]
93 * }
94 * ],
95 * "fees": [
96 * {
97 * "rate": "2.5",
98 * "amount": {
99 * "amount": "0.00",
100 * "currency": "USD"
101 * }
102 * },
103 * {
104 * "type": "FEE_INCLUDED",
105 * "rate": "2.5",
106 * "amount": {
107 * "amount": "3.08",
108 * "currency": "USD"
109 * }
110 * }
111 * ],
112 * "subTotal": {
113 * "amount": "123.00",
114 * "currency": "USD"
115 * },
116 * "grandTotal": {
117 * "amount": "123.00",
118 * "currency": "USD"
119 * },
120 * "revenue": {
121 * "amount": "119.92",
122 * "currency": "USD"
123 * }
124 * }
125 * }
126 */