> 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 # GetReservationLocation # Package: reservations # Namespace: ReservationLocationsService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/reservations/reservation-locations/get-reservation-location.md ## Permission Scopes: Read Reservation Locations (Basic): SCOPE.DC-RESERVATIONS.READ-LOCATIONS-BASIC Read Reservation Locations (Full): SCOPE.DC-RESERVATIONS.READ-LOCATIONS-FULL ## Introduction Retrieves a reservation location by ID. --- ## REST API ### Schema ``` Method: getReservationLocation Description: Retrieves a reservation location by GUID. URL: https://www.wixapis.com/v1/reservation-locations/{reservationLocationId} Method: GET # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: reservationLocationId Method parameters: param name: reservationLocationId | type: none | required: true Return type: GetReservationLocationResponse - name: reservationLocation | type: ReservationLocation | description: The retrieved reservation location. - name: id | type: string | description: Reservation location GUID. - name: revision | type: string | description: Represents the current state of a reservation location. Each time the reservation location is modified, its `revision` changes. For an update operation to succeed, you must specify the latest revision. - name: createdDate | type: string | description: The date and time this reservation location was created. - name: updatedDate | type: string | description: The date and time this reservation location was last updated. - name: location | type: Location | description: Physical location details. Locations can be created and configured using the Locations API. or on the [Business Info](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fsettings/business-info) page in the Dashboard. - name: id | type: string | description: Location GUID. - name: configuration | type: Configuration | description: Reservation location configuration. - name: onlineReservations | type: OnlineReservations | description: Settings for this location that are used to determine restaurant availability for reservations made online. - name: approval | type: Approval | description: Approval settings. - ONE-OF: - name: manualForLargePartiesOptions | type: ManualForLargePartiesOptions | description: Manual approval for large parties options. - name: partySizeThreshold | type: integer | description: The minimum party size that requires manual approval. - name: considerTablesForManualApproval | type: boolean | description: Use tables for manual approval part. - name: mode | type: Mode | description: Approval mode. - enum: AUTOMATIC, MANUAL, MANUAL_FOR_LARGE_PARTIES - name: seatPacing | type: SeatPacing | description: Seat pacing settings. The maximum number of seats that can be filled by new reservations within a 15-minute period. For example, setting a seat pacing of 15 would mean that between `10:00.000`-`10:14.999` there will be no more than 15 new seats available for reservation. - name: number | type: integer | description: Maximum number of seats allowed per `timeSlotInterval`. - name: enabled | type: boolean | description: Whether this option is enabled. - name: partyPacing | type: PartyPacing | description: Party pacing settings. The maximum number of party reservations that can start within a `timeSlotInterval` period. For example, if `timeSlotInterval` is 15 minutes, then a party pacing of 5 would mean that no more than 5 parties could make a reservation for the period between `10:00.000`-`10:14.999`. - name: number | type: integer | description: Maximum number of new party reservations allowed per `timeSlotInterval`. - name: enabled | type: boolean | description: Whether this option is enabled. - name: partySize | type: PartySize | description: Party size limits for a reservation. - name: min | type: integer | description: Minimum number of seats a party can reserve. - name: max | type: integer | description: Maximum number of seats a party can reserve. - name: minimumReservationNotice | type: NoticePeriod | description: Minimum reservation notice. The minimum amount of time that must be allowed between making a reservation and that reservation's start time. - name: number | type: integer | description: The quantity of the chosen time unit. - name: unit | type: Unit | description: Time unit. - enum: UNKNOWN, MINUTES, HOURS, DAYS - name: maximumReservationNotice | type: NoticePeriod | description: Maximum reservation notice. The maximum amount of time that can be allowed between making a reservation and that reservation's start time. - name: defaultTurnoverTime | type: integer | description: Default turnover time in minutes. Turnover time is how much time a party is allotted for their entire reservation - from being seated to leaving the restaurant. - name: turnoverTimeRules | type: array | description: Custom turnover time rules. This allows you to set different turnover times for different party sizes. - name: seatsMin | type: integer | description: Minimum number of seats to qualify for this rule. - name: seatsMax | type: integer | description: Maximum number of seats to qualify for this rule. - name: minutes | type: integer | description: Turnover time in minutes for qualifying parties. - name: businessSchedule | type: BusinessSchedule | description: The location's business schedule. Limited to 100 time periods. - name: periods | type: array | description: - name: openDay | type: DayOfWeek | description: Day of the week this period starts on. - enum: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY - name: openTime | type: string | description: Time this period starts in 24hr [ISO 8601](http://www.w3.org/TR/NOTE-datetime) extended format (hh:mm). Valid values are `00:00-24:00`, where `24:00` represents midnight at the end of the specified day field. - name: closeDay | type: DayOfWeek | description: Day of the week this period ends on. - name: closeTime | type: string | description: Time this period ends in 24hr [ISO 8601](http://www.w3.org/TR/NOTE-datetime) extended format (hh:mm). Valid values are `00:00-24:00`, where `24:00` represents midnight at the end of the specified day field. This is the last time a reservation can be made at the restaurant, not the time the restaurant closes its doors. - name: specialHourPeriod | type: array | description: Time periods during which this location is open. Each period represents a range of hours during the week during which the location is open. Max: 100 time periods - name: startDate | type: string | description: Start date and time in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#combined_date_and_time_representations) format. - name: endDate | type: string | description: End date and time in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#combined_date_and_time_representations) format. - name: isClosed | type: boolean | description: Whether or not the location is closed during this period. - name: comment | type: string | description: Additional details about the period. - name: showPhoneNumber | type: boolean | description: Whether a phone number is shown. - name: onlineReservationsEnabled | type: boolean | description: Whether online reservations are enabled. - name: pauseSettings | type: PauseSettings | description: Pause settings for reservations. - name: standardReservations | type: StandardReservations | description: Pause settings for standard reservations. - name: pauseFrom | type: string | description: Timestamp from which online reservations are paused. Read-only, set automatically when pause is configured. - name: pauseUntil | type: string | description: Timestamp until which online reservations are paused. When set and the current time is before this timestamp, online reservations are blocked. When the current time passes this timestamp, reservations automatically resume. - name: timeSlotInterval | type: integer | description: Interval between a reservation location's time slots in minutes. This controls the interval between time slots on a Wix site's Reservations page, and the interval between time slots returned by the Time Slots API's Get Time Slots method. Default: `15` - name: reservationForm | type: ReservationForm | description: Reservation form settings. - name: submitMessage | type: string | description: A message shown to the customer in the registration form. - name: policiesEnabled | type: boolean | description: Whether to show policies (the terms and conditions, and the privacy policy) to the customer. - name: termsAndConditions | type: TermsAndConditions | description: Settings for displaying the terms and conditions. - ONE-OF: - name: url | type: PageUrlV2 | description: Terms and conditions URL. - name: relativePath | type: string | description: The relative path for the page within the site. - name: url | type: string | description: The page's full URL. - name: text | type: string | description: Terms and conditions text. - name: enabled | type: boolean | description: Whether the terms and conditions are shown to the customer. Default: `false` - name: privacyPolicy | type: PrivacyPolicy | description: Settings for displaying the privacy policy. - ONE-OF: - name: url | type: PageUrlV2 | description: Privacy policy URL. - name: text | type: string | description: Privacy policy text. - name: enabled | type: boolean | description: Whether the privacy policy is shown to the customer. Default: `false` - name: customFieldDefinitions | type: array | description: Custom fields you wish to add to the registration form for the customer to fill in. - name: id | type: string | description: Custom field GUID. - name: name | type: string | description: Custom field name. - name: required | type: boolean | description: Whether the custom field is required. Default: `false` - name: lastNameRequired | type: boolean | description: Whether a last_name is required in the reservation form. Default: `false` - name: emailRequired | type: boolean | description: Whether an email is required in the reservation form. Default: `false` - name: emailMarketingCheckbox | type: EmailMarketingCheckbox | description: Email marketing checkbox settings. - name: enabled | type: boolean | description: Whether the checkbox is shown to the customer. Default: `false` - name: checkedByDefault | type: boolean | description: Whether the checkbox is checked by default. Default: `false` - name: tableManagement | type: TableManagement | description: Table management settings. - name: mode | type: TableManagementMode | description: Table management mode. The mode determines how tables are assigned for reservations at this location. - enum: - ON: Tables can be assigned manually for reservations at this location. When tables aren't manually assigned, Wix assigns them automatically. - IN_HOUSE_ONLY: Tables can be assigned manually for reservations at this location. Wix doesn't assign tables automatically. - OFF: Tables can't be assigned manually for reservations at this location. Wix doesn't assign tables automatically. If you try to assign a table manually, the request will fail. - name: tableDefinitions | type: array | description: Table definitions. - name: id | type: string | description: Table GUID. - name: name | type: string | description: Table name. - name: seatsMin | type: integer | description: Minimum number of seats. - name: seatsMax | type: integer | description: Maximum number of seats. - name: isActive | type: boolean | description: Whether the table is active (available to be reserved). - name: deletedTableDefinitions | type: array | description: Deleted table definitions. - name: tableCombinations | type: array | description: Table combinations. - name: id | type: string | description: Table combination GUID. - name: tableIds | type: array | description: IDs of tables in the combination. - name: seatsMin | type: integer | description: Minimum number of seats that can be reserved in this table combination. - name: seatsMax | type: integer | description: Maximum number of seats that can be reserved in this table combination. - name: isActive | type: boolean | description: Whether the table combination is active (available to be reserved). - name: paymentPolicy | type: PaymentPolicy | description: Reservation payment policy. This policy determines how the restaurant charges for reservations. - ONE-OF: - name: perGuestOptions | type: PerGuestOptions | description: Settings for charging per guest. - name: price | type: string | description: Monetary amount to charge. Must be a decimal string with a period as a decimal separator. For example, `"3.99"`. - name: minPartySize | type: integer | description: Minimum party size required to apply the payment policy. - name: perReservationOptions | type: PerReservationOptions | description: Settings for charging per reservation. - name: price | type: string | description: Monetary amount to charge. Must be a decimal string with a period as a decimal separator. For example, `"3.99"`. - name: minPartySize | type: integer | description: Minimum party size required to apply the payment policy. - name: paymentPolicyType | type: PaymentPolicyType | description: Type of payment policy. - enum: - UNKNOWN_PAYMENT_POLICY: Undefined table management mode. - PER_GUEST: A fee is charged for each guest in the reservation. - PER_RESERVATION: A fee is charged for the entire reservation. - name: default | type: boolean | description: Whether this reservation location's `location` is the default location of the business. - name: archived | type: boolean | description: Whether this reservation location's `location` is archived. - name: extendedFields | type: ExtendedFields | description: Custom field data for the reservation location object. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). ``` ### Examples ### Get a reservation location ```curl curl -X GET 'https://www.wixapis.com/table-reservations/reservation-locations/v1/reservation-locations/7b0221b9-a14a-48a3-a71c-f0d3b5d2b1ae' \ -H 'Authorization: ' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.reservations.ReservationLocationsService.getReservationLocation(reservationLocationId) Description: Retrieves a reservation location by GUID. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: reservationLocationId Method parameters: param name: reservationLocationId | type: string | description: GUID of the ReservationLocation to retrieve. | required: true Return type: PROMISE - name: _id | type: string | description: Reservation location GUID. - name: revision | type: string | description: Represents the current state of a reservation location. Each time the reservation location is modified, its `revision` changes. For an update operation to succeed, you must specify the latest revision. - name: _createdDate | type: Date | description: The date and time this reservation location was created. - name: _updatedDate | type: Date | description: The date and time this reservation location was last updated. - name: location | type: Location | description: Physical location details. Locations can be created and configured using the Locations API. or on the [Business Info](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Fsettings/business-info) page in the Dashboard. - name: _id | type: string | description: Location GUID. - name: configuration | type: Configuration | description: Reservation location configuration. - name: onlineReservations | type: OnlineReservations | description: Settings for this location that are used to determine restaurant availability for reservations made online. - name: approval | type: Approval | description: Approval settings. - ONE-OF: - name: manualForLargePartiesOptions | type: ManualForLargePartiesOptions | description: Manual approval for large parties options. - name: partySizeThreshold | type: integer | description: The minimum party size that requires manual approval. - name: considerTablesForManualApproval | type: boolean | description: Use tables for manual approval part. - name: mode | type: Mode | description: Approval mode. - enum: AUTOMATIC, MANUAL, MANUAL_FOR_LARGE_PARTIES - name: seatPacing | type: SeatPacing | description: Seat pacing settings. The maximum number of seats that can be filled by new reservations within a 15-minute period. For example, setting a seat pacing of 15 would mean that between `10:00.000`-`10:14.999` there will be no more than 15 new seats available for reservation. - name: number | type: integer | description: Maximum number of seats allowed per `timeSlotInterval`. - name: enabled | type: boolean | description: Whether this option is enabled. - name: partyPacing | type: PartyPacing | description: Party pacing settings. The maximum number of party reservations that can start within a `timeSlotInterval` period. For example, if `timeSlotInterval` is 15 minutes, then a party pacing of 5 would mean that no more than 5 parties could make a reservation for the period between `10:00.000`-`10:14.999`. - name: number | type: integer | description: Maximum number of new party reservations allowed per `timeSlotInterval`. - name: enabled | type: boolean | description: Whether this option is enabled. - name: partySize | type: PartySize | description: Party size limits for a reservation. - name: min | type: integer | description: Minimum number of seats a party can reserve. - name: max | type: integer | description: Maximum number of seats a party can reserve. - name: minimumReservationNotice | type: NoticePeriod | description: Minimum reservation notice. The minimum amount of time that must be allowed between making a reservation and that reservation's start time. - name: number | type: integer | description: The quantity of the chosen time unit. - name: unit | type: Unit | description: Time unit. - enum: UNKNOWN, MINUTES, HOURS, DAYS - name: maximumReservationNotice | type: NoticePeriod | description: Maximum reservation notice. The maximum amount of time that can be allowed between making a reservation and that reservation's start time. - name: defaultTurnoverTime | type: integer | description: Default turnover time in minutes. Turnover time is how much time a party is allotted for their entire reservation - from being seated to leaving the restaurant. - name: turnoverTimeRules | type: array | description: Custom turnover time rules. This allows you to set different turnover times for different party sizes. - name: seatsMin | type: integer | description: Minimum number of seats to qualify for this rule. - name: seatsMax | type: integer | description: Maximum number of seats to qualify for this rule. - name: minutes | type: integer | description: Turnover time in minutes for qualifying parties. - name: businessSchedule | type: BusinessSchedule | description: The location's business schedule. Limited to 100 time periods. - name: periods | type: array | description: - name: openDay | type: DayOfWeek | description: Day of the week this period starts on. - enum: MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY - name: openTime | type: string | description: Time this period starts in 24hr [ISO 8601](http://www.w3.org/TR/NOTE-datetime) extended format (hh:mm). Valid values are `00:00-24:00`, where `24:00` represents midnight at the end of the specified day field. - name: closeDay | type: DayOfWeek | description: Day of the week this period ends on. - name: closeTime | type: string | description: Time this period ends in 24hr [ISO 8601](http://www.w3.org/TR/NOTE-datetime) extended format (hh:mm). Valid values are `00:00-24:00`, where `24:00` represents midnight at the end of the specified day field. This is the last time a reservation can be made at the restaurant, not the time the restaurant closes its doors. - name: specialHourPeriod | type: array | description: Time periods during which this location is open. Each period represents a range of hours during the week during which the location is open. Max: 100 time periods - name: startDate | type: string | description: Start date and time in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#combined_date_and_time_representations) format. - name: endDate | type: string | description: End date and time in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601#combined_date_and_time_representations) format. - name: isClosed | type: boolean | description: Whether or not the location is closed during this period. - name: comment | type: string | description: Additional details about the period. - name: showPhoneNumber | type: boolean | description: Whether a phone number is shown. - name: onlineReservationsEnabled | type: boolean | description: Whether online reservations are enabled. - name: pauseSettings | type: PauseSettings | description: Pause settings for reservations. - name: standardReservations | type: StandardReservations | description: Pause settings for standard reservations. - name: pauseFrom | type: Date | description: Timestamp from which online reservations are paused. Read-only, set automatically when pause is configured. - name: pauseUntil | type: Date | description: Timestamp until which online reservations are paused. When set and the current time is before this timestamp, online reservations are blocked. When the current time passes this timestamp, reservations automatically resume. - name: timeSlotInterval | type: integer | description: Interval between a reservation location's time slots in minutes. This controls the interval between time slots on a Wix site's Reservations page, and the interval between time slots returned by the Time Slots API's Get Time Slots method. Default: `15` - name: reservationForm | type: ReservationForm | description: Reservation form settings. - name: submitMessage | type: string | description: A message shown to the customer in the registration form. - name: policiesEnabled | type: boolean | description: Whether to show policies (the terms and conditions, and the privacy policy) to the customer. - name: termsAndConditions | type: TermsAndConditions | description: Settings for displaying the terms and conditions. - ONE-OF: - name: url | type: string | description: Terms and conditions URL. - name: text | type: string | description: Terms and conditions text. - name: enabled | type: boolean | description: Whether the terms and conditions are shown to the customer. Default: `false` - name: privacyPolicy | type: PrivacyPolicy | description: Settings for displaying the privacy policy. - ONE-OF: - name: url | type: string | description: Privacy policy URL. - name: text | type: string | description: Privacy policy text. - name: enabled | type: boolean | description: Whether the privacy policy is shown to the customer. Default: `false` - name: customFieldDefinitions | type: array | description: Custom fields you wish to add to the registration form for the customer to fill in. - name: _id | type: string | description: Custom field GUID. - name: name | type: string | description: Custom field name. - name: required | type: boolean | description: Whether the custom field is required. Default: `false` - name: lastNameRequired | type: boolean | description: Whether a last_name is required in the reservation form. Default: `false` - name: emailRequired | type: boolean | description: Whether an email is required in the reservation form. Default: `false` - name: emailMarketingCheckbox | type: EmailMarketingCheckbox | description: Email marketing checkbox settings. - name: enabled | type: boolean | description: Whether the checkbox is shown to the customer. Default: `false` - name: checkedByDefault | type: boolean | description: Whether the checkbox is checked by default. Default: `false` - name: tableManagement | type: TableManagement | description: Table management settings. - name: mode | type: TableManagementMode | description: Table management mode. The mode determines how tables are assigned for reservations at this location. - enum: - ON: Tables can be assigned manually for reservations at this location. When tables aren't manually assigned, Wix assigns them automatically. - IN_HOUSE_ONLY: Tables can be assigned manually for reservations at this location. Wix doesn't assign tables automatically. - OFF: Tables can't be assigned manually for reservations at this location. Wix doesn't assign tables automatically. If you try to assign a table manually, the request will fail. - name: tableDefinitions | type: array | description: Table definitions. - name: _id | type: string | description: Table GUID. - name: name | type: string | description: Table name. - name: seatsMin | type: integer | description: Minimum number of seats. - name: seatsMax | type: integer | description: Maximum number of seats. - name: isActive | type: boolean | description: Whether the table is active (available to be reserved). - name: deletedTableDefinitions | type: array | description: Deleted table definitions. - name: tableCombinations | type: array | description: Table combinations. - name: _id | type: string | description: Table combination GUID. - name: tableIds | type: array | description: IDs of tables in the combination. - name: seatsMin | type: integer | description: Minimum number of seats that can be reserved in this table combination. - name: seatsMax | type: integer | description: Maximum number of seats that can be reserved in this table combination. - name: isActive | type: boolean | description: Whether the table combination is active (available to be reserved). - name: paymentPolicy | type: PaymentPolicy | description: Reservation payment policy. This policy determines how the restaurant charges for reservations. - ONE-OF: - name: perGuestOptions | type: PerGuestOptions | description: Settings for charging per guest. - name: price | type: string | description: Monetary amount to charge. Must be a decimal string with a period as a decimal separator. For example, `"3.99"`. - name: minPartySize | type: integer | description: Minimum party size required to apply the payment policy. - name: perReservationOptions | type: PerReservationOptions | description: Settings for charging per reservation. - name: price | type: string | description: Monetary amount to charge. Must be a decimal string with a period as a decimal separator. For example, `"3.99"`. - name: minPartySize | type: integer | description: Minimum party size required to apply the payment policy. - name: paymentPolicyType | type: PaymentPolicyType | description: Type of payment policy. - enum: - UNKNOWN_PAYMENT_POLICY: Undefined table management mode. - PER_GUEST: A fee is charged for each guest in the reservation. - PER_RESERVATION: A fee is charged for the entire reservation. - name: default | type: boolean | description: Whether this reservation location's `location` is the default location of the business. - name: archived | type: boolean | description: Whether this reservation location's `location` is archived. - name: extendedFields | type: ExtendedFields | description: Custom field data for the reservation location object. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls. - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured. You can only access fields for which you have the appropriate permissions. Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md). ``` ### Examples ### Close a restaurant and cancel all reservations on a given day (with $w) This scenario sets up an interface that allows a site owner to select a reservation location and a date, and then close the restaurant on that date. We start by creating a day-long special hour period during which reservations can't be made. We then cancel all reservations on that date. ```javascript /************************************************* * Backend code - reservationLocations.web.js/ts * ************************************************/ import { Permissions, webMethod } from "@wix/web-methods"; import { reservationLocations } from "@wix/table-reservations"; import { locations } from "@wix/business-tools"; import { auth } from "@wix/essentials"; export const getRestaurantLocation = webMethod( Permissions.Anyone, async (location_id) => { const elevatedGetLocation = auth.elevate(locations.getLocation); try { const result = await elevatedGetLocation(location_id); return result; } catch (error) { console.error(error); // Handle the error } }, ); export const getRestautantDetails = webMethod( Permissions.Anyone, async (reservationLocationId, options) => { const elevatedGetReservationLocations = auth.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 = auth.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/ts * ****************************************/ import { Permissions, webMethod } from "@wix/web-methods"; import { reservations } from "@wix/table-reservations"; import { auth } from "@wix/essentials"; export const queryReservationsInDateRange = webMethod( Permissions.Anyone, async (startDate, endDate) => { const elevatedQueryReservations = auth.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 * *************/ /* This example requires the page elements: * A dropdown element named `locationDropdown`. * A date picker element named 'datePicker`. * A button named `confirmButton`. * A text element named `cancellationNotice`. */ import { reservationLocations } from "@wix/table-reservations"; import { reservations } from "@wix/table-reservations"; import { getRestaurantLocation } from "backend/reservationLocations.web"; import { getRestautantDetails } from "backend/reservationLocations.web"; import { updateRestaurantDetails } from "backend/reservationLocations.web"; import { queryReservationsInDateRange } from "backend/reservations.web"; $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 getRestautantDetails( $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.toISOString(), 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: "; //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 + " "; } } } $w("#cancellationNotice").text = canceledReservationsNote; $w("#cancellationNotice").show(); }); }); ``` ### Get a reservation location with options This example demonstrates how to request the `FULL` fieldset in `options` using elevation to get the necessary permissions. ```javascript import { reservationLocations } from '@wix/table-reservations'; /* Sample reservationLocationId value: 'fab8cc1f-31cf-462f-b5bb-392594624bf2' * * Sample options value: * { * "fieldsets": ["FULL"] * } */ export async function myGetReservationLocationFunction(reservationLocationId, options) { try { const result = await reservationLocations.getReservationLocation(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" * } */ ``` ### Get a reservation location ```javascript import { reservationLocations } from '@wix/table-reservations'; // 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" * } */ ``` ### getReservationLocation (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { reservationLocations } from '@wix/table-reservations'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { reservationLocations }, // Include the auth strategy and host as relevant }); async function getReservationLocation(reservationLocationId) { const response = await myWixClient.reservationLocations.getReservationLocation(reservationLocationId); }; ``` ---