In the Checkout screen, I can Cancel or Submit my payment.

When I click on Submit, the Cancel button gets disabled but not the submit button.

I think that both should be disabled or hidden and maybe even a message shown in their place saying "Purchase submitted... Please wait." That way we'd avoid people clicking 20 times on the button (which I'd bet happens.)

I can see the function in the cart.js file but I don't understand how $(this) is set properly.

Thank you.
Alexis

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

maximpodorov’s picture

Priority: Minor » Major

Yes, it's really annoying, and can create problems. For me, a strange problem appears in uc_discounts_alt module after doubleclicking on 'Submit order' button. The following modification fixes the problem. Now the original button is really hidden, and the only visible button is disabled clone.

--- uc_cart.js.orig     2009-07-21 18:37:20.000000000 +0400
+++ uc_cart.js  2010-09-05 00:32:42.087112645 +0400
@@ -20,7 +20,8 @@
  */
 Drupal.behaviors.ucSubmitOrderThrobber = function(context) {
   $('form#uc-cart-checkout-review-form input#edit-submit:not(.ucSubmitOrderThrobber-processed)', context).addClass('ucSubmitOrderThrobber-processed').click(function() {
-    $(this).clone().insertAfter(this).attr('disabled', true).after('<span class="ubercart-throbber">&nbsp;&nbsp;&nbsp;&nbsp;</span>').end().hide();
+    $(this).clone().insertAfter(this).attr('disabled', true).after('<span class="ubercart-throbber">&nbsp;&nbsp;&nbsp;&nbsp;</span>').end();
+    $(this).hide();
     $('#uc-cart-checkout-review-form #edit-back').attr('disabled', true);
   });
 }
TR’s picture

Status: Active » Postponed (maintainer needs more info)

@AlexisWilkie: I don't see that the Cancel button ever gets disabled on the checkout page, and I don't see any code that would do that. Maybe this is browser-controlled (and therefore browser-dependent) behavior? I'm using Firefox. Also, there's no "Submit" button on the checkout page, it's "Review order". This is significant because the action isn't finalizing an order, so double clicking really doesn't cause a problem here.

@maximpodorov: Your situation is different than the original poster - the OP was talking about the checkout page while you're talking about the checkout review page. There is no Cancel button on the checkout review page. Moving the .hide() to a new line like you have done doesn't change the behavior of the JavaScript, at least in the version of jQuery that comes bundled with Drupal 6. .end() unwinds the stack, so .hide() is applied to the original $(this) wrapped set in both the current version of the uc_cart.js and in your modified version. Are you perhaps using jQuery update or a new version of the jQuery libraries? Perhaps something that has changed in the jQuery library.

maximpodorov’s picture

