Skip to content

JavaScript

window.pmsBooking is the script’s interface for your own code, and its events tell your code what happened.

When it is ready

window.pmsBooking exists as soon as our script has run. A script of yours that may run first waits for pms-booking-ready.

function whenBookingReady(run) {
if (window.pmsBooking) run(window.pmsBooking);
else
window.addEventListener('pms-booking-ready', () => run(window.pmsBooking), {
once: true,
});
}

The examples below write pmsBooking for window.pmsBooking.

Methods

A wrong argument is ignored or replaced by its default. rooms(), calendar() and currencies() reject when the request fails.

MethodReturnsWhat it does
setTheme()voidSwitches every component to light or dark.
setLocale()voidSwitches every component to English or Bulgarian.
rooms()Promise<Room[]>The property's room types with live prices for one stay.
bookUrl()stringThe address of your booking page for a stay, a party and a room.
calendar()Promise<Calendar>The lowest price and whether the night sells, date by date.
refresh()voidBinds markup added after the page loaded and reads your CSS variables again.
currencies()Promise<{ codes: string[], current: string | null }>The currencies the property shows prices in.
setCurrency()voidShows prices in another currency.
openDates()voidOpens the calendar of a search form.
openGuests()voidOpens the guests panel of a search form.
closePicker()voidCloses the open calendar or guests panel.
getSearch()Search | nullWhat a search form holds now.
setSearch()voidSets the dates or the party of a search form.

setTheme

Switches every component to light or dark. Every component repaints at once. Not remembered: your site remembers its own choice. It does not fire pms-booking-theme.

Signature
setTheme(theme: 'light' | 'dark')
Returns
void
Example
pmsBooking.setTheme('dark');

setLocale

Switches every component to English or Bulgarian. No reload: every component repaints, and the values and repeats in your own HTML are filled again in that language. Not remembered.

Signature
setLocale(locale: 'en' | 'bg')
Returns
void
Example
pmsBooking.setLocale('bg');

rooms

The property's room types with live prices for one stay. The same rows a rooms repeat draws. With no stay: one night from tomorrow. adults starts at 2; childAges is one age per child, each 0 to 17 and at most eight — a list with any other entry, or with a child the property books as an adult, is ignored whole; plan prices one rate plan only. available is true when the room has a rate plan for the stay that can be paid for online — the plan price and bookUrl are for. price and pricePerNight are formatted text in the property's currency, empty when the room cannot be sold; priceAmount is the number, or null — never convert it. price is the whole price the booking page charges: vatAdded and cityTax, formatted and empty unless charged on top of the room rate, are already inside it, and taxes is the one line the booking window prints about them. depositPercent is a number only for a percent deposit. On a room these four are its priced plan's. left is null when the room cannot be sold; scarce is true when 1 to 3 are left. reasonKind says why a room cannot be sold, as one word, and reason as the booking window's sentence in the page's language; both are empty when it can. minStay, maxStay, minAdvance and maxAdvance are a number only when the stay is refused by that restriction, and stayLengths lists the allowed lengths only then. An answer is kept for one minute, so asking again for the same stay and party within it makes no second request.

Signature
rooms(query?: {
stay?: 'tomorrow' | 'weekend',
checkIn?: string, checkOut?: string,
adults?: number, childAges?: number[],
plan?: string,
})
Returns
Promise<Array<{
id: string, name: string, description: string,
photo: string, photos: string[], amenities: string[],
area: number | null, maxGuests: number,
available: boolean,
price: string, pricePerNight: string, priceAmount: number | null, currency: string,
vatAdded: string, cityTax: string, taxes: string, depositPercent: number | null,
left: number | null, scarce: boolean,
reasonKind: '' | 'party' | 'sold-out' | 'closed' | 'no-arrival' | 'no-departure'
| 'min-stay' | 'max-stay' | 'stay-length' | 'min-advance' | 'max-advance' | 'other',
reason: string,
minStay: number | null, maxStay: number | null,
minAdvance: number | null, maxAdvance: number | null, stayLengths: number[],
nights: number, checkIn: string, checkOut: string,
bookUrl: string,
plans: Plan[],
}>>
type Plan = {
id: string, name: string, description: string,
price: string, pricePerNight: string, priceAmount: number,
deposit: string, depositPercent: number | null,
vatAdded: string, cityTax: string, taxes: string,
cancellation: string, includes: string,
bookUrl: string,
}
Example
const rooms = await pmsBooking.rooms({
checkIn: '2026-12-24',
checkOut: '2026-12-27',
adults: 2,
childAges: [6, 9],
});
const onSale = rooms.filter((room) => room.available);
const cheapest = onSale.sort((a, b) => a.priceAmount - b.priceAmount)[0];

