Introduction

Wix Bookings events are fired in your site's backend when certain events occur in your site's Bookings application. You can write event handlers that react to these events. Event handler functions receive data that correspond to the event that has occurred. Use event handlers to create custom responses to bookings events.

To add a bookings event handler, add an events.js file to the Backend section of your site if one does not already exist. All event handler functions for your site are defined in this file.

Event handler functions are defined using the following pattern:

Copy

For example, an event handler that handles a new booking request looks like this:

Copy

Note: Backend events don't work when previewing your site.

Did this help?

onBookingCanceled( )


An event that fires when a booking is canceled.

The onBookingCanceled() event handler runs when a booking is canceled.

The event object includes a trigger property that describes the action that triggered the event. The trigger value is one of:

  • "OWNER_CANCELED": The booking was canceled by the business.
  • "MEMBER_CANCELED": The booking was canceled by the member.

Note: Backend events don't work when previewing your site.

Method Declaration
Copy
Method Parameters
eventBookingEventRequired

Information about a canceled booking.

An event when a booking is canceled
JavaScript
Did this help?

onBookingConfirmed( )


An event that fires when a booking request is confirmed.

The onBookingConfirmed() event handler runs when a new booking request is confirmed.

The event object includes a trigger property that describes the action that triggered the event. The trigger value is one of:

  • "BOOKING_AUTO_CONFIRMED": A new booking was made for a service that is configured for automatic confirmation.
  • "OWNER_CONFIRMED_BOOKING_REQUEST": A booking was confirmed by the business.
  • "OWNER_BOOKED": The owner made a booking directly from the calendar.

Note: Backend events don't work when previewing your site.

Method Declaration
Copy
Method Parameters
eventBookingEventRequired

Information about a confirmed booking.

An event when a booking is confirmed
JavaScript
Did this help?

onBookingDeclined( )


An event that fires when a booking request is declined.

The onBookingDeclined() event handler runs when a booking request is declined by the business.

The event object includes a trigger property that describes the action that triggered the event. The trigger value for this event is "OWNER_DECLINED_BOOKING_REQUEST".

Note: Backend events don't work when previewing your site.

Method Declaration
Copy
Method Parameters
eventBookingEventRequired

Information about a declined booking.

An event when a booking request is declined
JavaScript
Did this help?

onBookingRequestCreated( )


An event that fires when a booking request is created.

The onBookingRequestCreated() event handler runs when a new booking request is created for a service that requires manual booking confirmation.

The event object includes a trigger property that describes the action that triggered the event. The trigger value for this event is "VISITOR_BOOKING_REQUEST_CREATED".

Note: Backend events don't work when previewing your site.

Method Declaration
Copy
Method Parameters
eventBookingEventRequired

Information about a newly-created booking request.

An event when a booking request is created
JavaScript
Did this help?

onBookingScheduleUpdated( )


An event that fires when a booking's schedule is updated.

The onBookingScheduleUpdated() event handler runs when a booking's schedule is updated.

The event object includes a trigger property that describes the action that triggered the event. The trigger value is one of:

  • "OWNER_UPDATED_SESSION": The booking's session was updated by the business.
  • "MEMBER_RESCHEDULED_BOOKING": The booking was rescheduled by the member.
  • "OWNER_CANCELED_SESSION_IN_SET": A session in a set of sessions was canceled by the business. A session is part of a set when it belongs to a schedule that has "course" as one of its tags.

Note: Backend events don't work when previewing your site.

Method Declaration
Copy
Method Parameters
eventBookingEventRequired

Information about a booking with an updated schedule.

An event when a booking schedule is updated
JavaScript
Did this help?

onBookingUpdated( )


An event that fires when a booking's details are updated.

The onBookingUpdated() event handler runs when a booking's details are updated.

The event object includes a trigger property that describes the action that triggered the event. The trigger value for this event is "OWNER_UPDATED_ATTENDANCE" when the business updates the booking's attendance information.

Note: Backend events don't work when previewing your site.

Method Declaration
Copy
function onBookingUpdated(event: BookingEvent): void;
Method Parameters
eventBookingEventRequired

Information about an updated booking.