Yes, I use jQuery Update module (with jQuery 1.3.2), and the problem (on checkout review page, you're right) does exist.

AlexisWilke’s picture

Status: Postponed (maintainer needs more info) » Active

TR,

Well... I guess I meant the Review screen. The one with two buttons. I use SeaMonkey and FireFox and also I tested on IE. I get the same behavior on all 3.

Now, there is another problem too, all the other links on the page remain click-able. So I was thinking that an even better way would be to show an overlay that's transparent and that prevents clicks anywhere. That way the buttons cannot be clicked and all the links cannot be clicked. (in my website design, removing all the menus would look... quite broken!)

That overlay could include a sentence defined by the admin saying that the transaction is being processed, please wait...

I did not yet test Maxim's changes.

Thank you.
Alexis

AlexisWilke’s picture

FileSize
21.62 KB

There is a sample in a PNG. As you can see I clicked on the Submit button. The Back button is grayed out but the Submit button is still clickable. The waiting GIF shows up but I'm sure some people still click the button multiple times.

Thank you.
Alexis

smartparty’s picture

Having exactly same issue with jquery update (jq 1.3.2) where back/cancel button is greyed out, but the submit button is not.

This is allowing duplicate credit card transactions too with the protx/sagepay module.

** Update: Can confirm code in comment #1 works for me **

P.

maximpodorov’s picture

This is better (end() is removed):

--- uc_cart.js.orig     2009-07-21 18:37:20.000000000 +0400
+++ uc_cart.js  2010-09-05 00:32:42.087112645 +0400
@@ -20,7 +20,8 @@
  */
Drupal.behaviors.ucSubmitOrderThrobber = function(context) {
   $('form#uc-cart-checkout-review-form input#edit-submit:not(.ucSubmitOrderThrobber-processed)', context).addClass('ucSubmitOrderThrobber-processed').click(function() {
-    $(this).clone().insertAfter(this).attr('disabled', true).after('<span class="ubercart-throbber">&nbsp;&nbsp;&nbsp;&nbsp;</span>').end().hide();
+    $(this).clone().insertAfter(this).attr('disabled', true).after('<span class="ubercart-throbber">&nbsp;&nbsp;&nbsp;&nbsp;</span>');
+    $(this).hide();
     $('#uc-cart-checkout-review-form #edit-back').attr('disabled', true);
   });
}
longwave’s picture

Status: Active » Needs review
FileSize
1.01 KB

Patch format attached.

When the Ubercart maintainers look at this, I also request that they consider #941546: uc_cart.js contains unreachable code at the same time.

longwave’s picture

Title: One Button disabled, not the other » "Submit order" button not disabled on click when jquery_update is installed

Fixing title.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Marking RTBC as smartparty already confirmed this patch works.

AlexisWilke’s picture

Hmmm... So we hide the Submit button and disable the Back button. Should we not hide or disable both instead?

  $('#uc-cart-checkout-review-form #edit-back').attr('disabled', true)

should probably also become .hide():

  $('#uc-cart-checkout-review-form #edit-back').hide();

What do you think?

Thank you.
Alexis

longwave’s picture

The submit button is cloned, the clone is disabled and the original is hidden; this means the click processing on the original button occurs as normal. The back button is simply disabled, so the net effect to the end user is that both buttons appear disabled.

smartparty’s picture

I've applied the latest patch and still see two throbbers instead of one when the submit button is clicked.

P

sammys’s picture

Those testing need to make sure they aren't using uc_optional_checkout_review module because this patch won't fix the submit button you get using that module.

I've patched the uc_optional_checkout_review.js file with the same fix (#8) and it works for that as well. I'd say the patch is RTBC.

I have a feeling jQuery 1.2 changed the way chaining works with a cloned jQuery object. It looks like the end() call actually returns the chain to the clone and not to the original object ($(this) in the case of this bug).

AlexisWilke’s picture

sammys,

That wouldn't work because we're not supposed to know that this other module is there. However, this may required a JavaScript hook... I'm not aware of any specific Drupal API for such a case.

Thank you.
Alexis

longwave’s picture

If uc_optional_checkout_review is buggy, it is not uc_cart's responsibility to fix this - a patch should be posted at http://www.ubercart.org/node/4987

sammys’s picture

@AlexisWilke,

In my post above I'm warning testers of this patch that if they have uc_optional_checkout_review installed the posted patch will not fix their problem. I have absolutely no idea what you are talking about.

I think patch #8 will fix the bug reported by the OP because I tested the fix on uc_optional_checkout_review's JS and that worked. They are copies of the same code. Thus a patch for uc_optional_checkout_review can be created by anyone that cares to fix that module also. Good stuff huh? RTBC yo!

Island Usurper’s picture

Status: Reviewed & tested by the community » Fixed

Committed. I'm glad that Drupal 6 now ships with jQuery 1.2 so we don't have to worry about whether jquery_update is enabled or not.

longwave’s picture

Status: Fixed » Patch (to be ported)

Needs porting to 7.x.

longwave’s picture

Status: Patch (to be ported) » Fixed

Wait, no it doesn't :)

Status: Fixed » Closed (fixed)

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