Multiple enterprises and pre-selected locations
Sample code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!-- 1. Install booking engine loader script as close to the opening <head/> tag as possible -->
<script src="https://api.mews.com/distributor/distributor.min.js"></script>
<title>My page</title>
</head>
<body>
<!-- 2. Add buttons for opening the booking engine with specific location pre-selected -->
<button disabled type="button" id="london-button">Loading...</button>
<button disabled type="button" id="paris-button">Loading...</button>
<script>
// 3. Initialize Booking Engine Widget just before the closing </body> tag.
Mews.Distributor(
// 3.1 Set Configuration IDs of your booking engine.
{
configurationIds: [
'Configuration id of first London hotel',
'Configuration id of second London hotel.',
'Paris hotel configuration id',
],
},
// Add callback which will make the buttons open Booking Engine Widget and set the city/location.
function (api) {
const initializeButton = (buttonId, cityId, buttonText) => {
const buttonElement = document.getElementById(buttonId);
buttonElement.addEventListener('click', event => {
event.preventDefault();
// Use Booking Engine Widget API to set the city/location and open the Booking Engine Widget.
api.setCity(cityId);
api.open();
});
buttonElement.innerHTML = buttonText;
buttonElement.disabled = false;
};
// 3.2 Prepare the City IDs.
const londonCityId = 'Your London city id';
const parisCityId = 'Your Paris city id';
initializeButton('london-button', londonCityId, 'London hotels');
initializeButton('paris-button', parisCityId, 'Paris hotel');
}
// 4. Note - this guide is written for the Production environment.
);
</script>
</body>
</html>1. Install booking engine loader script
2. Add buttons for opening the booking engine with specific city pre-selected
3. Initialize Booking Engine Widget
4. This guide is written for the Production environment
Conclusion
Last updated
Was this helpful?