even if there are no more rooms of this type available.
An example would be a room type that has 5 rooms, but only one available for the specified date. The user adds the room to the cart and continues shopping for more rooms, and the room they already have in the cart shows up again, and will let you add it to the cart again, even though there is only one available.

I think some logic may need to be added in the search to check the users cart and subtract those rooms from the results.

Also if a room type is already added to the cart and they want to book more rooms of the same type, is there a way to see how many of those rooms are available and set the quantity you would like to book?

CommentFileSizeAuthor
#15 hotel_booking_module_addition.txt2.85 KB_boban

Comments

codigovision’s picture

Priority: Normal » Critical

Setting this to critical, because we can't go to production without this getting fixed. Thank you.

larowlan’s picture

Can they checkout?
There is a hook_order or similar in the code that is supposed to prevent them from finishing checkout.

Lee

codigovision’s picture

Hi Lee, thanks for responding. we're set up using paypal and it gets all the way to logging in to paypal, which seems too far. I think it should give an error as its added to the cart, but even better would be adding a cart check to the search, so the room type doesn't show up at all if there are no availabilities left. I wish i knew more php so i could help, I tried intensely to figure it out, but its over my head. thanks for your help.

larowlan’s picture

What paypal module are you using - wps or express?
WPS definitely generates the order first so if you're using that - it's definitely not working the way it should.

codigovision’s picture

Yes we are using WPS. and the 4.0 alpha1 version of this module.

Here is the development site,
http://casadeflores.codigovision.com
paypal is live, but set to authorize only, I will cancel any test transactions, if you need to test it.

larowlan’s picture

The right way to do this is to prevent checkout, not adding to cart.
Otherwise your competitor could go to your site, add all of your rooms to their cart and then leave them there - and noone else could book.

codigovision’s picture

Maybe what I was thinking is not possible then, but I hoped that the search could check just the cart for the user searching, and subtract rooms in their cart in the calculation of which rooms to show for the search. So it would only affect that one persons search, and only for the dates they have in their cart.

Were you able to test it though, is it working on your end? because it still lets me get all the way to paypal and would overbook the room. because we only have one room of each type. any way to fix this?

codigovision’s picture

Hi Lee, this is still an issue, it is allowing someone to book the same room type twice even if only one is available. We would really appreciate anything you can do to resolve this, we want to go live with the site as soon as possible.

Thank you :)

larowlan’s picture

Hi
To be honest I don't have time to look at this at the moment.
It should be an implementation of hook_order (see the Ubercart api docs on the Ubercart site) that does a final 'pre-flight' check and prevents the order from continuing if necessary.

LR

spydmobile’s picture

Hi Lee, Our issue was closed as a duplicate, we are on vers 2.dev not 4. we are also being held back from going live by this problem, it would appear that there is already a check in place, but it avoids adding the SAME search to the cart and only the same search. Are we sure that this is the same issue? in both versions of the code?
Franco

heidiselzler’s picture

Version: 6.x-4.0-alpha1 » 6.x-2.x-dev
Component: Code » User interface

Hi Lee,

I realize you are very busy and your last post here was almost a month ago... Would it be possible to hire you to solve this problem? We were supposed to go live on October first and our client is unhappy because we have not fixed this problem yet. Please let me know...

The cart allows you to add the same room for overlapping dates twice (in the same transaction), thereby double booking the room. The Room Availability sets itself to -1. Also, I was emailed two booking confirmations, both with the same information in each. I am NOT saying rooms are double booked in separate transactions, just within the same transaction.
However, it does NOT allow a double booking in the cart if you book the exact same room with all the same criteria (date, number of people, number of nights).
In other words....
If you simply book the same room twice without changing dates or number of nights, it overwrites what was in the cart without double booking the room correctly.
BUT if you change the number of nights but leave the same date it lets you add the room to the cart and double books.
Also, if you change the number of people in the room but leave the same dates it lets you double book the room.

Regards, Heidi

heidiselzler’s picture

Version: 6.x-2.x-dev » 6.x-4.0-alpha1

ooops! I changed the version from the original post but I just changed it back... sorry

Hi Lee,

I realize you are very busy and your last post here was almost a month ago... Would it be possible to hire you to solve this problem? We were supposed to go live on October first and our client is unhappy because we have not fixed this problem yet. Please let me know...

The cart allows you to add the same room for overlapping dates twice (in the same transaction), thereby double booking the room. The Room Availability sets itself to -1. Also, I was emailed two booking confirmations, both with the same information in each. I am NOT saying rooms are double booked in separate transactions, just within the same transaction.
However, it does NOT allow a double booking in the cart if you book the exact same room with all the same criteria (date, number of people, number of nights).
In other words....
If you simply book the same room twice without changing dates or number of nights, it overwrites what was in the cart without double booking the room correctly.
BUT if you change the number of nights but leave the same date it lets you add the room to the cart and double books.
Also, if you change the number of people in the room but leave the same dates it lets you double book the room.

Regards, Heidi

heidiselzler’s picture

Hi there, do you know how to implement this?

"It should be an implementation of hook_order (see the Ubercart api docs on the Ubercart site) that does a final 'pre-flight' check and prevents the order from continuing if necessary."

ty, H

larowlan’s picture

I knew I'd done this at some stage...
This is from pre v1 of the module so tables names etc have change but it's a good start:
Other issues:
a) not i18n friendly
b) $product->title is not passed through check_plain
c) doesn't meet coding standards
This dates back to my first ever drupal code (and it shows)
Lee

/**
* Implementation of hook_order
*/
function hotel_booking_order($op, &$order, $status) {
    switch($op) {
    case 'load':
        foreach($order->products as $key => $product){
            if($product->data['module'] = 'hotel_booking'){
                //this is a hotel booking product
                //check still available
                $nid = $product->nid;
                $nights = $product->data['nights'];
                if(is_array($nights)) {
                    foreach($nights as $night) {
                        foreach($nights as $night) {
                            //do it like this in case cart has two products the same with same dates
                            $allNights[$night]++;
                        }
                        foreach($allNights as $night => $qty) {
                            $result = db_query("SELECT avail_quantity
                                               FROM {hotel_availability_calendars}
                                               WHERE rtid = %d
                                               AND caldate = '%s'", $nid, $night);
                            $avail = db_result($result);
                            if($avail < $qty) {
                                return array(array('pass' => FALSE, 'message' => 'We are sorry but there are no longer enough '.$product->title.' rooms available for '.date('d/m/Y',strtotime($night)).'.<br />Please '.l('/book', 'try searching again')));
                            }
                        }
                    }
                }
            }
        }
        break;
    case 'new':

        break;

    case 'update':

        break;

    }
}
_boban’s picture

StatusFileSize
new2.85 KB

Hi all,
if all available rooms are already in cart, the following code prevent the rooms showing up in the search form, based on 7.x-1.0-beta1 code.
hope it will help.

[edit]
it removes the room type from search result, if available quantity in database for the booking dates are already in the cart of person/session responsible for booking.
sorry for bad english.