Search.../

listReservationLocations( )

Developer Preview

Retrieves a list of up to 100 reservation locations.

Description

The FULL fieldset can only be retrieved by users with the READ RESERVATION LOCATIONS (FULL) or MANAGE RESERVATION LOCATIONS permission scopes.

Syntax

function listReservationLocations(options: ListReservationLocationsOptions): Promise<ListReservationLocationsResponse>

listReservationLocations Parameters

NAME
TYPE
DESCRIPTION
options
Optional
ListReservationLocationsOptions

An object representing the available options for listing reservation locations.

Returns

Return Type:

Promise<
ListReservationLocationsResponse
>
NAME
TYPE
DESCRIPTION
pagingMetadata
CursorPagingMetadata

Metadata for the paginated results.

reservationLocations
Array<
ReservationLocation
>

Locations list.

Was this helpful?

List reservation locations (page code)

Copy Code
1import { reservationLocations } from 'wix-table-reservations-v2';
2
3reservationLocations.listReservationLocations()
4 .then((retrievedReservationLocations) => {
5 const isDefault = retrievedReservationLocations.reservationLocations[0].default;
6 const minNotice = retrievedReservationLocations.reservationLocations[0].configuration.onlineReservations.minimumReservationNotice;
7
8 console.log('Success! Retrieved reservation location list:', retrievedReservationLocations);
9 return retrievedReservationLocations;
10 })
11 .catch((error) => {
12 console.error(error);
13 // Handle the error
14 });
15
16/* Promise resolves to:
17 * {
18 * "reservationLocations": [
19 * {
20 * "location": {
21 * "name": "Yunitsman Street",
22 * "fax": "",
23 * "timeZone": "Europe/Dublin",
24 * "email": "",
25 * "phone": "",
26 * "address": {
27 * "formatted": "Yunitsman Street 5, Tel Aviv-Yafo, Israel",
28 * "location": {
29 * "latitude": 32.141816,
30 * "longitude": 34.7987383
31 * },
32 * "streetAddress": {
33 * "name": "Yunitsman Street",
34 * "number": "5",
35 * "apt": ""
36 * },
37 * "city": "Tel Aviv-Yafo",
38 * "subdivision": "",
39 * "country": "IL",
40 * "postalCode": ""
41 * },
42 * "businessSchedule": {
43 * "periods": [
44 * {
45 * "openDay": "SUNDAY",
46 * "openTime": "08:00",
47 * "closeDay": "MONDAY",
48 * "closeTime": "20:00"
49 * },
50 * {
51 * "openDay": "THURSDAY",
52 * "openTime": "08:00",
53 * "closeDay": "SUNDAY",
54 * "closeTime": "01:00"
55 * }
56 * ],
57 * "specialHourPeriod": []
58 * },
59 * "_id": "9bd42376-12c2-483e-86c3-8ee685e718e1"
60 * },
61 * "configuration": {
62 * "onlineReservations": {
63 * "partiesSize": {
64 * "min": 1,
65 * "max": 6
66 * },
67 * "minimumReservationNotice": {
68 * "number": 30,
69 * "unit": "MINUTES"
70 * },
71 * "turnoverTimeRules": [],
72 * "turnoverRules": [],
73 * "onlineReservationsEnabled": true
74 * },
75 * "myReservationsFields": []
76 * },
77 * "default": false,
78 * "archived": false,
79 * "_id": "800c581a-1942-4079-8198-2eee44463eb7"
80 * },
81 * {
82 * "location": {
83 * "name": "Nemal Tel Aviv Street",
84 * "fax": "",
85 * "timeZone": "Europe/Dublin",
86 * "email": "",
87 * "phone": "",
88 * "address": {
89 * "formatted": "Tel Aviv Port, Nemal Tel Aviv Street, Tel Aviv, Israel",
90 * "location": {
91 * "latitude": 32.0972612,
92 * "longitude": 34.77376549999999
93 * },
94 * "streetAddress": {
95 * "name": "Nemal Tel Aviv Street",
96 * "number": "",
97 * "apt": ""
98 * },
99 * "city": "Tel Aviv-Yafo",
100 * "country": "IL"
101 * },
102 * "businessSchedule": {
103 * "periods": [
104 * {
105 * "openDay": "SUNDAY",
106 * "openTime": "00:00",
107 * "closeDay": "MONDAY",
108 * "closeTime": "00:00"
109 * },
110 * {
111 * "openDay": "THURSDAY",
112 * "openTime": "00:00",
113 * "closeDay": "SUNDAY",
114 * "closeTime": "00:00"
115 * }
116 * ],
117 * "specialHourPeriod": []
118 * },
119 * "_id": "f1f59093-6842-45a4-b9d1-106429ec8313"
120 * },
121 * "configuration": {
122 * "onlineReservations": {
123 * "partiesSize": {
124 * "min": 1,
125 * "max": 6
126 * },
127 * "minimumReservationNotice": {
128 * "number": 30,
129 * "unit": "MINUTES"
130 * },
131 * "turnoverTimeRules": [],
132 * "turnoverRules": [],
133 * "businessSchedule": {
134 * "periods": [
135 * {
136 * "openDay": "SUNDAY",
137 * "openTime": "00:00",
138 * "closeDay": "TUESDAY",
139 * "closeTime": "00:00"
140 * },
141 * {
142 * "openDay": "WEDNESDAY",
143 * "openTime": "00:00",
144 * "closeDay": "THURSDAY",
145 * "closeTime": "00:00"
146 * },
147 * {
148 * "openDay": "FRIDAY",
149 * "openTime": "00:00",
150 * "closeDay": "SUNDAY",
151 * "closeTime": "00:00"
152 * }
153 * ],
154 * "specialHourPeriod": []
155 * },
156 * "onlineReservationsEnabled": true
157 * },
158 * "reservationForm": {
159 * "customFieldDefinitions": [
160 * {
161 * "name": "Allergies",
162 * "required": false,
163 * "_id": "f4283b2d-6340-4cf9-bae7-8769e6b62127"
164 * }
165 * ]
166 * },
167 * "myReservationsFields": []
168 * },
169 * "default": true,
170 * "archived": false,
171 * "_id": "fab8cc1f-31cf-462f-b5bb-392594624bf2"
172 * }
173 * ],
174 * "pagingMetadata": {
175 * "count": 2,
176 * "cursors": {},
177 * "hasNext": false
178 * }
179 * }
180 */
181
List reservation locations with options (backend)

