Bookings: Sample Use Cases and Flows

This article shares basic flows your app could support. You're certainly not limited to these use cases, but they can be a helpful jumping-off point for your planning. Your app 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.

Book an appointment

Your app 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.

Part 1: Book an appointment

  1. Call Get Site Properties to retrieve the timeZone of the business location.
  2. Use Query Services and pass {"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. Run Query Availability. Make sure to provide 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. Invoke Create Booking. Pass startDate, endDate, resource and location from the selected slot in booking.bookedEntity.slot. If the slot's availability hasn't changed since running Query Availability, the function succeeds and the status of the booking is CREATED.

Part 2: Handle the payment process with
Wix eCommerce

  1. Run Create Checkout. Make sure to provide 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 and redirect the customer.
  3. Once the customer completes the checkout, Wix eCommerce automatically creates an order and the customer is charged.

Alternatively, you could follow these steps to handle the payment process with a custom checkout.

Book a class session

Your app 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 to retrieve the timeZone of the business location.
  2. Use Query Services and pass {"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. Run Query Availability. Provide 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 sessionId.
  6. Invoke Create Booking and pass the relevant sessionId in booking.bookedEntity.slot.sessionId. If the class session's availability hasn't changed since running 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. Set options.paymentStatus to PAID to update the booking status to CONFIRMED.
  3. Run Create Order with your custom payment details.

Alternatively, you could follow these steps to handle the payment process with Wix eCommerce.

Book a course

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

To book a course:

  1. Use Query Services and pass {"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. Make sure to provide 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. Invoke Create Booking and pass the relevant schedule ID as booking.bookedEntity.scheduleId. If the course's availability hasn't changed since running Query Extended Bookings, the call 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: Calling Create Booking 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?