An event when a booking is updated
JavaScript
// Place this code in the events.js file // of your site's Backend section. export function wixBookings_onBookingUpdated(event) { const eventTrigger = event.trigger; const bookingId = event.booking._id; } /* Full event object * { * "trigger": "OWNER_UPDATED_ATTENDANCE", * "booking": { * "_id": "9f5a05d6-2fb4-4de8-990d-12db585d25c5", * "bookedResources": [{ * "_id": "6dd5e48d-9e6d-4e74-bf61-e103e8d52575", * "name": "Jane Doe", * "email": "Doe" * }], * "status": "CONFIRMED", * "_createdDate": "2021-02-28T18:11:56.177Z", * "attendanceInfo": { * "attendanceStatus": true, * "numberOfAttendees": 3 * }, * "bookingSource": { * "platform": "WEB", * "actor": "BUSINESS", * "appDefId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97", * "appName": "Wix Bookings" * }, * "bookedEntity": { * "serviceId": "2e80e5e0-2385-49c7-9f9f-2e59a3566809", * "scheduleId": "f1945fde-d567-4ebc-85ef-dd1d52327c11", * "singleSession": { * "sessionId": "2mmoW0vwKcSFyxtOfCdMhFC1gAivXqAQVAQP0hHoOUADs242fBtwKRY3sHLMmbVxJ75TQ4G6BkCe6z1E1fVT6gUPWDDNF4WX2S6P", * "start": "2021-03-18T19:00:00.000Z", * "end": "2021-03-18T20:00:00.000Z" * }, * "title": "Appointment service", * "rate": { * "labeledPriceOptions": { * "general": { * "amount": "10", * "currency": "USD", * "downPayAmount": "0" * } * } * }, * "tags": ["INDIVIDUAL"], * "location": { "locationType": "OWNER_BUSINESS" } * }, * "paymentDetails": { * "balance": { * "finalPrice": { * "amount": "10", * "currency": "USD", * "downPayAmount": "0" * }, * "amountReceived": "0" * }, * "state": "PENDING_MARK_AS_PAID", * "wixPayMultipleDetails": [{ * "txId": "c1cef510-e382-4c1c-aeec-4300cfea219a", * "orderId": "179c361c-8a04-4f78-b28f-065b62cf4806", * "orderAmount": "10", * "paymentVendorName": "inPerson", * "orderApprovalTime": null * }] * }, * "formInfo": { * "paymentSelection": [{ * "rateLabel": "general", * "numberOfParticipants": 1 * }], * "additionalFields": [{ * "_id": "00000000-0000-0000-0000-000000000008", * "label": "Add Your Message", * "valueType": "LONG_TEXT" * }], * "contactDetails": { * "contactId": "baf3cd37-c32c-4f01-9e1a-c8ab152af490", * "firstName": "Adam Smith ", * "email": "asmith@amail.com", * "phone": "9998765", * "timeZone": "America/New_York", * "countryCode": "US" * } * } * }, * "previousBooking": { * "_id": "9f5a05d6-2fb4-4de8-990d-12db585d25c5", * "bookedResources": [{ * "_id": "6dd5e48d-9e6d-4e74-bf61-e103e8d52575", * "name": "Jane Doe", * "email": "Doe" * }], * "status": "CONFIRMED", * "_createdDate": "2021-02-28T18:11:56.177Z", * "attendanceInfo": { * "attendanceStatus": true, * "numberOfAttendees": 1 * }, * "bookingSource": { * "platform": "WEB", * "actor": "BUSINESS", * "appDefId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97", * "appName": "Wix Bookings" * }, * "bookedEntity": { * "serviceId": "2e80e5e0-2385-49c7-9f9f-2e59a3566809", * "scheduleId": "f1945fde-d567-4ebc-85ef-dd1d52327c11", * "singleSession": { * "sessionId": "2mmoW0vwKcSFyxtOfCdMhFC1gAivXqAQVAQP0hHoOUADs242fBtwKRY3sHLMmbVxJ75TQ4G6BkCe6z1E1fVT6gUPWDDNF4WX2S6P", * "start": "2021-03-18T19:00:00.000Z", * "end": "2021-03-18T20:00:00.000Z" * }, * "title": "Appointment service", * "rate": { * "labeledPriceOptions": { * "general": { * "amount": "10", * "currency": "USD", * "downPayAmount": "0" * } * } * }, * "tags": ["INDIVIDUAL"], * "location": { "locationType": "OWNER_BUSINESS" } * }, * "paymentDetails": { * "balance": { * "finalPrice": { * "amount": "10", * "currency": "USD", * "downPayAmount": "0" * }, * "amountReceived": "0" * }, * "state": "PENDING_MARK_AS_PAID", * "wixPayMultipleDetails": [{ * "txId": "c1cef510-e382-4c1c-aeec-4300cfea219a", * "orderId": "179c361c-8a04-4f78-b28f-065b62cf4806", * "orderAmount": "10", * "paymentVendorName": "inPerson", * "orderApprovalTime": null * }] * }, * "formInfo": { * "paymentSelection": [{ * "rateLabel": "general", * "numberOfParticipants": 1 * }], * "additionalFields": [{ * "_id": "00000000-0000-0000-0000-000000000008", * "label": "Add Your Message", * "valueType": "LONG_TEXT" * }], * "contactDetails": { * "contactId": "baf3cd37-c32c-4f01-9e1a-c8ab152af490", * "firstName": "Adam Smith ", * "email": "asmith@amail.com", * "phone": "9998765", * "timeZone": "America/New_York", * "countryCode": "US" * } * } * } * } */
Did this help?