This example demonstrates how to request the FULL fieldset in options using elevation to get the necessary permissions.

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { reservationLocations } from 'wix-table-reservations.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample options value:
6 * {
7 * "fieldsets": ["FULL"],
8 * "sort": {
9 * "fieldName": "_id",
10 * "order": "ASC"
11 * }
12 * }
13 */
14
15export const myListReservationLocationsFunction = webMethod(Permissions.Anyone, async (options) => {
16 const elevatedListReservationLocations = elevate(reservationLocations.listReservationLocations);
17
18 try {
19 const result = await elevatedListReservationLocations(options);
20 return result;
21 } catch (error) {
22 console.error(error);
23 // Handle the error
24 }
25});
26
27/* Promise resolves to:
28 * {
29 * "reservationLocations": [
30 * {
31 * "revision": "2",
32 * "location": {
33 * "name": "Yunitsman Street",
34 * "fax": "",
35 * "timeZone": "Europe/Dublin",
36 * "email": "",
37 * "phone": "",
38 * "address": {
39 * "formatted": "Yunitsman Street 5, Tel Aviv-Yafo, Israel",
40 * "location": {
41 * "latitude": 32.141816,
42 * "longitude": 34.7987383
43 * },
44 * "streetAddress": {
45 * "name": "Yunitsman Street",
46 * "number": "5",
47 * "apt": ""
48 * },
49 * "city": "Tel Aviv-Yafo",
50 * "subdivision": "",
51 * "country": "IL",
52 * "postalCode": ""
53 * },
54 * "businessSchedule": {
55 * "periods": [
56 * {
57 * "openDay": "SUNDAY",
58 * "openTime": "00:00",
59 * "closeDay": "MONDAY",
60 * "closeTime": "00:00"
61 * },
62 * {
63 * "openDay": "THURSDAY",
64 * "openTime": "00:00",
65 * "closeDay": "SUNDAY",
66 * "closeTime": "00:00"
67 * }
68 * ],
69 * "specialHourPeriod": []
70 * },
71 * "_id": "9bd42376-12c2-483e-86c3-8ee685e718e1"
72 * },
73 * "configuration": {
74 * "onlineReservations": {
75 * "partiesSize": {
76 * "min": 1,
77 * "max": 6
78 * },
79 * "partySize": {
80 * "min": 1,
81 * "max": 6
82 * },
83 * "minimumReservationNotice": {
84 * "number": 30,
85 * "unit": "MINUTES"
86 * },
87 * "defaultTurnoverTime": 90,
88 * "turnoverTimeRules": [],
89 * "turnoverRules": [],
90 * "onlineReservationsEnabled": true
91 * },
92 * "reservationForm": {
93 * "customFieldDefinitions": []
94 * },
95 * "myReservationsFields": [
96 * {
97 * "fieldType": "TABLE",
98 * "shown": true
99 * },
100 * {
101 * "fieldType": "START_DATE",
102 * "shown": true
103 * },
104 * {
105 * "fieldType": "END_DATE",
106 * "shown": true
107 * },
108 * {
109 * "fieldType": "CREATED_DATE",
110 * "shown": true
111 * },
112 * {
113 * "fieldType": "UPDATED_DATE",
114 * "shown": true
115 * },
116 * {
117 * "fieldType": "PARTY_SIZE",
118 * "shown": true
119 * },
120 * {
121 * "fieldType": "FIRST_NAME",
122 * "shown": true
123 * },
124 * {
125 * "fieldType": "LAST_NAME",
126 * "shown": true
127 * },
128 * {
129 * "fieldType": "EMAIL",
130 * "shown": true
131 * },
132 * {
133 * "fieldType": "PHONE",
134 * "shown": true
135 * },
136 * {
137 * "fieldType": "ADDITIONAL_INFO",
138 * "shown": true
139 * },
140 * {
141 * "fieldType": "TEAM_MESSAGE",
142 * "shown": true
143 * },
144 * {
145 * "fieldType": "STATUS",
146 * "shown": true
147 * }
148 * ],
149 * "tableManagement": {
150 * "tableDefinitions": [
151 * {
152 * "name": "Small table",
153 * "seatsMin": 1,
154 * "seatsMax": 4,
155 * "isActive": true,
156 * "_id": "ec4adfb0-568f-4846-8f92-86059ef94ec8"
157 * },
158 * {
159 * "name": "Big table",
160 * "seatsMin": 3,
161 * "seatsMax": 6,
162 * "isActive": true,
163 * "_id": "63b73378-5e79-401c-9a69-3e4da76558d3"
164 * }
165 * ],
166 * "deletedTableDefinitions": [],
167 * "tableCombinations": []
168 * }
169 * },
170 * "default": false,
171 * "archived": false,
172 * "_id": "800c581a-1942-4079-8198-2eee44463eb7",
173 * "_createdDate": "2023-10-08T07:07:39.123Z",
174 * "_updatedDate": "2024-01-09T12:42:12.667Z"
175 * },
176 * {
177 * "revision": "10",
178 * "location": {
179 * "name": "Nemal Tel Aviv Street",
180 * "fax": "",
181 * "timeZone": "Europe/Dublin",
182 * "email": "",
183 * "phone": "",
184 * "address": {
185 * "formatted": "Tel Aviv Port, Nemal Tel Aviv Street, Tel Aviv, Israel",
186 * "location": {
187 * "latitude": 32.0972612,
188 * "longitude": 34.77376549999999
189 * },
190 * "streetAddress": {
191 * "name": "Nemal Tel Aviv Street",
192 * "number": "",
193 * "apt": ""
194 * },
195 * "city": "Tel Aviv-Yafo",
196 * "country": "IL"
197 * },
198 * "businessSchedule": {
199 * "periods": [
200 * {
201 * "openDay": "SUNDAY",
202 * "openTime": "00:00",
203 * "closeDay": "MONDAY",
204 * "closeTime": "00:00"
205 * },
206 * {
207 * "openDay": "THURSDAY",
208 * "openTime": "00:00",
209 * "closeDay": "SUNDAY",
210 * "closeTime": "00:00"
211 * }
212 * ],
213 * "specialHourPeriod": []
214 * },
215 * "_id": "f1f59093-6842-45a4-b9d1-106429ec8313"
216 * },
217 * "configuration": {
218 * "onlineReservations": {
219 * "seatPacing": {
220 * "number": 11,
221 * "enabled": false
222 * },
223 * "partyPacing": {
224 * "number": 6,
225 * "enabled": true
226 * },
227 * "partiesSize": {
228 * "min": 1,
229 * "max": 6
230 * },
231 * "partySize": {
232 * "min": 1,
233 * "max": 6
234 * },
235 * "minimumReservationNotice": {
236 * "number": 30,
237 * "unit": "MINUTES"
238 * },
239 * "defaultTurnoverTime": 90,
240 * "turnoverTimeRules": [],
241 * "turnoverRules": [],
242 * "businessSchedule": {
243 * "periods": [
244 * {
245 * "openDay": "SUNDAY",
246 * "openTime": "00:00",
247 * "closeDay": "TUESDAY",
248 * "closeTime": "00:00"
249 * },
250 * {
251 * "openDay": "WEDNESDAY",
252 * "openTime": "00:00",
253 * "closeDay": "THURSDAY",
254 * "closeTime": "00:00"
255 * },
256 * {
257 * "openDay": "FRIDAY",
258 * "openTime": "00:00",
259 * "closeDay": "SUNDAY",
260 * "closeTime": "00:00"
261 * }
262 * ],
263 * "specialHourPeriod": []
264 * },
265 * "onlineReservationsEnabled": true
266 * },
267 * "reservationForm": {
268 * "customFieldDefinitions": [
269 * {
270 * "name": "Allergies",
271 * "required": false,
272 * "_id": "f4283b2d-6340-4cf9-bae7-8769e6b62127"
273 * }
274 * ]
275 * },
276 * "myReservationsFields": [
277 * {
278 * "fieldType": "TABLE",
279 * "shown": true
280 * },
281 * {
282 * "fieldType": "START_DATE",
283 * "shown": true
284 * },
285 * {
286 * "fieldType": "END_DATE",
287 * "shown": true
288 * },
289 * {
290 * "fieldType": "CREATED_DATE",
291 * "shown": true
292 * },
293 * {
294 * "fieldType": "UPDATED_DATE",
295 * "shown": true
296 * },
297 * {
298 * "fieldType": "PARTY_SIZE",
299 * "shown": true
300 * },
301 * {
302 * "fieldType": "FIRST_NAME",
303 * "shown": true
304 * },
305 * {
306 * "fieldType": "LAST_NAME",
307 * "shown": true
308 * },
309 * {
310 * "fieldType": "EMAIL",
311 * "shown": true
312 * },
313 * {
314 * "fieldType": "PHONE",
315 * "shown": true
316 * },
317 * {
318 * "fieldType": "ADDITIONAL_INFO",
319 * "shown": true
320 * },
321 * {
322 * "fieldType": "TEAM_MESSAGE",
323 * "shown": true
324 * },
325 * {
326 * "fieldType": "STATUS",
327 * "shown": true
328 * },
329 * {
330 * "fieldType": "CUSTOM_FIELD",
331 * "customFieldId": "f4283b2d-6340-4cf9-bae7-8769e6b62127",
332 * "shown": false
333 * }
334 * ],
335 * "tableManagement": {
336 * "tableDefinitions": [
337 * {
338 * "name": "Small table",
339 * "seatsMin": 1,
340 * "seatsMax": 4,
341 * "isActive": true,
342 * "_id": "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
343 * },
344 * {
345 * "name": "Big table",
346 * "seatsMin": 3,
347 * "seatsMax": 6,
348 * "isActive": true,
349 * "_id": "2c8aed3a-20c5-404c-b075-84a92f90a996"
350 * }
351 * ],
352 * "deletedTableDefinitions": [],
353 * "tableCombinations": [
354 * {
355 * "tableIds": [
356 * "1ed802ae-708f-4da6-9177-54c3df5d3dd5",
357 * "2c8aed3a-20c5-404c-b075-84a92f90a996"
358 * ],
359 * "seatsMin": 7,
360 * "seatsMax": 10,
361 * "isActive": true,
362 * "_id": "6df9a875-d30d-4c0f-9faa-0a5ae18cd6f6"
363 * }
364 * ]
365 * }
366 * },
367 * "default": true,
368 * "archived": false,
369 * "_id": "fab8cc1f-31cf-462f-b5bb-392594624bf2",
370 * "_createdDate": "2023-07-10T09:06:07.507Z",
371 * "_updatedDate": "2024-01-09T12:42:12.840Z"
372 * }
373 * ],
374 * "pagingMetadata": {
375 * "count": 2,
376 * "cursors": {},
377 * "hasNext": false
378 * }
379 * }
380 */
381
Update the minimum required notice for reservations at all locations

