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
|
UbercartOne cart to rule them all... |
|
| Donate to Ubercart | Affiliates | ||
Prevent multiple clicks of submit order
Submitted by txcrew on 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,
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. 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. 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, I'll try, but I wonder if changing the text like that will cause the submit to misfire. 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? 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). 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? 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. 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. 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. Alrighty, this is in Checkout Enhancements.
|
|
Joined: 09/28/2007