bookUrl

The address of your booking page for a stay, a party and a room. The address a data-pms-book link gets. childAges is judged as rooms() judges it and travels as child_ages. plan is used only together with room. With no stay the address carries no dates and no party.

Signature
bookUrl(target?: {
stay?: 'tomorrow' | 'weekend',
checkIn?: string, checkOut?: string,
adults?: number, childAges?: number[],
room?: string, plan?: string,
})
Returns
string
Example
location.assign(pmsBooking.bookUrl({ stay: 'weekend', adults: 2, childAges: [6, 9] }));

calendar

The lowest price and whether the night sells, date by date. from is the first date (left out: today); days is how many. price is the lowest price of that night in currency, or null. available says the night sells. arrival and departure say whether a stay may start or end on that date. min_stay is the minimum stay for an arrival on that date.

Signature
calendar(query?: { from?: string, days?: number })
Returns
Promise<{
currency: string, from: string,
days: Array<{
date: string, price: number | null, available: boolean,
arrival?: boolean, departure?: boolean, min_stay?: number | null,
}>,
}>
Example
const { days, currency } = await pmsBooking.calendar({ from: '2026-12-01', days: 31 });
const open = days.filter((day) => day.available);

refresh

Binds markup added after the page loaded and reads your CSS variables again. Draws new boxes, wires new data-pms-* elements and reads your --pms-* variables again for our frames. Markup a single-page site adds is noticed by itself; a stylesheet swapped while the page is open is not — call refresh() after it.

Signature
refresh()
Returns
void
Example
// after a stylesheet with other --pms-* values was swapped in
pmsBooking.refresh();

currencies

The currencies the property shows prices in. codes is every code on offer; current is the one this visitor sees now.

Signature
currencies()
Returns
Promise<{ codes: string[], current: string | null }>
Example
const { codes, current } = await pmsBooking.currencies();

setCurrency

Shows prices in another currency. Remembered in the visitor's browser; the page reloads to reprice. The booking is still charged in the property's currency. A code that is not three capital letters is ignored.

Signature
setCurrency(code: string)
Returns
void
Example
pmsBooking.setCurrency('EUR'); // remembered; the page reloads

openDates

Opens the calendar of a search form. form is a form of yours, or the box of a ready search form — the element with data-pms-booking="search-form", or the booking window's box while its search form is on screen. For a form of yours: as if its first data-pms-dates button was pressed, with its check-out value and its data-months count. With no form named: the first bound form of yours on the page; a page with none uses its first ready search form. Neither: nothing happens.

Signature
openDates(form?: Element)
Returns
void
Example
pmsBooking.openDates();

openGuests

Opens the guests panel of a search form. Under your form's first data-pms-guests button, or under the ready search form's own guests field when you name its box. With no form named: the first bound form of yours on the page, else its first ready search form.

Signature
openGuests(form?: Element)
Returns
void
Example
pmsBooking.openGuests(document.querySelector('.stay-search'));

closePicker

Closes the open calendar or guests panel. Of your own forms and of the ready search forms alike. Does nothing when none is open.

Signature
closePicker()
Returns
void
Example
pmsBooking.closePicker();

getSearch

What a search form holds now. For a form of yours: read afresh from the form's own fields. For a ready search form — name its box — what the guest has picked in it. nights is 0 without both dates; childAges holds null for a child whose age is not picked yet. null when no form is bound and no ready search form is drawn — also before the script has bound the page, and for the booking window's box once the guest is past the room list.

Signature
getSearch(form?: Element)
Returns
Search | null
type Search = {
checkIn: string | null, checkOut: string | null,
nights: number,
adults: number,
childAges: Array<number | null>,
}
Example
const search = pmsBooking.getSearch();
if (search && search.nights > 0) showNights(search.nights);
// the ready search form, by its box
const ready = pmsBooking.getSearch(document.querySelector('[data-pms-booking="search-form"]'));

setSearch

Sets the dates or the party of a search form. Only the keys you pass change. A date is YYYY-MM-DD, or null to clear it; a change that would leave check-out not after check-in is ignored, so give both dates together. adults is 1 to 20; ages that are not whole numbers from 0 to 17 are dropped. A valid call on a form of yours writes the form's fields and values, updates the state hooks and fires pms-booking-search. On a ready search form it fills the fields the guest sees and fires pms-booking-search on its box; in the booking window, once rooms are listed, the rooms are searched again.

