This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Updates a reservation.
Including the fields status
, source
, reservation.details.tableIds
, reservation.details.endDate
, ignoreReservationLocationConflicts
, and ignoreTableCombinationConflicts
in the request requires additional permissions. See this API's Introduction article for more information.
Each time the reservation is updated, revision increments by 1. The existing revision must be included when updating the reservation. This ensures you're working with the latest reservation information, and it prevents unintended overwrites.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function updateReservation(
_id: string,
reservation: UpdateReservation,
options: UpdateReservationOptions,
): Promise<Reservation>;
Reservation ID.
Reservation information to update.
Options for updating the reservation.
import { Permissions, webMethod } from "wix-web-module";
import { reservations } from "wix-table-reservations.v2";
import { elevate } from "wix-auth";
/* Sample reservationId value: "1e3db995-5614-4748-8903-cbe7c74c5753"
*
* Sample reservationObject value:
* {
* "details": {
* "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",
* "startDate": new Date("2024-12-18T15:30:00Z"),
* "endDate": new Date("2024-12-18T16:30:00Z"),
* "partySize": 3
* },
* "reservee":{
* "phone":"+972555555555",
* "firstName":"John"
* },
* "revision": "23"
* }
*
* Sample options value:
* {
* "ignoreTableCombinationConflicts":["RESERVED", "TOO_BIG"],
* "ignoreReservationLocationConflicts":["PARTY_PACING"]
* }
*/
export const myUpdateReservationFunction = webMethod(
Permissions.Anyone,
async (reservationId, reservation, options) => {
const elevatedUpdateReservation = elevate(reservations.updateReservation);
try {
const result = await elevatedUpdateReservation(
reservationId,
reservation,
options,
);
return result;
} catch (error) {
console.error(error);
// Handle the error
}
},
);
/* Promise resolves to:
* {
* "status": "RESERVED",
* "source": "ONLINE",
* "details": {
* "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",
* "tableIds": [
* "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
* ],
* "startDate": "2024-12-18T15:30:00.000Z",
* "endDate": "2024-12-18T16:30:00.000Z",
* "partySize": 3
* },
* "reservee": {
* "firstName": "John",
* "email": "pedro.doe@mail.com",
* "phone": "+972555555555"
* },
* "revision": "24",
* "migrationNotes": [],
* "tablesWithReservationConflicts": [
* {
* "tableId": "1ed802ae-708f-4da6-9177-54c3df5d3dd5",
* "reservationIds": [
* "1c98f3af-f5e1-47b8-b935-1426345652d8"
* ]
* }
* ],
* "_id": "1e3db995-5614-4748-8903-cbe7c74c5753",
* "_createdDate": "2024-01-22T07:25:51.008Z",
* "_updatedDate": "2024-02-07T08:46:57.544Z"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.