Greetings all,
Is it possible to prevent someone from clicking 'submit order' more than once?
For some reason or another, I just had my ubercart store charge a customer twice on their credit card using PayPal WPP.
Any ideas?
TIA,
txcrew
|
Ubercart |
|
|
|
||
|
Fri, 03/21/2008 - 20:32
Greetings all, Is it possible to prevent someone from clicking 'submit order' more than once? For some reason or another, I just had my ubercart store charge a customer twice on their credit card using PayPal WPP. Any ideas? TIA,
Re: Prevent multiple clicks of submit order
This would be a useful addition. It'd be a really small snippet of jQuery code that would set the "submit" element to disabled. Either that or using hook_form_alter(). There is some good discussion here: Although this is the type of feature I'd love to see rolled into core. We have had quite a few duplicate orders on our site, too.
Re: Re: Prevent multiple clicks of submit order
huh... interesting. I had no clue this was happening. It'd be a very simple bit of JS I can attach to the submit order button. It'll be in the next release.
Re: Re: Re: Prevent multiple clicks of submit order
So... I change line 1623 in uc_cart.module from: <?phpTo: <?phpWhen someone clicks the button, it will get a new onclick function that returns false, thereby canceling any duplicate form submissions. My only question is what if there is a timeout or something else? Then they'll sit there click "Submit Order" over and over with no result. Any thoughts? Should I keep this mod?
Hi Ryan,
Hi Ryan,
Re: Hi Ryan,
I'll try, but I wonder if changing the text like that will cause the submit to misfire.
Re: Re: Hi Ryan,
Follow-up: Can anyone tracking this issue go try checkout on the Livetest and let me know what you think? My only beef with it is the jarring jump to the left, but that's not a huge deal to me since we aren't expecting folks to click the button again. Thoughts? Should this stay in? Should I just make it a simple contrib?
Re: Re: Re: Hi Ryan,
If disabling the button is not an option, the throbber looks good. I could live with the jump to the left because it will show the user who might have clicked it twice that they caused something to start working by clicking once, and in turn will prevent the second click (hopefully).
Re: Re: Re: Re: Hi Ryan,
Well, now with the change, a second click won't do anything anyways. I disable form submission for any subsequent clicks... which I guess means they're up a creek w/o a paddle if it times out?
Re: Re: Re: Re: Re: Hi Ryan,
Timing out could be an issue, but after reading more on d.o I realized that there seem to be issues of doing it this way with certain browsers? Also not having JS enabled would do this (but wouldn't that break Ubercart in general?) One thought I had would be to add some kind of checks-and-balances using the form's token as a key. If more than one insert into uc_orders comes from the same form, then either just overwrite that order row (which is how regular forum and page editing forms work, from what I've read) or ignore the new insert altogether. That way it doesn't matter the client-side issues since it's taken care of on the server end.
Re: Re: Re: Re: Re: Re: Hi Ryan,
Hmm.. that part of a form really only deals with moving an existing order to the post-checkout state's default status and invoking hook_order() w/ the submit $op. There shouldn't be a danger of duplicate orders anywhere. Perhaps I can simply log in the order's data whether or not the submit has happened and not invoke the hook if it's already happened. Although, as of right now, there's no way for someone to checkout without JS enabled anyways. I think I'll go ahead and make my solution a contrib pending review, since I'd like to put up a release candidate in the near future and don't want this to hold it up.
Re: Re: Re: Re: Re: Re: Re: Hi Ryan,
That's what I thought. Well you're more well-versed in Drupal than I am. Whichever you think is best. To be honest, now that I think about it, I think we've only had a few duplicate orders and I think it's been caused more by credit cards being declined, and someone submitting again (after reloading the checkout page perhaps). But I guess it's better to be safe than sorry, so long as it doesn't break the checkout process altogether I will test your contrib once it's up.
Re: Re: Re: Re: Re: Re: Re: Re: Hi Ryan,
Alrighty, this is in Checkout Enhancements.
Bad Practice, but it works.
Works for UC2 and tested in IE7, IE8 & Firefox. Please note that this is bad practice but if you need this problem fixed right away add this line to your uc_cart.pages.inc Search for:
under
add this line
Keep in mind that upon upgrading this will break. Again, only use this if you need it fixed right away and plan to come back later and do it right.
Ubercart 2?
Hello running Ubercart 6.x-2.2 and customers are still getting double submissions when they double click this button. Please note that ideally the submit button should change to something that says "sending" while the next page loads; and prevent further submissions. Thanks Sebastian.
more information
Hello, of so apparently Ubercart *does* prevent double orders by disabeling the button... however double orders are still happening sometime! I am not sure yet why, as I can't reproduce it. But once I can really nail the cause I will post more information.
Re: more information
If you have jquery_update installed, this causes the code that disables the button to break. See http://drupal.org/node/795676
Viable solution
I was looking into this because there are a bunch of things that can go wrong. IE - if submit is clicked, then back button is clicked you may want to lock the back button as well. The problem I ran into was that disabling the submit button caused the cart not to submit at all. A more viable solution: function lock_submit_order(){ -reference your javascipt using #after build. So in your customized module or whatever you would have something like: function your_module_form_alter($form_id,$form){ function _load_your_module_javascript($element){ The result should be the "Submit Order" button appearing as if it's been locked and it says processing. What really happens is that you've hidden the "submit order" button and unhidden the disabled "processing button" |
|