Signature
setSearch(search: Patch)
setSearch(form: Element | null | undefined, search: Patch)
Returns
void
type Patch = {
checkIn?: string | null, checkOut?: string | null,
adults?: number,
childAges?: number[],
}
Example
pmsBooking.setSearch({
checkIn: '2026-12-08',
checkOut: '2026-12-11',
adults: 2,
childAges: [6],
});
// clear the dates of one form
pmsBooking.setSearch(form, { checkIn: null, checkOut: null });

Events

Plain DOM events. Listen with addEventListener.

EventFires onevent.detail
pms-booking-readywindownone
pms-booking-searchyour form, or the ready search form's box — it bubbles{ checkIn: string | null, checkOut: string | null, nights: number, adults: number, childAges: Array, }
pms-booking-renderedthe template — it bubblesnone
pms-booking-themewindow{ theme: 'light' | 'dark' }
pms-booking-localewindow{ locale: 'en' | 'bg' }
pms-booking-openyour form, or the ready search form's box — it bubbles{ picker: 'dates' | 'guests' }
pms-booking-closeyour form, or the ready search form's box — it bubbles{ picker: 'dates' | 'guests' }
pms-booking-stepwindow{ step: 'rooms' | 'rate' | 'extras' | 'details' | 'confirmation' }
pms-booking-purchasewindow{ id: string, total: number, currency: string, roomTypeId: string | null, ratePlanId: string | null, checkIn: string | null, checkOut: string | null, nights: number | null, adults: number | null, children: number | null, }

pms-booking-ready

Fired once, when our script has run and window.pmsBooking exists — before the components are drawn.

  • Fires on: window
Example
function whenBookingReady(run) {
if (window.pmsBooking) run(window.pmsBooking);
else
window.addEventListener('pms-booking-ready', () => run(window.pmsBooking), {
once: true,
});
}

Fired every time the dates or the party of a search form change — through our calendar, our guests panel or setSearch(). On a form of yours it fires on the form; on a ready search form, on its box.

  • Fires on: your form, or the ready search form's box — it bubbles
event.detail
{
checkIn: string | null, checkOut: string | null,
nights: number,
adults: number,
childAges: Array<number | null>,
}
Example
document.addEventListener('pms-booking-search', (event) => {
console.log(event.target, event.detail.nights);
});

A child the guest has added but not yet given an age is null in childAges. Do not pass such a list on: rooms() and bookUrl() take a list only whole, and one null makes them price the adults alone — see Children. Wait for the event in which every entry is a number.

pms-booking-rendered

Fired each time a repeat has been drawn: when the page loads, and again when the language changes.

  • Fires on: the template — it bubbles
Example
document.addEventListener('pms-booking-rendered', (event) => {
const list = event.target.parentElement;
startCarousel(list.querySelectorAll('[data-pms-item]'));
});

pms-booking-theme

Fired when a guest picks light or dark on our theme icon or in our menu. Not fired by setTheme(), nor when the components follow your page.

  • Fires on: window
event.detail
{ theme: 'light' | 'dark' }
Example
window.addEventListener('pms-booking-theme', (event) => {
const dark = event.detail.theme === 'dark';
document.documentElement.classList.toggle('dark', dark);
});

pms-booking-locale

Fired when a guest picks a language on our language icon or in our menu, before the page reloads to apply it. The pick is already remembered in the guest's browser.

  • Fires on: window
  • Cancelable: after event.preventDefault() the page is not reloaded.
event.detail
{ locale: 'en' | 'bg' }
Example
window.addEventListener('pms-booking-locale', (event) => {
event.preventDefault(); // no reload
location.assign(`/${event.detail.locale}/`);
});

pms-booking-open

Fired when a calendar or a guests panel opens for the form. On a form of yours data-pms-open is already set when you hear it; a ready search form's box gets no such attribute.

  • Fires on: your form, or the ready search form's box — it bubbles
event.detail
{ picker: 'dates' | 'guests' }
Example
document.addEventListener('pms-booking-open', (event) => {
console.log(event.target, event.detail.picker);
});

pms-booking-close

Fired when it closes. Switching from one picker to the other fires close for the old one, then open for the new.

  • Fires on: your form, or the ready search form's box — it bubbles
event.detail
{ picker: 'dates' | 'guests' }
Example
document.addEventListener('pms-booking-close', (event) => {
console.log(event.target, event.detail.picker);
});

pms-booking-step

Fired when the booking window shows a step: rooms (the room list, also before a search), rate, extras (only for a rate that has extras), details (your details and payment), confirmation. The first step fires too, and a step the guest goes back to fires again; each showing fires once. A link that lands on a later step fires rooms first, while the prices load. It carries the step's name and nothing else.

  • Fires on: window
