BAR website integration

© 2008-2018 WebHotelier Technologies Ltd.

Integration Steps
  1. Write a local javascript function that will accept the data
  2. Include the remote BAR script with a callback to the local function
  3. Read the returned BAR data using
  4. Change the HTML placeholders with the correct information

Requirements

  • Novice Javascript knowledge
  • Access to website source files or templates
Live Example (view source for actual code)

1. Insert JavaScript

<script defer async src="https://rest.reserve-online.net/bar/george.js?callback=renderBar&per=room&date=today+2"></script>

2. Define JavaScript callback

<script>
function renderBar(data) {
    // do something with the data
    var rm;
    for ( rm in data ) {
        if ( document.getElementById('rm-'+rm) ) {
            document.getElementById('rm-'+rm).innerHTML = 'BOOK THIS ROOM FROM €' + data[rm].price.toFixed(2) + ' PER NIGHT';
        }
    }
}
</script>

Sample window.webhotelier.bar output


{
    "PENTH":{
        "roomName":"Penthouse Suite",
        "room":"penth",
        "price":130.5000,
        "constraints":{
            "expiration":"",
            "earlyBookLimit":14,
            "freeCancelDays":32767
        },
        "parentRate":8294,
        "name":"Advance Purchase",
        "tod":"",
        "description":"10% Off Best Available Rate !! BOOK NOW,",
        "pricing":{
            "minBefore":81.00,
            "max":148.50,
            "days":441,
            "min":81.00,
            "maxBefore":148.50
        },
        "fromd":"2010-09-04",
        "id":20955,
        "public":1
    },
    "JNR":{
        "roomName":"Junior Suite",
        "room":"jnr",
        "price":112.5000,
        "constraints":{
            "expiration":"",
            "earlyBookLimit":14,
            "freeCancelDays":32767
        },
        "parentRate":8293,
        "name":"Advance Purchase",
        "tod":"",
        "description":"10% Off Best Available Rate !! BOOK NOW,",
        "pricing":{
            "minBefore":72.00,
            "max":130.50,
            "days":441,
            "min":72.00,
            "maxBefore":130.50
        },
        "fromd":"2010-09-04",
        "id":8749,
        "public":1
    },
    "STUDIO":{
        "roomName":"Studio",
        "room":"studio",
        "price":115.0000,
        "constraints":{
            "expiration":"",
            "earlyBookLimit":14,
            "freeCancelDays":32767
        },
        "parentRate":8295,
        "name":"Advance Purchase",
        "tod":"",
        "description":"10% Off Best Available Rate !! BOOK NOW,",
        "pricing":{
            "minBefore":70.00,
            "max":135.00,
            "days":441,
            "min":70.00,
            "maxBefore":135.00
        },
        "fromd":"2010-09-04",
        "id":21110,
        "public":1
    },
    "DEL":{
        "roomName":"Deluxe Room",
        "room":"del",
        "price":112.5000,
        "constraints":{
            "expiration":"",
            "earlyBookLimit":14,
            "freeCancelDays":32767
        },
        "parentRate":8292,
        "name":"Advance Purchase",
        "tod":"",
        "description":"10% Off Best Available Rate !! BOOK NOW,",
        "pricing":{
            "minBefore":72.00,
            "max":130.50,
            "days":441,
            "min":72.00,
            "maxBefore":130.50
        },
        "fromd":"2010-09-04",
        "id":8748,
        "public":1
    }
}