Elxis CMS Forum

Extensions => Components => Topic started by: jesusto on December 30, 2013, 21:35:55

Title: prices before discounts for all rooms in iosr4?
Post by: jesusto on December 30, 2013, 21:35:55
Hi,

Is there a way to show prices before discounts (red and strikethrough) for every room of the hotel and not just for the recommended one?

Thanks a lot
Title: Re: prices before discounts for all rooms in iosr4?
Post by: datahell on December 30, 2013, 23:28:48
It does so if you proceed to booking.

To do what you want in the dynamic room pick form is quite difficult if you don't have tech skills. You must modify the html and the javascript code and the code is difficult for not experienced developers...

Technical information below for those they can...
IOSR Hotels availability system for each item calculates 2 prices, the normal without any discount and one with the discounts applied. These values are separated with a "no", which means "no discount".

$iosr = eRegistry::get('icore');
$availability = $iosr->loadOnce('availability', 'hotels');
$ok = $availability->prepare($checkin, $checkout, $guests, $is_touroperator, 0, 0, false);
if ($ok) {
   $response = $availability->checkHotel(0, $row);
}

For picked rooms recommendation form
available rooms and their prices are in $response['picked'] array
"price" is the final price with the discounts and "priceno" the price without the discounts.


For dynamic pick rooms form
available rooms and their prices are in $response['rooms'] array

For each room these data are available:
"unitadult": Price per adult for one room with discounts applied
"unitchild": Price per child for one room with discounts applied
"unitadultno": Price per adult for one room without discounts
"unitchildno": Price per child for one room without discounts

On rooms with charge type "per room" the room's unit price is the "unit adult" price.

Of course if the customer picks more than one adults/children/rooms the calculation should consider these parameters too. This is why I said that it is difficult for someone to do it...
Title: Re: prices before discounts for all rooms in iosr4?
Post by: jesusto on December 31, 2013, 16:17:53
Thanks Datahell,

As I only use "per room" option I have solved this way:

$pnodiscount = $currency->formatexprice($response['rooms'][$rid]['unitadultno'], 1, 1);

echo '<span class="resh_oldprice" dir="ltr">'.$pnodiscount.'</span> '.$p1.' '.$symb. ' ' .$eLang->get('PER_ROOM');


Now I would like to make the same in hotel list (locations), and also include there the  "only one room left" if it should appear.

This doesn´t work (shows 0):    $fprice = $currency->shortprice($room->priceno);

Can you please help?

Thanks a lot in advance and HAPPY NEW YEAR!!
Title: Re: prices before discounts for all rooms in iosr4?
Post by: datahell on January 01, 2014, 14:43:04
In the hotels list page you have to deal with javascript because the price changes dynamically based on the user selection of number of rooms. Else it wont be good, except if you only want to display just the unit price (the price for one room). 

In the location hotels listing page the following data are available under conditions.

A. If customer has picked checkin/checkout/guests then the actual price is shown:
if ($pagedata['check'] == true) { ... }
Available data in this case:
$hotel->price Actual hotel price with discounts
For each room:
$room->price Actual room price with discounts
$room->discounts An array containing the discounts applied, if any (you can calculate the normal price from this)
The discounts array has elements in this format discounttype:discountamount (example longdiscount:10)
So if for example $room->price = 45, and longdiscount = 10(%) then the normal price without the discount is:
x = (45  * 100) / (100 - 10) => x = 4500/90 => x = 50 EUR (this is the "no" price for the room)

B. If customer has not picked checkin/checkout/guests or has selected to see all rooms:
if ($pagedata['check'] == false) { ... }
Available data in this case:
$hotel->minprice Minimum hotel price
$hotel->minpricepp Whether the minimum price is per person (1) or per room (0)

For each room:
$room->minprice Minimum room price
$room->maxprice Maximum room price

The prices without the discount ("no" prices) are only available in the availability check response array ($response).

All available discount types
operdiscount
lastmindiscount
earlydiscount
longdiscount
childdiscount
weekdays : 0 / 1 (no/yes) - details are not available in the response, you only get weekdays:vary
weekday1: 0 - 6 (day of the week)
weekdaypc1: 0 - 100
weekday2: 0 - 6 (day of the week)
weekdaypc2: 0 - 100
weekday3: 0 - 6 (day of the week)
weekdaypc3: 0 - 100

Title: Using IOSR API to get room prices
Post by: datahell on January 01, 2014, 15:24:58
Someone can use the built-in XML/JSON API to check available rooms and get their prices (with and without discount).

API endpoint:
http://www.example.com/inner.php/reservations/hotels/api/checkavrooms

Response parameters:
currency, hid, title, childage, numrooms, guests, checkin, checkout, syscheckin, syscheckout, message, rooms, pickedrooms

"rooms" contains the following data for each room returned:
rid, title, available, vacancy, persons, chargetype, unitadult, unitadultno, unitchild, unitchildno, discounts, sqm, message, facilities, facilitiestext, images

"pickedrooms" contains the following data for each room that has an exact match:
rid, price, priceno

More information on IOSR Hotels API developers documentation.
Title: Re: prices before discounts for all rooms in iosr4?
Post by: jesusto on January 02, 2014, 02:07:06
Pitty, really difficult for me.

What about this? I would like to include in hotel list the "only one room left" if it should appear.

Is it easier?

Thanks again
Title: Re: prices before discounts for all rooms in iosr4?
Post by: datahell on January 02, 2014, 11:19:02
Availability check is the core of IOSR Hotels and the hardest part. Nothing is easy in this part even if the system does automatically the calculations and gives you ready to use results. My advice is not to touch such things except if you are an expirienced developer.