Strange checkout-problem with Internet Explorer

Posts: 82
Joined: 08/12/2007
Uber DonorBug FinderInternationalizationizer

Hey there.

I waste a whole day by debugging a strange behaviour in IE. I updated a site from RC4 to 1.0, after that everything went fine. Today I noticed, that IE-Users can't finish the checkout process. Respectively they can finish the checkout process, but they don't get an Order-ID and the order stays in "in_checkout" state.

While debugging I detect, that in the step between cart/checkout/review and cart/checkout/complete the $_SESSION[cart_order] gets lost.

In theme_uc_cart_checkout_review() $_SESSION[cart_order] is still set. But in uc_cart_checkout_review_form_submit() $_SESSION[cart_order] doesn't exist. Therefore $order = uc_order_load($_SESSION['cart_order']) (~line 1678) can't work corectly. I point that out by writing print_r($_SESSION) in both functions.

The result is, that the IE-User gets a message similar to "Order is complete, Your Order-ID is: ... " without a number. In the database the order_status is still "in_checkout".

I have NO idea where to search. In Firefox/Opera everything works well. And in IE only the $_SESSION[cart_order] gets lost, not the whole session.

I could understand it, if the whole session gets lost, then it would be a browser problem. And I would understand it, if a Session variable gets lost in every browser, then it would be a code problem. But one variable? And just in one browser?

I'm very thankful for every hint!

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Hmm... thanks for the info. Someone else posted this sort of issue, but I had no clue where to start looking. There seems to be a lead here, so I'm going to redirect that thread here.

I'm curious if there's anything that's possibly trying to load in IE that fails and "loads" /cart where the cart_order session variable gets unset. This may be the case, and solarian has submitted a patch that I haven't had a chance to test out yet.

You need to add this code to the top of uc_cart_view() in uc_cart.module:

<?php
 
// Failsafe so that this function only works when called with no arguments.
  // This prevents the accidental wiping of the cart_order session variable.
 
if ((func_num_args() > 0)) {
    return
drupal_not_found();
  }
?>

Let me know if that gets you anywhere.

Posts: 82
Joined: 08/12/2007
Uber DonorBug FinderInternationalizationizer

Thanks for your quick reply.

The code seems to have no effect.
For debugging I wrote under every unset($_SESSION['cart_order']) a drupal_set_message("UNSET LINE XYZ");

But I can't detect any differences between the browsers. The only unset between /review and /complete is called in uc_cart_complete_sale():

~line 1840: unset($_SESSION['cart_order'], $_SESSION['do_complete'], $_SESSION['new_user']);"

And that's ok.

I'm not even sure if this is a browser, an ubercart or a module problem.

Posts: 82
Joined: 08/12/2007
Uber DonorBug FinderInternationalizationizer

Ok, I found the problem in uc_cart_checkout_form():

<?php
  $referer
= referer_uri();
  if (
substr($referer, -20, 20) == 'cart/checkout/review' || substr($referer, -13, 13) == 'cart/checkout') {
    if (
$order == FALSE || uc_order_status_data($order->order_status, 'state') != 'in_checkout') {
       unset(
$_SESSION['cart_order']);
     
$order = NULL;
    }
    if (
uc_order_status_data($order->order_status, 'state') != 'in_checkout' || ($user->uid > 0 && $user->uid != $order->uid)) {
     
$order = NULL;
    }
  }
  else {
   
//@problem unset($_SESSION['cart_order']);
 
}
?>

For now it solves my problem when I comment out unset($_SESSION['cart_order']);

Reasons? Dunno..
Do you see any problems by commenting in out?

Posts: 5367
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Ahh, something about the HTTP Referer is different from IE to FF. I was actually just about to review and implement the patch here or some similar solution. The idea is to check w/ another variable where the user is coming from instead of relying on HTTP Referer.