Orders and Bookings
List a signed-in customer's orders and bookings, cancel or reschedule bookings, and fetch receipts and booking tickets
List a signed-in customer's orders and bookings, let them cancel or move their bookings, and fetch receipts and booking tickets. First, complete the setup and sign the customer in.
Listing orders
const { orders, hasMore, nextCursor } = await tiquo.getOrders({ limit: 20 });
for (const order of orders) {
console.log(order.orderNumber, order.status, order.paymentStatus);
}status filters by the order lifecycle status (draft, processing, completed, cancelled, refunded, or open_tab), not payment status. See List Orders for every field.
Listing bookings
// Booking history
const { bookings } = await tiquo.getBookings();
// Past bookings only
const past = await tiquo.getBookings({ range: 'past' });
// Upcoming bookings only, soonest first
const upcoming = await tiquo.getUpcomingBookings();getBookings() accepts range: 'upcoming' | 'past'; getUpcomingBookings() is the convenience method for upcoming results sorted soonest first.
Each booking also has serviceImage (the service's featured image, first image, or category image), location (the venue and sublocation, with its address, coordinates, and timezone), and customerActions, which says whether the customer can cancel or move it. See List Bookings for every field.
Pagination
getOrders() and getBookings() accept limit, cursor, and status options and return hasMore plus an optional nextCursor. The maximum page size is 100 and the default is 50. Pass nextCursor as cursor to load the next page.
let page = await tiquo.getOrders({ limit: 50 });
const allOrders = [...page.orders];
while (page.hasMore && page.nextCursor) {
page = await tiquo.getOrders({ limit: 50, cursor: page.nextCursor });
allOrders.push(...page.orders);
}Cancelling and rescheduling bookings
Signed-in customers can cancel or move their own bookings with the same rules as the customer portal: the service's cancellation deadline (24 hours before the start unless the service sets another), availability, and advance-booking limits. These methods need DOM Package 1.11.0 or newer.
const { bookings } = await tiquo.getUpcomingBookings();
const booking = bookings[0];
// Cancel, or withdraw a waiting-list request
if (booking.customerActions.canCancel) {
await tiquo.cancelBooking(booking.id);
}
// Move to another time
if (booking.customerActions.canReschedule) {
const { options } = await tiquo.getBookingRescheduleOptions(booking.id);
const next = options[0];
if (next) {
const moved = await tiquo.rescheduleBooking(booking.id, {
date: next.date,
startTime: next.startTime,
});
console.log(moved.date, moved.startTime, moved.endTime);
}
}| Method | Resolves |
|---|---|
cancelBooking(bookingId) | { bookingId, status: 'cancelled' } |
getBookingRescheduleOptions(bookingId, { dateFrom?, dateTo? }) | { canReschedule, reason?, bookingMethod?, firstDate?, lastDate?, options }, where each option has date, startTime, and endTime |
rescheduleBooking(bookingId, { date, startTime }) | { bookingId, status, date, startTime, endTime } |
Slot bookings list every bookable slot. Calendar bookings list the next 31 days by default and at most 42 days per call, so page through later dates with dateFrom and dateTo (YYYY-MM-DD). Dates and times are in the venue's timezone.
Use booking.customerActions to decide which buttons to show. Imported bookings, such as hotel stays from Mews, can only be changed by the venue: their canCancel and canReschedule are false and cancellationBlockedReason is managed_by_venue, so show a message such as "Contact the venue to change this booking" instead. See Cancel and Reschedule Bookings for every reason value.
Tiquo emails the customer after each change. When a change isn't allowed, the method throws a TiquoAuthError with a readable message you can show, such as "The cancellation deadline for this booking has passed." or "That time has just sold out. Please choose another." The error codes are CANCEL_BOOKING_FAILED, GET_RESCHEDULE_OPTIONS_FAILED, and RESCHEDULE_BOOKING_FAILED.
Receipts
Use getReceipt() to retrieve a printable receipt payload for an order owned by the authenticated customer.
const receipt = await tiquo.getReceipt('order_123');Receipts are available for orders that have been paid, refunded, or completed. Draft and pending orders do not have customer receipts yet. See Receipt for the payload.
Booking tickets
Bookings include a ticketing object when ticket settings are available for the booking's sublocation.
const { bookings } = await tiquo.getUpcomingBookings();
const booking = bookings[0];
if (booking?.ticketing.qrCodeTicketsEnabled) {
const ticketPdf = await tiquo.downloadBookingTicket(booking.id);
}When wallet tickets are enabled, the booking also includes wallet links:
const walletUrl = booking.ticketing.walletTicketUrl;
const appleWalletUrl = booking.ticketing.appleWalletTicketUrl;
const googleWalletUrl = booking.ticketing.googleWalletTicketUrl;These are tickets for one booking. For a customer's membership or loyalty card, use Wallet Cards instead.
Guest flows and invitations
To let a signed-in customer register guests for a visit, see Custom Guest Invitations. To show how many Guest Passes or Access Passes they have left, see Pass Balances.