> 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: getReservationLocation(reservationLocationId: string, options: GetReservationLocationOptions) # Method package: wixTableReservationsV2 # Method menu location: wixTableReservationsV2 --> reservationLocations --> getReservationLocation # Method Link: https://dev.wix.com/docs/velo/apis/wix-table-reservations-v2/reservation-locations/get-reservation-location.md # Method Description: Retrieves a reservation location by ID. 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. ## Get a reservation location (page code) ```javascript import { reservationLocations } from 'wix-table-reservations-v2'; // Sample reservationLocationId value: 'fab8cc1f-31cf-462f-b5bb-392594624bf2' reservationLocations.getReservationLocation(reservationLocationId) .then((retrievedReservationLocation) => { const isDefault = retrievedReservationLocation.default; const minNotice = retrievedReservationLocation.configuration.onlineReservations.minimumReservationNotice; console.log('Success! Retrieved reservation location:', retrievedReservationLocation); return retrievedReservationLocation; }) .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * { * "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" * } */ ``` ## Get a reservation location with options (backend) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { reservationLocations } from 'wix-table-reservations.v2'; import { elevate } from 'wix-auth'; /* Sample reservationLocationId value: 'fab8cc1f-31cf-462f-b5bb-392594624bf2' * * Sample options value: * { * "fieldsets": ["FULL"] * } */ export const myGetReservationLocationFunction = webMethod(Permissions.Anyone, async (reservationLocationId, options) => { const elevatedGetReservationLocation = elevate(reservationLocations.getReservationLocation); try { const result = await elevatedGetReservationLocation(reservationLocationId, options); return result; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "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" * } */ ``` ## Close a restaurant and cancel all reservations on a given day ```javascript /* This example requires the following elements: * A dropdown element named `locationDropdown`. * A date picker element named 'datePicker`. * A button named `confirmButton`. * A text element named `cancellationNotice`. */ /********************************************** * Backend code - reservationLocations.web.js * **********************************************/ import { Permissions, webMethod } from 'wix-web-module'; import { reservationLocations } from 'wix-table-reservations.v2'; 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 } }); export const getRestaurantDetails = webMethod(Permissions.Anyone, async (reservationLocationId, options) => { const elevatedGetReservationLocations = elevate(reservationLocations.getReservationLocation); try { const result = await elevatedGetReservationLocations(reservationLocationId, options); return result; } catch (error) { console.error(error); // Handle the error } }); 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 } }); /******************************************* * Backend code - reservations.web.js * *******************************************/ import { Permissions, webMethod } from 'wix-web-module'; import { reservations } from 'wix-table-reservations.v2'; import { elevate } from 'wix-auth'; export const queryReservationsInDateRange = webMethod(Permissions.Anyone, async (startDate, endDate) => { const elevatedQueryReservations = elevate(reservations.queryReservations); try { const result = await elevatedQueryReservations() .ge('details.startDate', startDate) .lt('details.startDate', endDate) .find(); 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 { getRestaurantLocation } from 'backend/reservationLocations.web.js'; import { getRestaurantDetails } from 'backend/reservationLocations.web.js'; import { updateRestaurantDetails } from 'backend/reservationLocations.web.js'; import { queryReservationsInDateRange } from 'backend/reservations.web.js'; $w.onReady(async function () { $w('#datePicker').hide(); $w('#confirmButton').hide(); $w('#cancellationNotice').hide(); // Set the earliest selectable date to the day after the current date var tomorrowsDate = new Date(); tomorrowsDate.setDate(tomorrowsDate.getDate() + 1); $w('#datePicker').minDate = tomorrowsDate; $w('#datePicker').value = tomorrowsDate; //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 dropdown list let dropdownOptions = []; 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); dropdownOptions.push({ "label": locationObject.name, "value": myReservationLocationList[object]._id }) } //Populate our dropdown list with the array $w("#locationDropdown").options = dropdownOptions; $w('#locationDropdown').onChange( (event) => { if ($w('#locationDropdown').value) { $w('#datePicker').show(); $w('#confirmButton').show(); } }); $w('#confirmButton').onClick( async (event) => { const options = { "fieldsets": "FULL" } const selectedLocation = await getRestaurantDetails($w('#locationDropdown').value, options) //Create a new special hour period to push to the list in our reservation location's business schedule const selectedDate = $w('#datePicker').value; const dayAfterSelectedDate = new Date(selectedDate); dayAfterSelectedDate.setDate(selectedDate.getDate() + 1); const mySpecialHourPeriod = { "startDate": selectedDate, "endDate": dayAfterSelectedDate, "isClosed": true } if(!("businessSchedule" in selectedLocation.configuration.onlineReservations)){ //Handle business schedule configuration } selectedLocation.configuration.onlineReservations.businessSchedule.specialHourPeriod.push(mySpecialHourPeriod); await updateRestaurantDetails(selectedLocation._id, selectedLocation); //Create a variable to hold of names and phone numbers of canceled reservations. let canceledReservationsNote = "Notify of cancellation:\n"; //Query for reservations on the selected date and cancel any at our selected reservation location let reservationsOnSelectedDate = await queryReservationsInDateRange(selectedDate, dayAfterSelectedDate); for(let reservation in reservationsOnSelectedDate._items){ if(reservationsOnSelectedDate._items[reservation].details.reservationLocationId == selectedLocation._id){ let options = { "phone" : reservationsOnSelectedDate._items[reservation].reservee.phone } const canceledReservation = await (async () => { try { return reservations.cancelReservation(reservationsOnSelectedDate._items[reservation]._id, reservationsOnSelectedDate._items[reservation].revision, options) } catch (error) { console.error(error); // Handle the error return false; } })(); if(canceledReservation){ canceledReservationsNote += "First name: " + reservationsOnSelectedDate._items[reservation].reservee.firstName + ". Last name: " + reservationsOnSelectedDate._items[reservation].reservee.lastName + ". Phone: " + reservationsOnSelectedDate._items[reservation].reservee.phone + "\n"; } } } $w('#cancellationNotice').text = canceledReservationsNote; $w('#cancellationNotice').show(); }); }); ``` ---