Hi,
if 2 users add the same room to the cart, and one of them pay the reservation?
What happens to the other user? Could he continuing the reservation and pay of the same room?

Thank you in advance

Comments

larowlan’s picture

Status: Active » Fixed

There is an implementation of hook_order that does a final check before the order is saved and returns an error if someone else has beaten them to it.
There will always be a race condition but that's down to Drupal 6 using Myisam as the db engine instead of innodb.

Lee

Anonymous’s picture

Thanks for your answer, I thought that, but wasn't sure.

ayalsule’s picture

Hi
first I want to thank @larowlan to the great support he provide in uc_hotel
second , I though there is a problem with overbooking
I booked a room and check it out ,but the days I booked still available in availability calendar , with 1 room available , I tried to rebook the same room with same period It`s still available , I think It must disabled in availability calendar first with red days and checked in checking out too , I see hook_order but It`s seems to b there is no availability update

<?php
/**
 * Implementation of hook_order().
 */
function hotel_booking_order($op, &$order) {
  switch ($op) {
    case 'load':
      hotel_booking_inc('util');
      if (hotel_booking_item_in_order($order) &&
          variable_get('hotel_booking_reward_prompt', '')) {
        $result = db_query('SELECT *
                           FROM {hotel_booking_reward_memberships}
                           WHERE order_id = %d', $order->order_id);
        if ($data = db_fetch_object($result)) {
          $order->reward_membership = $data->member_number;
        }
      }
      break;

    case 'save':
      if (hotel_booking_item_in_order($order) &&
          variable_get('hotel_booking_reward_prompt', '')) {
        if (!empty($order->reward_membership)) {
          $record = array(
            'order_id' => $order->order_id,
            'member_number' => $order->reward_membership
          );
          drupal_write_record('hotel_booking_reward_memberships', $record, array('order_id'));
        }
      }
      break;

    case 'delete':
      db_query('DELETE FROM {hotel_booking_reward_memberships}
               WHERE order_id = %d', $order->order_id);
      break;
  }
}
?>

please check and advice

ayalsule’s picture

Status: Fixed » Active
larowlan’s picture

Hi
The availability update occurs via conditional actions which by default are setup to fire when
a) an order payment is entered and
b) the order status is not 'payment received' and
c) the order balance (after payment) is zero
So if you're using a manual payment method (eg other, COD, cheque etc) the CA won't fire.
You can create a new CA to fire on 'checkout complete' by editing/copying the default one.
There are a few posts in the issue queue regarding how to do this.

I've seen default conditional actions that just won't fire before, something to do with module weights - if this is the case you can edit the default one and add another action like 'Display a message to the user' and that moves the CA from code (defaults ca's provided by a module are in code) to the database (manual ca's are saved in the database) and then they fire every time.

Lee