Clicking on "Remove" to remove a booking from the cart shows the message " ... removed from the cart", but the booking itself remains in the cart. Happens with "Hotel Room Type" content. Items created with (ubercart) "Product" type can be added and then removed by clicking on "Remove". But, adding "Product" type items and then clicking "Update cart" will remove "Product" type items. The "item not removed" issue occurred previously also with "Product" type items, but has been resolved: http://drupal.org/node/1115360

Comments

larowlan’s picture

Assigned: Unassigned » larowlan
Issue tags: +Release blocker

ta

bwoelkers’s picture

I'm having the same problem. "Product" content types can be removed easily with the update cart/ remove button, but the remove button does not work for "Hotel Room" Content Types. It might be a related issue (probably not, but you never know), but when I add an item in the checkout I have an undefined property notice for weight units:

Notice: Undefined property: stdClass::$weight_units in uc_cart_get_contents() (line 1371 of [installdirectory]/modules/ubercart/uc_cart/uc_cart.module).

The "Hotel Room" content type doesn't allow me to post a weight (which it doesn't need to obviously), but the notice is saying it needs it.

pragna’s picture

Version: 7.x-1.x-dev » 7.x-1.0-alpha1

I have used ubercart_hotel module and ubercart module.
I have requirement same functionality ubercart_hotel In my project but whenever I book room it redirect me cart page and when I tried to remove that room from cart page it remains as it is.
Remove button is not working for ubercart_hotel.

Please help me if any one has solution...

Thanks in advance...:)

pragna’s picture

I solved above problem... replace uc_cart_remove_item function to following code:

function uc_cart_remove_item($nid, $cid = NULL, $data = array(), $op = 'remove') {

if (isset($data['booking_upgrades'])) {
unset($data['booking_upgrades']);
}

if (empty($nid)) {

return;
}

$cart_id = !(is_null($cid) || empty($cid)) ? $cid : uc_cart_get_id();

// Invoke hook_uc_cart_item() with $op = 'remove' in enabled modules.

$result = db_query("SELECT c.*, n.title, n.vid FROM {node} n INNER JOIN {uc_cart_products} c ON n.nid = c.nid WHERE c.cart_id = :cart_id AND c.nid = :nid AND c.data = :data", array(':cart_id' => $cart_id, ':nid' => $nid, ':data' => serialize($data)));

if ($item = $result->fetchObject()) {

foreach (module_implements('uc_cart_item') as $module) {
$func = $module . '_uc_cart_item';
if (function_exists($func)) {

$func($op, $item);
}
}
}

db_delete('uc_cart_products')
->condition('cart_id', $cart_id)
->condition('nid', $nid)
->condition('data', serialize($data))
->execute();
}

larowlan’s picture

Are you saying it's a bug with ubercart? I don't think that is the case, we should be able to resolve it by modifying our implementation of hook_uc_cart_item.
If so please post your fix as a patch so we can allocate it to the Ubercart issue queue.

pragna’s picture

you are right, its not bug of Ubercart we should change the hotel_booking_uc_cart_item() in hotel_booking.ubercart.inc file.

zany’s picture

Status: Active » Needs review
StatusFileSize
new510 bytes

Attached patch fixes this issue. hotel_booking_uc_cart_item() doesn't need to unserialize() $item->data -- it's already unserialized in uc_cart_remove_item(). This patches just the case 'remove', the case 'load' is already ok.
(comment 2 about weight_units is a different problem.)

zany’s picture

The above patch fixed part of the problem. The real problem is the code in hotel_booking.panes.inc line 416:

  if (!isset($item->data['booking_upgrades'])) {
    $item->data['booking_upgrades'] = array();
  }

which introduces a booking_upgrades array entry into data. This then mismatches the db_query() in ubercart's uc_cart_remove_item().

I'm not sure about the fix here. But removing the empty array in hotel_booking_cart_details_table() works for me.

zany’s picture

StatusFileSize
new488 bytes

Here is a patch to test my assumption about the empty booking_upgrades entry into data.

larowlan’s picture

All references to upgrades can be removed, the upgrades module is deprecated in d7.

zany’s picture

StatusFileSize
new12.76 KB

This patch tries to remove all references to upgrades. This needs careful review!

larowlan’s picture

Status: Needs review » Fixed

I've removed the empty upgrades array from the data array.
I've not applied the rest of the upgrades removal patch as I plan to include it eventually, but just don't want it to delay a release of the module.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

manicato’s picture

Priority: Normal » Major
Status: Closed (fixed) » Needs work

I applied this patch. But now, when I click the remove button, it removes not only one room reservation but all of them.

larowlan’s picture

Please test the 7.x-dev version and report back

manicato’s picture

The dev version does the same thing as the beta1 version. You can't remove the rooms from the cart.

manicato’s picture

Still not resolved. Does not work with patch, does not work with "dev" version.

manicato’s picture

Does anybody know the solution?
@larowlan You?

larowlan’s picture

Ubercart has changed the remove checkbox to a button, uc hotel needs updating to suit.

manicato’s picture

Is there a patch to correct this shortly?

manicato’s picture

I downgraded Ubercart to beta1, which still has the check boxes, but it does still not remove the reservations in the cart.

manicato’s picture

Status: Needs work » Fixed

Oh my god. I lost hours and hours for nothing. The patch above works, but not for reservations created before the patch.

Status: Fixed » Closed (fixed)
Issue tags: -Release blocker

Automatically closed -- issue fixed for 2 weeks with no activity.