This article shares basic flows your code could support. You're certainly not limited to these use cases, but they can be a helpful jumping-off point for your planning. Your code could add bookings to the business calendar. These bookings can be for all types of services: appointment-based, classes, and courses. You can also use all Wix eCommerce-supported payment methods, along with Wix Pricing Plans.
Your code could display available time slots for appointment-based services to customers, let them choose a slot, create the related booking, and handle the payment process using Wix eCommerce.
{"type": "APPOINTMENT"}
as a filter to retrieve all appointment-based services.serviceId
, startDate
and endDate
as filters.slot
.startDate
, endDate
, resource
and location
from the selected slot
in booking.bookedEntity.slot
. If the slot's availability hasn't changed
since running queryAvailability(), the function succeeds and the status of
the booking is CREATED
.catalogReference.appId
and the relevant booking ID as
catalogReference.catalogItemId
. Save the checkout ID.checkoutId
.Alternatively, you could follow these steps to handle the payment process with a custom checkout.
Your code could display available class sessions to customers, let them choose a session, create the booking, and handle the payment process with a custom checkout.
{"type": "CLASS"}
as a filter to retrieve all classes.serviceId
, startDate
and endDate
as filters.sessionId
.sessionId
in booking.bookedEntity.slot.sessionId
.
If the class session's availability hasn't changed since running
queryAvailability(), the function succeeds and the status of the booking is
CREATED
.options.paymentStatus
to PAID
to update the booking status to
CONFIRMED
.Alternatively, you could follow these steps to handle the payment process with Wix eCommerce.
Your code could display available courses to customers, let them choose a service, and create the booking.
To book a course:
{"type": "COURSE"}
as a filter to retrieve all courses.defaultCapacity
.bookedEntity.item.schedule.serviceId
as a filter.attendance.numberOfAttendees
from all returned extended
bookings. This lets you know how many people have already booked a place in
the course.defaultCapacity
. This gives you the number of remaining spots for the
course.numberOfParticipants
doesn't exceed the number of
remaining places.booking.bookedEntity.scheduleId
. If
the course's availability hasn't changed since running queryExtendedBookings(),
the function succeeds and the status of the booking is CREATED
.Then, you could handle the payment process with Wix eCommerce or with a custom checkout.
Important:
Running createBooking() can fail if the service is no longer available. You
can ensure success, for example if you want to create a booking on behalf
of the business owner. Then, run createBooking() with
options.flowControlSettings.skipAvailabilityValidation
set to true
. Using other
flowControlSettings
lets you override the maximum number of participants per
session, or allow unsupported payment methods for the service.