If Payment and the Donation pane are on the same checkout page, and the Payment validation fails, then the Donation line item is added to the cart, and the page is reloaded.
At this point the Donation is in cart, so when you correct payment validation problem, and then submit your checkout page form, it gets added again on form submission, resulting in duplicate items in the cart.
This doesn't happen with basic validation on the Payment pane (e.g. missing required fields) -- it only happens when the Card Number doesn't match the credit card type, or other more complex validations..
I'm using Paypal, maybe this is related.
Perhaps addressing #1819786: Hide donation checkout pane when cart already contains donation would make this problem go away...
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | issue-1851196.patch | 3.06 KB | lsolesen |
Comments
Comment #1
tmsimont commentedrelated: #1851312: Payment validation occurs after other panes execute submit callbacks rather than before, resulting in non-standard form behavior
Now I'm not sure if this problem is an issue with the payment module for commerce, or if it's just this module...
Comment #2
tmsimont commentedApparently this issue should be resolved within this module, per rszrama's comments here:
#1380310: Optionally require all panes on a checkout page to validate before processing them and here #1851312: Payment validation occurs after other panes execute submit callbacks rather than before, resulting in non-standard form behavior
Because
commerce_donate_checkout_pane_checkout_form_submit()fires before all of the pane's on the same page validate, it needs to consider the fact that it might be called more than once during checkout. Also, it seems to be called if the user clicks "Go Back" and then re-submits the page where the donation is added.Comment #3
tmsimont commentedAttached is a patch that simply checks an order for the configured donation product ID before adding the donation line item fields to the checkout pane. If there's already a donation in the order, the pane does not display a form, but instead displays markup:
Perhaps the behavior could be instead configurable by the module, but this at least addresses the bug that I encountered where the Donation can be added numerous times to 1 order if there are validation errors on other panes on the same checkout page as the donation form.
Comment #4
tmsimont commentedLast patch doesn't check for existence of property before calling on it.. this should fix it
Comment #5
abasso commentedCould not apply patch above, created a new one.
Comment #6
lsolesen commentedAdded a proper patch made from within the module.
Comment #7
lsolesen commentedThe proposed workaround needs work:
Comment #8
lsolesen commentedComment #9
lsolesen commentedComment #10
lsolesen commentedPatch in #9 fixes notices and warnings after submitting the product.
Comment #11
robcarr#9 works for me. Thanks
Comment #12
lsolesen commentedMinor adjustment to patch.
Comment #13
stella commentedI'm not sure this is the correct approach. What if I wanted more than one donation product type in the cart?
Comment #14
stella commentedThat's also the wrong approach to embedding a link in a translatable string as you're loosing the context of the 'shopping cart' string when translating it. You should be doing something like:
Comment #16
stella commented@lsolesen after closer review, I've committed the patch (with the translation fix described above) as I note that the code just prevents the checkout donation product from being added more than once, which is fine. It doesn't prevent other donation products from being added multiple times.
Thanks all!