Enable appointment bookings to be distributed among staff members in a weight-based round robin fashion.
In this example, we create an appointment scheduling system using a multi-state box. Using a weight-based round robin implementation, we first identify the staff member with the fewest existing appointments to receive the next booking. We then query this staff member’s availability and display dates and times for visitors to choose from. Upon a successful booking, we change the state of the multi-state box to display the visitor’s appointment details.
To use this example:
We added the following to our site:
The code in this file initializes the page’s elements, validates input data for creating a booking, and retrieves the created booking data from the backend.
In this file, we:
We defined the following methods:
getResourcesWithMinimumWeight()
: Calls getFirstService()
to retrieve the staff member IDs of the booking service, defines a query filter to call queryExtendedBookings()
, then uses the query results to find and return the staff member with the least number of booked appointments.getFirstService()
: Queries all services and returns the first service (under the assumption that your appointment scheduling system is that service).queryExtendedBookings()
: Retrieves the extended bookings that match the query filter criteria for the staff members.queryAvailability()
: Calls getFirstService()
and extracts the service ID, calls queryAvailability()
on the availability calendar with a query filter, and then returns a list of the staff member’s availability entries.createBooking()
: Creates an appointment booking with the provided booking object.The code in this file uses the Wix Ecom Checkout API to create a checkout and order to successfully confirm the created appointment booking.
We defined the following methods:
createCheckout()
: Creates a checkout that holds information about the booking that was created.createOrder()
: Creates an order from the checkout, which confirms the booking creation.Join the Wix Studio community on Discord, where experienced developers and fellow creators come together to share tips, troubleshoot issues, and collaborate.
Building a coded solution on your own can be challenging. Let an experienced Wix developer build it for you, so you can keep working on your site or business. Visit the Wix Marketplace to find a trusted developer.