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
configurationIdsandopenElements.
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:
<!-- Example of use of an instance to call the API -->
<script>
Mews.Distributor({
configurationIds: ['aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'],
}, function(distributor) {
$('.booking-button').click(function() {
var start = new Date();
var end = new Date();
end.setDate(start.getDate() + 2);
distributor.setStartDate(start);
distributor.setEndDate(end);
distributor.open();
});
});
</script>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)
languageCodeType:stringDescription: 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. IflanguageCodeis not in the valid format, nothing happens.
setCurrencyCode(currencyCode)
currencyCodeType:stringDescription: 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
currencyCodeis not in the valid format, nothing happens.
setStartDate(date)
dateType:DateDescription: The start date to setSets the start date for a new availability query, the currently loaded availability list is not affected. If
dateis not a validDateobject or its value isn’t allowed as a start date, nothing happens. Note:monthIndexstarts runs from0for January to11for December (click here for more details).
Correct - for 18 January 2019:
distributor.setStartDate(new Date(2019, 0, 18))Incorrect - DO NOT DO THIS:
distributor.setStartDate("2019-01-18")
setEndDate(date)
dateType:DateDescription: The end date to setSets the end date for a new availability query, the currently loaded availability list is not affected. If
dateis not a validDateobject, nothing happens. Note:monthIndexstarts runs from0for January to11for December (click here for more details).
Correct - for 18 December 2019:
distributor.setEndDate(new Date(2019, 11, 18))Incorrect - DO NOT DO THIS:
distributor.setEndDate("2019-12-18")
setVoucherCode(code)
codeType:stringDescription: The voucher code to setSets a new voucher code value.
setAdultCount(adultCount)
adultCountType:numberDescription: 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)
childCountType:numberDescription: 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
Roomsstep.
showRates(roomId)
roomIdType:stringDescription: 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
Hotelsstep.
showRooms(hotelId)
hotelIdType:stringDescription: ID of a hotel or other property whose rooms you want to displaySets the booking engine to the
Roomsstep.
setCity(cityId)
cityIdType:stringDescription: ID of a city whose hotels you want to display
Advanced configuration (optional)
As the third parameter, Mews.Distributor accepts optional configuration.
Mews.Distributor(
{ configurationIds: ['aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'] },
function (api) {
api.open();
},
{ dataBaseUrl: 'https://api.mews-demo.com' }
);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
Was this helpful?