> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: listReservationLocations(options: ListReservationLocationsOptions) # Method package: wixTableReservationsV2 # Method menu location: wixTableReservationsV2 --> reservationLocations --> listReservationLocations # Method Link: https://dev.wix.com/docs/velo/apis/wix-table-reservations-v2/reservation-locations/list-reservation-locations.md # Method Description: Retrieves a list of up to 100 reservation locations. The `FULL` fieldset can only be retrieved by users with the `READ RESERVATION LOCATIONS (FULL)` or `MANAGE RESERVATION LOCATIONS` permission scopes. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## List reservation locations (page code) ```javascript import { reservationLocations } from 'wix-table-reservations-v2'; reservationLocations.listReservationLocations() .then((retrievedReservationLocations) => { const isDefault = retrievedReservationLocations.reservationLocations[0].default; const minNotice = retrievedReservationLocations.reservationLocations[0].configuration.onlineReservations.minimumReservationNotice; console.log('Success! Retrieved reservation location list:', retrievedReservationLocations); return retrievedReservationLocations; }) .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * { * "reservationLocations": [ * { * "location": { * "name": "Yunitsman Street", * "fax": "", * "timeZone": "Europe/Dublin", * "email": "", * "phone": "", * "address": { * "formatted": "Yunitsman Street 5, Tel Aviv-Yafo, Israel", * "location": { * "latitude": 32.141816, * "longitude": 34.7987383 * }, * "streetAddress": { * "name": "Yunitsman Street", * "number": "5", * "apt": "" * }, * "city": "Tel Aviv-Yafo", * "subdivision": "", * "country": "IL", * "postalCode": "" * }, * "businessSchedule": { * "periods": [ * { * "openDay": "SUNDAY", * "openTime": "08:00", * "closeDay": "MONDAY", * "closeTime": "20:00" * }, * { * "openDay": "THURSDAY", * "openTime": "08:00", * "closeDay": "SUNDAY", * "closeTime": "01:00" * } * ], * "specialHourPeriod": [] * }, * "_id": "9bd42376-12c2-483e-86c3-8ee685e718e1" * }, * "configuration": { * "onlineReservations": { * "partiesSize": { * "min": 1, * "max": 6 * }, * "minimumReservationNotice": { * "number": 30, * "unit": "MINUTES" * }, * "turnoverTimeRules": [], * "turnoverRules": [], * "onlineReservationsEnabled": true * }, * "myReservationsFields": [] * }, * "default": false, * "archived": false, * "_id": "800c581a-1942-4079-8198-2eee44463eb7" * }, * { * "location": { * "name": "Nemal Tel Aviv Street", * "fax": "", * "timeZone": "Europe/Dublin", * "email": "", * "phone": "", * "address": { * "formatted": "Tel Aviv Port, Nemal Tel Aviv Street, Tel Aviv, Israel", * "location": { * "latitude": 32.0972612, * "longitude": 34.77376549999999 * }, * "streetAddress": { * "name": "Nemal Tel Aviv Street", * "number": "", * "apt": "" * }, * "city": "Tel Aviv-Yafo", * "country": "IL" * }, * "businessSchedule": { * "periods": [ * { * "openDay": "SUNDAY", * "openTime": "00:00", * "closeDay": "MONDAY", * "closeTime": "00:00" * }, * { * "openDay": "THURSDAY", * "openTime": "00:00", * "closeDay": "SUNDAY", * "closeTime": "00:00" * } * ], * "specialHourPeriod": [] * }, * "_id": "f1f59093-6842-45a4-b9d1-106429ec8313" * }, * "configuration": { * "onlineReservations": { * "partiesSize": { * "min": 1, * "max": 6 * }, * "minimumReservationNotice": { * "number": 30, * "unit": "MINUTES" * }, * "turnoverTimeRules": [], * "turnoverRules": [], * "businessSchedule": { * "periods": [ * { * "openDay": "SUNDAY", * "openTime": "00:00", * "closeDay": "TUESDAY", * "closeTime": "00:00" * }, * { * "openDay": "WEDNESDAY", * "openTime": "00:00", * "closeDay": "THURSDAY", * "closeTime": "00:00" * }, * { * "openDay": "FRIDAY", * "openTime": "00:00", * "closeDay": "SUNDAY", * "closeTime": "00:00" * } * ], * "specialHourPeriod": [] * }, * "onlineReservationsEnabled": true * }, * "reservationForm": { * "customFieldDefinitions": [ * { * "name": "Allergies", * "required": false, * "_id": "f4283b2d-6340-4cf9-bae7-8769e6b62127" * } * ] * }, * "myReservationsFields": [] * }, * "default": true, * "archived": false, * "_id": "fab8cc1f-31cf-462f-b5bb-392594624bf2" * } * ], * "pagingMetadata": { * "count": 2, * "cursors": {}, * "hasNext": false * } * } */ ``` ## List reservation locations with options (backend) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { reservationLocations } from 'wix-table-reservations.v2'; import { elevate } from 'wix-auth'; /* Sample options value: * { * "fieldsets": ["FULL"], * "sort": { * "fieldName": "_id", * "order": "ASC" * } * } */ export const myListReservationLocationsFunction = webMethod(Permissions.Anyone, async (options) => { const elevatedListReservationLocations = elevate(reservationLocations.listReservationLocations); try { const result = await elevatedListReservationLocations(options); return result; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "reservationLocations": [ * { * "revision": "2", * "location": { * "name": "Yunitsman Street", * "fax": "", * "timeZone": "Europe/Dublin", * "email": "", * "phone": "", * "address": { * "formatted": "Yunitsman Street 5, Tel Aviv-Yafo, Israel", * "location": { * "latitude": 32.141816, * "longitude": 34.7987383 * }, * "streetAddress": { * "name": "Yunitsman Street", * "number": "5", * "apt": "" * }, * "city": "Tel Aviv-Yafo", * "subdivision": "", * "country": "IL", * "postalCode": "" * }, * "businessSchedule": { * "periods": [ * { * "openDay": "SUNDAY", * "openTime": "00:00", * "closeDay": "MONDAY", * "closeTime": "00:00" * }, * { * "openDay": "THURSDAY", * "openTime": "00:00", * "closeDay": "SUNDAY", * "closeTime": "00:00" * } * ], * "specialHourPeriod": [] * }, * "_id": "9bd42376-12c2-483e-86c3-8ee685e718e1" * }, * "configuration": { * "onlineReservations": { * "partiesSize": { * "min": 1, * "max": 6 * }, * "partySize": { * "min": 1, * "max": 6 * }, * "minimumReservationNotice": { * "number": 30, * "unit": "MINUTES" * }, * "defaultTurnoverTime": 90, * "turnoverTimeRules": [], * "turnoverRules": [], * "onlineReservationsEnabled": true * }, * "reservationForm": { * "customFieldDefinitions": [] * }, * "myReservationsFields": [ * { * "fieldType": "TABLE", * "shown": true * }, * { * "fieldType": "START_DATE", * "shown": true * }, * { * "fieldType": "END_DATE", * "shown": true * }, * { * "fieldType": "CREATED_DATE", * "shown": true * }, * { * "fieldType": "UPDATED_DATE", * "shown": true * }, * { * "fieldType": "PARTY_SIZE", * "shown": true * }, * { * "fieldType": "FIRST_NAME", * "shown": true * }, * { * "fieldType": "LAST_NAME", * "shown": true * }, * { * "fieldType": "EMAIL", * "shown": true * }, * { * "fieldType": "PHONE", * "shown": true * }, * { * "fieldType": "ADDITIONAL_INFO", * "shown": true * }, * { * "fieldType": "TEAM_MESSAGE", * "shown": true * }, * { * "fieldType": "STATUS", * "shown": true * } * ], * "tableManagement": { * "tableDefinitions": [ * { * "name": "Small table", * "seatsMin": 1, * "seatsMax": 4, * "isActive": true, * "_id": "ec4adfb0-568f-4846-8f92-86059ef94ec8" * }, * { * "name": "Big table", * "seatsMin": 3, * "seatsMax": 6, * "isActive": true, * "_id": "63b73378-5e79-401c-9a69-3e4da76558d3" * } * ], * "deletedTableDefinitions": [], * "tableCombinations": [] * } * }, * "default": false, * "archived": false, * "_id": "800c581a-1942-4079-8198-2eee44463eb7", * "_createdDate": "2023-10-08T07:07:39.123Z", * "_updatedDate": "2024-01-09T12:42:12.667Z" * }, * { * "revision": "10", * "location": { * "name": "Nemal Tel Aviv Street", * "fax": "", * "timeZone": "Europe/Dublin", * "email": "", * "phone": "", * "address": { * "formatted": "Tel Aviv Port, Nemal Tel Aviv Street, Tel Aviv, Israel", * "location": { * "latitude": 32.0972612, * "longitude": 34.77376549999999 * }, * "streetAddress": { * "name": "Nemal Tel Aviv Street", * "number": "", * "apt": "" * }, * "city": "Tel Aviv-Yafo", * "country": "IL" * }, * "businessSchedule": { * "periods": [ * { * "openDay": "SUNDAY", * "openTime": "00:00", * "closeDay": "MONDAY", * "closeTime": "00:00" * }, * { * "openDay": "THURSDAY", * "openTime": "00:00", * "closeDay": "SUNDAY", * "closeTime": "00:00" * } * ], * "specialHourPeriod": [] * }, * "_id": "f1f59093-6842-45a4-b9d1-106429ec8313" * }, * "configuration": { * "onlineReservations": { * "seatPacing": { * "number": 11, * "enabled": false * }, * "partyPacing": { * "number": 6, * "enabled": true * }, * "partiesSize": { * "min": 1, * "max": 6 * }, * "partySize": { * "min": 1, * "max": 6 * }, * "minimumReservationNotice": { * "number": 30, * "unit": "MINUTES" * }, * "defaultTurnoverTime": 90, * "turnoverTimeRules": [], * "turnoverRules": [], * "businessSchedule": { * "periods": [ * { * "openDay": "SUNDAY", * "openTime": "00:00", * "closeDay": "TUESDAY", * "closeTime": "00:00" * }, * { * "openDay": "WEDNESDAY", * "openTime": "00:00", * "closeDay": "THURSDAY", * "closeTime": "00:00" * }, * { * "openDay": "FRIDAY", * "openTime": "00:00", * "closeDay": "SUNDAY", * "closeTime": "00:00" * } * ], * "specialHourPeriod": [] * }, * "onlineReservationsEnabled": true * }, * "reservationForm": { * "customFieldDefinitions": [ * { * "name": "Allergies", * "required": false, * "_id": "f4283b2d-6340-4cf9-bae7-8769e6b62127" * } * ] * }, * "myReservationsFields": [ * { * "fieldType": "TABLE", * "shown": true * }, * { * "fieldType": "START_DATE", * "shown": true * }, * { * "fieldType": "END_DATE", * "shown": true * }, * { * "fieldType": "CREATED_DATE", * "shown": true * }, * { * "fieldType": "UPDATED_DATE", * "shown": true * }, * { * "fieldType": "PARTY_SIZE", * "shown": true * }, * { * "fieldType": "FIRST_NAME", * "shown": true * }, * { * "fieldType": "LAST_NAME", * "shown": true * }, * { * "fieldType": "EMAIL", * "shown": true * }, * { * "fieldType": "PHONE", * "shown": true * }, * { * "fieldType": "ADDITIONAL_INFO", * "shown": true * }, * { * "fieldType": "TEAM_MESSAGE", * "shown": true * }, * { * "fieldType": "STATUS", * "shown": true * }, * { * "fieldType": "CUSTOM_FIELD", * "customFieldId": "f4283b2d-6340-4cf9-bae7-8769e6b62127", * "shown": false * } * ], * "tableManagement": { * "tableDefinitions": [ * { * "name": "Small table", * "seatsMin": 1, * "seatsMax": 4, * "isActive": true, * "_id": "1ed802ae-708f-4da6-9177-54c3df5d3dd5" * }, * { * "name": "Big table", * "seatsMin": 3, * "seatsMax": 6, * "isActive": true, * "_id": "2c8aed3a-20c5-404c-b075-84a92f90a996" * } * ], * "deletedTableDefinitions": [], * "tableCombinations": [ * { * "tableIds": [ * "1ed802ae-708f-4da6-9177-54c3df5d3dd5", * "2c8aed3a-20c5-404c-b075-84a92f90a996" * ], * "seatsMin": 7, * "seatsMax": 10, * "isActive": true, * "_id": "6df9a875-d30d-4c0f-9faa-0a5ae18cd6f6" * } * ] * } * }, * "default": true, * "archived": false, * "_id": "fab8cc1f-31cf-462f-b5bb-392594624bf2", * "_createdDate": "2023-07-10T09:06:07.507Z", * "_updatedDate": "2024-01-09T12:42:12.840Z" * } * ], * "pagingMetadata": { * "count": 2, * "cursors": {}, * "hasNext": false * } * } */ ``` ## Update the minimum required notice for reservations at all locations ```javascript /* This example requires the following elements: * A slider element named `noticeSlider`. * A button named `setMinNoticeButton` with an onClick() event handler named `setMinNoticeButton_click`. */ /********************************************** * Backend code - reservationLocations.web.js * **********************************************/ import { Permissions, webMethod } from 'wix-web-module'; import { reservationLocations } from 'wix-table-reservations.v2'; import { elevate } from 'wix-auth'; export const updateRestaurantDetails = webMethod(Permissions.Anyone, async (reservationLocationId, reservationLocationObject) => { const elevatedUpdateReservationLocation = elevate(reservationLocations.updateReservationLocation); try { const result = await elevatedUpdateReservationLocation(reservationLocationId, reservationLocationObject); return result; } catch (error) { console.error(error); // Handle the error } }); export const listRestaurantLocations = webMethod(Permissions.Anyone, async (options) => { const elevatedListReservationLocations = elevate(reservationLocations.listReservationLocations); try { const result = await elevatedListReservationLocations(options); return result; } catch (error) { console.error(error); // Handle the error } }); /************* * Page code * *************/ import { listRestaurantLocations, updateRestaurantDetails } from 'backend/reservationLocations.web.js'; export async function setMinNoticeButton_click(event) { const options = { "fieldsets": ["FULL"], }; const locationList = await listRestaurantLocations(options); //Loop through each reservationLocation and update `minimumReservationNotice` for (const item in locationList.reservationLocations) { const selectedLocation = locationList.reservationLocations[item]; selectedLocation.configuration.onlineReservations.minimumReservationNotice = { "number": $w("#noticeSlider").value, "unit": "MINUTES" }; await updateRestaurantDetails(selectedLocation._id, selectedLocation); } } ``` ## Create a held reservation with a given time, location, and party size. ```javascript /* This example requires the following elements: * A dropdown element named `locationDropdown`. * A dropdown element named `partySizeDropdown`. * A dropdown element named `timeSlotDropdown`. * A button named `confirmButton`. * A text element named `heldReservationNotification`. */ /********************************************** * Backend code - reservationLocations.web.js * **********************************************/ import { Permissions, webMethod } from 'wix-web-module'; import { locations } from 'wix-business-tools.v2'; import { elevate } from 'wix-auth'; export const getRestaurantLocation = webMethod(Permissions.Anyone, async (location_id) => { const elevatedGetLocation = elevate(locations.getLocation); try { const result = await elevatedGetLocation(location_id); return result; } catch (error) { console.error(error); // Handle the error } }); /************* * Page code * *************/ import { reservationLocations } from 'wix-table-reservations.v2'; import { reservations } from 'wix-table-reservations.v2'; import { timeSlots } from 'wix-table-reservations.v2'; import { getRestaurantLocation } from 'backend/reservationLocations.web.js'; $w.onReady(async function () { $w('#timeSlotDropdown').hide(); $w('#partySizeDropdown').hide(); $w('#confirmButton').hide(); $w('#heldReservationNotification').hide(); //Get the list of reservation locations const myReservationLocationList = await (async () => { try { let fullListObject = await reservationLocations.listReservationLocations(); return fullListObject.reservationLocations; } catch (error) { console.error(error); // Handle the error } })(); //Create an array to hold names and values for our locations dropdown list let locationDropdownOptions = []; for (const object in myReservationLocationList){ //Use the _id stored in the reservation location's location object to get the location's name from the `locations` service const locationObject = await getRestaurantLocation(myReservationLocationList[object].location._id); locationDropdownOptions.push({ "label": locationObject.name, "value": myReservationLocationList[object]._id }) } //Populate our dropdown list with the array $w("#locationDropdown").options = locationDropdownOptions; //Create an array to hold numbers and values for our party size dropdown list let partySizeDropdownOptions = []; for (let i = 1; i<10; i++){ partySizeDropdownOptions.push({ "label": String(i), "value": String(i) }) } //Populate our dropdown list with the array $w("#partySizeDropdown").options = partySizeDropdownOptions; $w('#locationDropdown').onChange( (event) => { if ($w('#locationDropdown').value) { $w('#partySizeDropdown').show(); $w('#timeSlotDropdown').hide() $w('#confirmButton').hide(); } }); $w('#partySizeDropdown').onChange( async (event) => { if ($w('#locationDropdown').value) { $w('#timeSlotDropdown').show() $w('#confirmButton').hide(); const timeSlotDetails = { "reservationLocationId": $w('#locationDropdown').value, "date": new Date(), "partySize": parseInt($w('#partySizeDropdown').value) }; const timeSlotOptions = { "duration": 30, "slotsAfter": 8, "slotsBefore": 0 }; //Get the list of time slots according to the details and options above const availableTimeSlots = await (async () => { try { let fullListObject = await timeSlots.getTimeSlots(timeSlotDetails.reservationLocationId, timeSlotDetails.date, timeSlotDetails.partySize, timeSlotOptions); return fullListObject.timeSlots; } catch (error) { console.error(error); // Handle the error } })(); //Create an array to hold numbers and values for our time slot dropdown list let timeSlotDropdownOptions = []; for (const timeSlot in availableTimeSlots){ if(availableTimeSlots[timeSlot].status == "AVAILABLE"){ timeSlotDropdownOptions.push({ "label": String(availableTimeSlots[timeSlot].startDate), "value": String(availableTimeSlots[timeSlot].startDate) }) } } //Populate our dropdown list with the array $w("#timeSlotDropdown").options = timeSlotDropdownOptions; } }); $w('#timeSlotDropdown').onChange( async (event) => { if ($w('#timeSlotDropdown').value) { $w('#confirmButton').show(); } }); $w('#confirmButton').onClick( async (event) => { //Get the list of time slots according to the details and options above const createdHeldReservation = await (async () => { try { const reservationDetails = { "reservationLocationId": $w('#locationDropdown').value, "startDate": new Date($w("#timeSlotDropdown").value), "partySize": parseInt($w('#partySizeDropdown').value) }; return await reservations.createHeldReservation(reservationDetails); } catch (error) { console.error(error); // Handle the error } })(); if(createdHeldReservation){ $w('#heldReservationNotification').text = "Held reservation created successfully." $w('#heldReservationNotification').show(); } }); }); ``` ---