Velo: Build a custom Booking Calendar page

You can replace your site’s default Wix Booking Calendar page with your own customized version. This enables you to modify or extend the page’s functionality to suit your precise business needs.

Important: This feature is currently not supported with Multi-service bookings appointments.

To integrate the page into your site’s booking flow and implement its functionality, you need to add code to the page and use Velo APIs.

Your code has to do several things:

  • Get data about the selected service and query session availability data.
  • Handle UI initialization and interactions.
  • Implement any customized business logic.
  • Direct users to the next page in the flow.

Step 1 | Add a custom Calendar page to your site

To create a custom calendar page, do one of the following:

Wix Editor
  1. Turn on Dev Mode.
  2. Click Pages on the left side of the Editor.
  3. Click Bookings Pages, and then on the Booking Calendar page, click .
  4. Click Replace with custom page.
  5. In the confirmation panel, click Replace.

Wix Studio
  1. Turn on Dev Mode by clicking and then Start Coding from the sidebar on the left side of the Editor.
  2. Click Pages on the sidebar.
  3. On the Booking Calendar (under Bookings Pages), click the More Actions icon .
  4. Click Replace with custom page.
  5. In the confirmation panel, click Replace.

Step 2 | Design your custom page

Add elements to the page to create your business’s customized design and functionality, such as text, buttons, and images.

At a minimum, these elements must:

  • Display information about the selected service.
  • Provide the site visitor with a way to view availability and select a slot.
  • Provide an action button that navigates to the next page in the flow (usually the Booking Form).

Step 3 | Add Velo code to your page

  1. Use the getAppPageData() function to get the service object associated with the page.

For example:

Copy
1
import wixWindow from 'wix-window';
2
import { availabilityCalendar } from 'wix-bookings.v2';
3
import wixLocation from 'wix-location';
4
5
$w.onReady(async function () {
6
const pageData = await wixWindow.getAppPageData();
7
const serviceId = pageData.service.id;
8
});

Note: To receive a populated page data object using getAppPageData() when testing your code, do the following:

  • Create at least one Bookings service.
  • Preview the Bookings Calendar page and then return to the editor.
  1. Get the service’s session availability data using the availabilityCalendar.queryAvailability() function.
    The following example queries data for the upcoming week:
Copy
1
const today = new Date();
2
const nextWeek = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1000);
3
let query = {
4
filter: {
5
serviceId: [serviceId],
6
startDate: today,
7
endDate: nextWeek,
8
}
9
}
10
const selectedTimezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
11
const options = {
12
timezone: selectedTimezone
13
};
14
const availability = await availabilityCalendar.queryAvailability(query, options);
15
const entries = availability.availabilityEntries;
  1. Initialize your custom page’s elements with the service information and availability data that you retrieved in the previous steps. Use the $w namespace to control the page’s elements. For example:
Copy
1
$w('#serviceName').text = myService.name;
2
const slotOptions = [];
3
entries.forEach((entry, index) => {
4
const label = `${entry.slot.startDate}-${entry.slot.endDate}`;
5
const value = `${index}``;
6
slotOptions.push({ label, value });
7
});
8
$w('#dropdown').options = slotOptions;
  1. Depending on the functionality you’re developing, implement any business logic that your customized page requires.

  2. Add an event handler to the page’s action button so that it navigates to the next page in the flow, which is typically your site’s Booking Form. You can create a link to a preloaded Booking Form, specifying the appropriate query params based on the user's selections.
    For example:

For example:

Copy
1
$w('#nextButton').onClick(() => {
2
const selectedIndex = $w('#dropdown').selectedIndex;
3
const selectedSlot = entries[selectedIndex].slot;
4
let queryParams = `?bookings_serviceId=${serviceId}&bookings_resourceId=${selectedSlot.resource._id}&bookings_startDate=${encodeURIComponent(selectedSlot.startDate)}&bookings_endDate=${encodeURIComponent(selectedSlot.endDate)}&bookings_timezone=${selectedTimezone}`;
5
const nextUrl = "/booking-form" + queryParams;
6
wixLocation.to(nextUrl);
7
})

Your custom page can now display the service’s data, provide site visitors with an interface for selecting an available slot, and direct them to the next page in the booking flow.

Was this helpful?
Yes
No