Reference
Options reference
Note: Direct configuration of the booking engine through the options has been deprecated and will be disabled in future. Instead use Booking Engine Configuration in Mews Operations. The only supported options now are
configurationIds
andopenElements
.
configurationIds
array ofstring
required
Set of booking engine unique identifiers. You can get the unique identifier of a configuration from its details page in Mews Operations - see Where can I get Configuration ID?.
openElements
string
optional
A list of comma-separated CSS selectors of elements, which will automatically get attached to click event listeners for opening the Booking Engine Widget. The string is given as an argument to the document.querySelectorAll
function, you can get more information about it here. The click event is being delegated, meaning that each element is being looked up on a website dynamically after the click happens. This way you can pass a selector to the elements that don’t exist yet during the initialization.
Javascript API reference
Javascript API calls are defined on the booking engine instance, which is created with the initialization call. This instance is returned to you as an argument of a callback function that you can pass as the second parameter to the initialization call. The following simple example shows how to use the calls to set up start and end dates, and then open the booking engine:
The API functions supported are listed below. Some functions are common to both Single Mode and Chain Mode, while some are specific to one mode or the other.
Common API functions
open()
Opens the booking engine in its overlay
close()
Closes the booking engine and its overlay (note: even though the booking engine is closed, it still responds to API calls)
setLanguageCode(languageCode)
languageCode
Type:string
Description: The language code to be set, in formaten-US
. Supported language codesSets the language of the booking engine’s localization. The language code should be in the format language-countryCode, e.g.
en-US
, as a variant of IETF tag. IflanguageCode
is not in the valid format, nothing happens.
setCurrencyCode(currencyCode)
currencyCode
Type:string
Description: The currency code to be set, in ISO 4217 format, e.g.EUR
. Supported currency codesSets the currency of the booking engine’s localization. The currency code should be in ISO 4217 format. If
currencyCode
is not in the valid format, nothing happens.
setStartDate(date)
date
Type:Date
Description: The start date to setSets the start date for a new availability query, the currently loaded availability list is not affected. If
date
is not a validDate
object or its value isn’t allowed as a start date, nothing happens. Note:monthIndex
starts runs from0
for January to11
for December (click here for more details).
Correct - for 18 January 2019:
Incorrect - DO NOT DO THIS:
setEndDate(date)
date
Type:Date
Description: The end date to setSets the end date for a new availability query, the currently loaded availability list is not affected. If
date
is not a validDate
object, nothing happens. Note:monthIndex
starts runs from0
for January to11
for December (click here for more details).
Correct - for 18 December 2019:
Incorrect - DO NOT DO THIS:
setVoucherCode(code)
code
Type:string
Description: The voucher code to setSets a new voucher code value.
setAdultCount(adultCount)
adultCount
Type:number
Description: The number of adults to setSets the number of adults that should be selected by default. Space occupancy for adults on the rate screen will be pre-filled according to this value.
setChildCount(childCount)
childCount
Type:number
Description: The number of children to setSets the number of children that should be selected by default. Space occupancy for children on the rate screen will be pre-filled according to this value.
disableTracking()
Sets all tracking consents to false (see Integrations).
enableTracking()
Sets all tracking consents to true (see Integrations).
Single Mode API functions
showRooms()
Sets the booking engine to the
Rooms
step.
showRates(roomId)
roomId
Type:string
Description: ID of a room or space to be selectedSets the booking engine to the third step (
Rates
) as if you had selected a room on the second screen.
Chain Mode API functions
showHotels()
Sets the booking engine to the
Hotels
step.
showRooms(hotelId)
hotelId
Type:string
Description: ID of a hotel or other property whose rooms you want to displaySets the booking engine to the
Rooms
step.
setCity(cityId)
cityId
Type:string
Description: ID of a city whose hotels you want to display
Advanced configuration (optional)
As the third parameter, Mews.Distributor
accepts optional configuration.
string dataBaseUrl
Allows you to define a custom URL which is used for booking engine API calls and static assets. In the example above, the booking engine will be run against our Demo environment.
Last updated