This scenario sets up an interface that allows a site owner to update minimumReservationNotice in all their reservation locations at once.

Copy Code
1/* This example requires the following elements:
2 * A slider element named `noticeSlider`.
3 * A button named `setMinNoticeButton` with an onClick() event handler named `setMinNoticeButton_click`.
4 */
5
6/**********************************************
7 * Backend code - reservationLocations.web.js *
8 **********************************************/
9
10import { Permissions, webMethod } from 'wix-web-module';
11import { reservationLocations } from 'wix-table-reservations.v2';
12import { elevate } from 'wix-auth';
13
14export const updateRestaurantDetails = webMethod(Permissions.Anyone, async (reservationLocationId, reservationLocationObject) => {
15 const elevatedUpdateReservationLocation = elevate(reservationLocations.updateReservationLocation);
16
17 try {
18 const result = await elevatedUpdateReservationLocation(reservationLocationId, reservationLocationObject);
19 return result;
20 } catch (error) {
21 console.error(error);
22 // Handle the error
23 }
24});
25
26export const listRestaurantLocations = webMethod(Permissions.Anyone, async (options) => {
27 const elevatedListReservationLocations = elevate(reservationLocations.listReservationLocations);
28
29 try {
30 const result = await elevatedListReservationLocations(options);
31 return result;
32 } catch (error) {
33 console.error(error);
34 // Handle the error
35 }
36});
37
38/*************
39 * Page code *
40 *************/
41
42import { listRestaurantLocations, updateRestaurantDetails } from 'backend/reservationLocations.web.js';
43
44export async function setMinNoticeButton_click(event) {
45 const options = {
46 "fieldsets": ["FULL"],
47 };
48
49 const locationList = await listRestaurantLocations(options);
50
51 //Loop through each reservationLocation and update `minimumReservationNotice`
52 for (const item in locationList.reservationLocations) {
53 const selectedLocation = locationList.reservationLocations[item];
54
55 selectedLocation.configuration.onlineReservations.minimumReservationNotice = {
56 "number": $w("#noticeSlider").value,
57 "unit": "MINUTES"
58 };
59
60 await updateRestaurantDetails(selectedLocation._id, selectedLocation);
61 }
62}
63
Create a held reservation with a given time, location, and party size.

