Price list | Previo API

Price list


Price list of accommodation with the same functionality and html structure as the price lists used on the websites of hotels created by our company.


  • Simple file cache
  • Supported languages ​​cs, en, de and sk
  • Switching seasons using JavaScript
  • Prices per room / per person

Download source code

History of changes

Date Change
17.7.2009 Added Slovak
20.7.2009 More accurate CSS class names
20.7.2009 Fixed invalid formatting character in English translation


Upload the Previo_PriceList base class from its actual location and set the login name, password, cache directory, and wsdl file addresses in the constructor.

require_once 'Previo/PriceList.php';
$priceList = new Previo_PriceList(array(
    'login'    => 'login_name',
    'password' => 'password',
    'cachedir' => 'path_to_directory',
    'booking' => array(
        'wsdl' => ''),
    'hotel' => array(
        'wsdl' => ''),
    'system' => array(
        'wsdl' => '')));

Set hotel id, date, language and currency.

    ->setTerm(array('from' => '2009-01-01', 'to' => '2009-12-31'))

Now all you have to do is call the render()method, which returns the HTML code of the price list.

echo $priceList->render();

Each subsequent call to the render() method with the same combination of hotel id, date, language, and currency returns the code stored in the file in the cachedir directory. There is no connection to the Previo server at all.

Finally, season switching is activated, just call the JavaScript function previoLoadPriceList(). This needs to be done when the entire document is ready. Use e.g.

<body onload="previoLoadPriceList()"></body>

or one of the JavaScript libraries (jQuery, Prototype).

Possible improvements

Regular maintenance

The first call to the render()method requires a connection to the Previo server. It is not good for this task to lie on the shoulders of any of the visitors to your site. Therefore, create a cron task and generate price lists at regular intervals, so visitors will only see the cached results.

// file cronCenik.php
// first you need to delete the chachedir directory ...
$priceList = new Previo_PriceList(...);
// for all hotels connected with Previo
foreach ($hotIds as $hotId) {
    // your site is in Czech and English
    foreach (array('cs', 'en') as $lang) {
        foreach (array('CZK', 'EUR') as $currency) {
            // render empty, the result is saved in cachedir


The cache method used is primitive. If you use a custom method (memcache, Zend_Cache), use it.


The Previo_PriceList class contains the _translate() translation method and strings stored in a static array. If you use another system (gettext, constants), replace these structures with your own solution.

Changing the structure of HTML code

All HTML code is located in the template.php file. Add elements or CSS class names as you wish.