event.detail
{ step: 'rooms' | 'rate' | 'extras' | 'details' | 'confirmation' }
Example
window.addEventListener('pms-booking-step', (event) => {
gtag('event', 'booking_step', { step: event.detail.step });
});

pms-booking-purchase

Fired once when a booking is paid online — on your booking page, or on the page of yours a hosted payment returns to. A booking that asks for no payment online fires none: listen for the confirmation step. It carries what our purchase analytics event carries: the amount, the currency, the room type and rate plan ids, the dates and the party, when known. id is an opaque id of the event, the same one our purchase push sends as transaction_id — not the booking's number. Never a name, an email, a phone or a booking reference. Reloading the page does not fire it again. It fires whether or not analytics is on.

  • Fires on: window
event.detail
{
id: string,
total: number, currency: string,
roomTypeId: string | null, ratePlanId: string | null,
checkIn: string | null, checkOut: string | null,
nights: number | null,
adults: number | null, children: number | null,
}
Example
window.addEventListener('pms-booking-purchase', (event) => {
const { id, total, currency } = event.detail;
showThankYou(total, currency);
});

The booking window’s events, in practice

pms-booking-step and pms-booking-purchase are fired on window, once each, and are not kept or fired again for a listener that arrives late. There is no method that answers the current step.

Add the listener before the first step

The first pms-booking-step is never fired while our script is still running: the booking window is drawn only after the property’s configuration has arrived over the network. But it can arrive before a script of yours that loads late.

  • A listener added in a script that stands before our script tag, or in an inline <script> of the page, is always in time. It needs nothing of ours: it is a plain listener on window, so it does not wait for pms-booking-ready.
  • A listener added inside a pms-booking-ready handler is in time too: that event fires first.
  • A listener added later — after the window’s load, in a bundle loaded on demand, in a framework effect that runs after the page is interactive — may miss the first step, and on a page a payment returned to it may miss the only one. Nothing fires it again.
<head>
<script>
window.addEventListener('pms-booking-step', (event) => { /* … */ });
window.addEventListener('pms-booking-purchase', (event) => { /* … */ });
</script>
<script src="https://link.tape-chart.com/widget/v1.js" data-property="YOUR_PROPERTY_NUMBER" defer></script>
</head>

What rooms means

rooms is the name of the first screen of the booking window, whatever it shows. It is fired:

  • on a page opened with no dates, where the screen is the search form and no room is listed yet;
  • on a page opened with dates, while the prices load;
  • on a link that lands on a later step — a room and a rate in the address — where rooms comes first, while the prices load, and the later step follows.

Pressing Search fires nothing: the list of rooms is the same step. The event carries no index, no total and no dates, so it cannot tell these apart. To know whether dates are in, read pmsBooking.getSearch(box) with the booking window’s box — it answers once the form is drawn and while the guest is on this first step, and null after it.

extras is fired only for a rate that has extras, so the number of steps is not known in advance.

Confirmation and purchase

  • confirmation is fired when the guest sees the confirmation, paid online or not.
  • pms-booking-purchase is fired only for a booking paid online, after the script has exchanged the payment’s receipt in one more request. If that request fails, it is not fired.

So confirmation is said first and the purchase a moment later. They are two separate events and no test of ours pins their order: handle each on its own, and do not wait for one inside the handler of the other.

A payment that was refused, or a booking whose room was taken meanwhile, shows its own screen and fires neither.

A payment on the provider’s own page

When the payment is made on the payment provider’s own page, the guest leaves your site and comes back to the page the booking window was on — the same address and path. Only the address and the path are handed over for the return; do not count on that page’s query coming back.

That page loads afresh. The script takes a single-use code off the address as it starts, and the booking window’s box shows the confirmation alone, with no room list around it. On that load the events are: pms-booking-step with confirmation, with no rooms before it, and then pms-booking-purchase. So the listeners must be on your booking page itself, added as above.

Our script shows no consent banner: it listens to yours. Your consent manager writes the visitor’s decision to window.pmsBookingConsent and fires pms:consent on window whenever it changes.

window.pmsBookingConsent = { analytics: true, marketing: false };
// later, when the visitor accepts marketing cookies
window.pmsBookingConsent = { analytics: true, marketing: true };
window.dispatchEvent(new CustomEvent('pms:consent'));

analytics switches our own first-party measurement. marketing switches the tags the property configured — GA4, Meta Pixel, GTM. An object that names one key changes only that key. Without it: data-consent on the script tag, then the property’s own setting, then analytics on and marketing off.