Bookings: Sample Use Cases and Flows

This article shares basic flows you could support. You're certainly not limited to these use cases, but they can be a helpful jumping-off point for your planning. You 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 (SDK | REST) payment methods, along with Wix Pricing Plans (SDK | REST).

Book an appointment

You 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 (SDK | REST).

Part 1: Book an appointment

  1. Call Get Site Properties (SDK | REST) to retrieve the timeZone of the business location.
  2. Use Query Services (SDK | REST) and specify {"type": "APPOINTMENT"} as a filter to retrieve all appointment-based services.
  3. Display all services to the customer and save the ID of the chosen service.
  4. Call Query Availability (SDK | REST). Make sure to specify the relevant serviceId, the business timezone, startDate and endDate as filters.
  5. Display the available time slots to the customer and let them select their preferred slot.
  6. Call Create Booking (SDK | REST). Specify startDate, endDate, resource and location from the selected slot in booking.bookedEntity.slot. If the slot's availability hasn't changed since calling Query Availability, the function succeeds and the status of the booking is CREATED.

Part 2: Handle the payment process with Wix eCommerce (
SDK | REST)

  1. Call Create Checkout (SDK | REST). Make sure to specify the Wix Bookings app ID as catalogReference.appId and the relevant booking ID as catalogReference.catalogItemId. Save the checkout ID and totalAfterGiftCard.amount.
  2. Retrieve the checkout's URL with Get Checkout URL (SDK | REST) and redirect the customer.
  3. Once the customer completes the checkout, Wix eCommerce automatically creates an order (SDK | REST) and the customer is charged.

Alternatively, you could follow these steps (SDK | REST) to handle the payment process with a custom checkout.

Book a class session

You could display available class sessions to customers, let them choose the session, create the booking, and handle the payment process with a custom checkout.

Part 1: Book a class session:

  1. Call Get Site Properties (SDK | REST) to retrieve the timeZone of the business location.
  2. Call Query Services (SDK | REST) and specify {"type": "CLASS"} as a filter to retrieve all classes.
  3. Display all classes to the customer and save the ID of the chosen service.
  4. Call Query Availability (SDK | REST). Specify the relevant serviceId, the business timezone, startDate and endDate as filters.
  5. Display the retrieved class sessions to the customer and let them select their preferred session. Make sure to save the corresponding availabilityEntries.slot.eventId.
  6. Call Create Booking (SDK | REST) and specify the saved event ID in booking.bookedEntity.slot.eventId. If the class session's availability hasn't changed since calling Query Availability, the call succeeds and the status of the booking is CREATED.

Part 2: Handle the payment process with a custom checkout

  1. Implement your custom checkout and display the checkout page to the customer.
  2. Once the customer completes the checkout, use Confirm Or Decline Booking (SDK | REST). Set options.paymentStatus to PAID to update the booking status to CONFIRMED.
  3. Call Create Order (SDK | REST) with your custom payment details.

Alternatively, you could follow these steps (SDK | REST) to handle the payment process with Wix eCommerce.

Book a course

You could display available courses to customers, let them choose a service, and create the booking.

To book a course:

  1. Call Query Services (SDK | REST) and specify {"type": "COURSE"} as a filter to retrieve all courses.
  2. Display all courses to the customer and save the ID of the chosen service and its defaultCapacity.
  3. Retrieve all bookings for this service with Query Extended Bookings (SDK | REST). Make sure to specify bookedEntity.item.schedule.serviceId as a filter.
  4. Sum up the values for attendance.numberOfAttendees from all returned extended bookings. This lets you know how many people have already booked a place in the course.
  5. Subtract the number of booked participants from the service's defaultCapacity to calculate the remaining spots.
  6. Let the customer choose how many participants they want to book. Make sure the intended numberOfParticipants doesn't exceed the number of remaining places.
  7. Call Create Booking (SDK | REST) and Specify the relevant schedule ID as booking.bookedEntity.scheduleId. If the course's availability hasn't changed since calling Query Extended Bookings, the call succeeds and the status of the booking is CREATED.

Then, you could handle the payment process with Wix eCommerce (SDK | REST) or with a custom checkout (SDK | REST).

Important: Calling Create Booking (SDK | REST) 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, use Create Booking with options.flowControlSettings.skipAvailabilityValidation set to true. Using other flowControlSettings lets you override the maximum number of participants per session, or allow payment methods that aren't supported for the service.

Did this help?