I am trying to create my own custom service pages. I am following this tutorial. I am encountering an issue as not all the available slots are retrieved. I have different classes, some happens every week on the same day, some are on an ad hoc basis, but on our Wix Bookings tool we have multiple classes planned for the next few months.
For none of the services I am able to retrieve all the available slots using the method in the tutorial : using getServiceAvailability() . For some there is only one slot, some there a few but still not all.
Searching on this forum, I see that it was already an issue back in 2019/2020 that was supposed to be solved ?
Greetings Lili, Jacob from Wix Bookings here.
Are you looking for the availability for a class? A course? An appointment?
Do you apply the dates correctly?
Please share your code and the site url you are applying the code on.
Thank you for your help. I’m trying to retrieve and display all the available slots for my classes on their individual custom service page. Unfortunately I can not share the site url but i’ll try to add pertinent screen captures to help you understand my issue.
This is the code, it’s quite exactly the same as the tutorial (i haven’t been able to go further yet)
$w.onReady(function () {
$w('#dynamicDataset').onReady(() => {
// this is how i retrieve the class id
let selectedService = $w('#dynamicDataset').getCurrentItem()._id;
//following the wix support tutorial
let availableSlots;
let slotOptions;
let enabledDates;
let selectedSlot;
let slotIndex;
wixBookings.getServiceAvailability(selectedService)
.then( (availability) => {
availableSlots = availability.slots;
slotOptions = availableSlots.map((slot) => {
let date = slot.startDateTime;
return {
"slotDate": date.toLocaleDateString() + " " + date.toLocaleTimeString(),
}
});
$w('#slotTable').rows = slotOptions;
});
});
});
Using this code, this is how the slotTable looks like :
All the available slots are appearing just fine on the “premade” wix bookings service pages :
HI, from your code I see that you don’t pass the time frame.
Quoting from the documentation, “Optionally, you can pass an AvailabilityOptions object that defines a date range for which slots should be returned. If you do not pass an an AvailabilityOptions object, the default date range is from the date and time the function is called until one week later.”
Please take a look at the “Get the available slots for a service for a specific date range” example in https://www.wix.com/velo/reference/wix-bookings/getserviceavailability and implement it in your code.