"Calculate Shipping" resets payment option choice on checkout screen when using jQuery 1.1.2

Project:Ubercart Contributions
Component:Code
Category:
Priority:normal
Assigned:Unassigned
Status:active
Description
Project: 
Ubercart

Drupal 5 comes with jQuery 1.0.4. I use jquery_update module / method to bump jQuery to 1.1.2 on my site. The issue likely exists with other jQuery versions.

Basic scenario:

A store is setup with 2 payment method options (paypal and webmoney in my case). The checkout panes are ordered such that choice of payment method precedes shipping calculation pane (is this the default?). If the second payment method is selected, clicking "Calculate Shipping" resets the choice of payment method to the default.

The order of panes does not affect reproducibility of the bug. For obvious reasons, if the customer is prompted to calculate shipping first (through ordering of panes), or if there is a single payment method available, the bug doesn't show. Placing shipping pane first cleverly hides the bug, which is the solution I went with for now. The issue however may come up in some alternative scenarios.

Version: 
Ubercart 1.x-dev
Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: "Calculate Shipping" resets payment option choice on checkou

I'm not able to reproduce this bug. I was using the check and credit card payment methods, but the order of the panes didn't affect the choices made in the different panes. Maybe there's something about webmoney integration that isn't right. I haven't looked at the code or anything.

k8n
k8n's picture
Offline
Joined: 04/20/2008
Juice: 21
I narrowed the issue down...
Assigned to:Lyle» k8n

I use jquery_update module (http://drupal.org/project/jquery_update) on my site. Downgrading jQuery, i.e. replacing /misc/jquery.js with Drupal's original makes the problem go away.

According to the jQuery changelog the change that occurred between 1.0.4 and 1.1 relevant here I think is this:
jQuery is no longer destructive. Doing var a = $("a"); a.find("span"); does not change the original "a" variable.
(http://dev.jquery.com/browser/trunk/jquery/ChangeLog.txt#L69)

In $Id: uc_quote.js,v 1.4.2.10 2008/09/17 21:38:39 rszrama Exp $
In function displayQuote(), on line 192, "quoteDiv.end()" returns the whole document, and subsequent operation acts on the wrong set of elements.

  ...
  if (quoteDiv.find("input").length == 0) {
    quoteDiv.end().append(Drupal.settings.uc_quote.err_msg);
  }
  else {
    quoteDiv.end().find("input:radio").eq(0).change().attr("checked", "checked").end().end();
    var quoteForm = quoteDiv.html();
    quoteDiv.append("<input type=\"hidden\" name=\"quote-form\" value=\"" + encodeURIComponent(quoteForm) + "\" />");
  }
  ...

I guess this feeds into the larger issue of porting Ubercart to Drupal 6 which uses newer jQuery out of the box.

I just noticed that it's been fixed in the Drupal 6 branch to work against the newer jQuery, http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/ubercart/sh...

I guess there is no hope for jquery_update and Ubercart on D5 :-/

Karel's picture
Offline
Joined: 06/13/2008
Juice: 19
Re: "Calculate Shipping" resets payment option choice on checkou
Assigned to:k8n» Karel

Any luck with this? I found out about the bug after enabling the shipment module, and I lost three orders in the process :-/ I need jquery update for many other modules, so I can't switch back...

ron_s's picture
Offline
Joined: 09/11/2008
Juice: 173
Re: Re: "Calculate Shipping" resets payment option choice on che
Assigned to:Karel» ron_s

Can you just update jquery.js from 1.0.4 to 1.1.2 manually? Because of all the problems I was having with the jQuery Update module, I just replaced the file in the /misc folder.

Possibly you're running some other modules which require the full jQuery Update code base? Do you really need the most "latest and greatest" jQuery? My experiences have shown that with Drupal 5.x, it's better to stick with some of the earlier versions of jQuery. I'm running Drupal 5.14 with Ubercart 1.6 locally, and have been able to run it without issue with jQuery 1.0.4 (comes with 5.x) and 1.1.2 (manual update).

Please remember though, even if you disable jQuery Update module, the folder needs to be removed from /sites/all/modules! Leaving the folder in there will still cause Drupal to pick up the js files and the errors will continue.

ron_s's picture
Offline
Joined: 09/11/2008
Juice: 173
Re: Re: Re: "Calculate Shipping" resets payment option choice on

Hmmm sorry about that, a manual update to 1.1.2 is not really an option. Still gives the javascript error. Only way I'm able to get things to work without problems is remove jQuery Update module entirely, and revert back to the 1.0.4 baseline.

k8n
k8n's picture
Offline
Joined: 04/20/2008
Juice: 21
Re: Re: Re: Re: "Calculate Shipping" resets payment option choic
Assigned to:ron_s» k8n

In my experience this is no longer an issue when using jQuery Update 2.0 branch. Yey.