This scenario sets up an interface that allows a site owner to select a reservation location and a party size, then select a time slot to reserve. Once a time slot is selected, the site owner can click a confirm button to create a held reservation at that time.

Copy Code
1/* This example requires the following elements:
2 * A dropdown element named `locationDropdown`.
3 * A dropdown element named `partySizeDropdown`.
4 * A dropdown element named `timeSlotDropdown`.
5 * A button named `confirmButton`.
6 * A text element named `heldReservationNotification`.
7 */
8
9
10/**********************************************
11 * Backend code - reservationLocations.web.js *
12 **********************************************/
13
14import { Permissions, webMethod } from 'wix-web-module';
15import { locations } from 'wix-business-tools.v2';
16import { elevate } from 'wix-auth';
17
18export const getRestaurantLocation = webMethod(Permissions.Anyone, async (location_id) => {
19 const elevatedGetLocation = elevate(locations.getLocation);
20
21 try {
22 const result = await elevatedGetLocation(location_id);
23 return result;
24 } catch (error) {
25 console.error(error);
26 // Handle the error
27 }
28});
29
30/*************
31 * Page code *
32 *************/
33
34import { reservationLocations } from 'wix-table-reservations.v2';
35import { reservations } from 'wix-table-reservations.v2';
36import { timeSlots } from 'wix-table-reservations.v2';
37
38import { getRestaurantLocation } from 'backend/reservationLocations.web.js';
39
40$w.onReady(async function () {
41 $w('#timeSlotDropdown').hide();
42 $w('#partySizeDropdown').hide();
43 $w('#confirmButton').hide();
44 $w('#heldReservationNotification').hide();
45
46 //Get the list of reservation locations
47 const myReservationLocationList = await (async () => {
48 try {
49 let fullListObject = await reservationLocations.listReservationLocations();
50 return fullListObject.reservationLocations;
51 } catch (error) {
52 console.error(error);
53 // Handle the error
54 }
55 })();
56
57 //Create an array to hold names and values for our locations dropdown list
58 let locationDropdownOptions = [];
59 for (const object in myReservationLocationList){
60 //Use the _id stored in the reservation location's location object to get the location's name from the `locations` service
61 const locationObject = await getRestaurantLocation(myReservationLocationList[object].location._id);
62 locationDropdownOptions.push({
63 "label": locationObject.name,
64 "value": myReservationLocationList[object]._id
65 })
66 }
67 //Populate our dropdown list with the array
68 $w("#locationDropdown").options = locationDropdownOptions;
69
70 //Create an array to hold numbers and values for our party size dropdown list
71 let partySizeDropdownOptions = [];
72 for (let i = 1; i<10; i++){
73 partySizeDropdownOptions.push({
74 "label": String(i),
75 "value": String(i)
76 })
77 }
78 //Populate our dropdown list with the array
79 $w("#partySizeDropdown").options = partySizeDropdownOptions;
80
81 $w('#locationDropdown').onChange( (event) => {
82 if ($w('#locationDropdown').value) {
83 $w('#partySizeDropdown').show();
84 $w('#timeSlotDropdown').hide()
85 $w('#confirmButton').hide();
86 }
87 });
88
89 $w('#partySizeDropdown').onChange( async (event) => {
90 if ($w('#locationDropdown').value) {
91 $w('#timeSlotDropdown').show()
92 $w('#confirmButton').hide();
93
94 const timeSlotDetails = {
95 "reservationLocationId": $w('#locationDropdown').value,
96 "date": new Date(),
97 "partySize": parseInt($w('#partySizeDropdown').value)
98 };
99
100 const timeSlotOptions = {
101 "duration": 30,
102 "slotsAfter": 8,
103 "slotsBefore": 0
104 };
105
106 //Get the list of time slots according to the details and options above
107 const availableTimeSlots = await (async () => {
108 try {
109 let fullListObject = await timeSlots.getTimeSlots(timeSlotDetails.reservationLocationId, timeSlotDetails.date, timeSlotDetails.partySize, timeSlotOptions);
110 return fullListObject.timeSlots;
111 } catch (error) {
112 console.error(error);
113 // Handle the error
114 }
115 })();
116
117 //Create an array to hold numbers and values for our time slot dropdown list
118 let timeSlotDropdownOptions = [];
119 for (const timeSlot in availableTimeSlots){
120 if(availableTimeSlots[timeSlot].status == "AVAILABLE"){
121 timeSlotDropdownOptions.push({
122 "label": String(availableTimeSlots[timeSlot].startDate),
123 "value": String(availableTimeSlots[timeSlot].startDate)
124 })
125 }
126 }
127 //Populate our dropdown list with the array
128 $w("#timeSlotDropdown").options = timeSlotDropdownOptions;
129 }
130 });
131
132 $w('#timeSlotDropdown').onChange( async (event) => {
133 if ($w('#timeSlotDropdown').value) {
134 $w('#confirmButton').show();
135 }
136 });
137
138 $w('#confirmButton').onClick( async (event) => {
139 //Get the list of time slots according to the details and options above
140
141 const createdHeldReservation = await (async () => {
142 try {
143 const reservationDetails = {
144 "reservationLocationId": $w('#locationDropdown').value,
145 "startDate": new Date($w("#timeSlotDropdown").value),
146 "partySize": parseInt($w('#partySizeDropdown').value)
147 };
148
149 return await reservations.createHeldReservation(reservationDetails);
150 } catch (error) {
151 console.error(error);
152 // Handle the error
153 }
154 })();
155
156 if(createdHeldReservation){
157 $w('#heldReservationNotification').text = "Held reservation created successfully."
158 $w('#heldReservationNotification').show();
159 }
160 });
161});
162