Following on the heels of various other issues such as #2106725: Fix interaction between address books & Copy Profile checkbox but more importantly #1804592: During AJAX form submission in checkout, the $order argument passed by the Form API is incorrect. the Addressbook checkout pane dropdown widget has a line of code that loads the current order from the form_state and wraps it.
Steps to reproduce:
1. Checkout with some products.
2. Apply a coupon.
3. Select a new address from the dropdown.
4. Click "continue to next page."
The coupon will have disappeared because the order was reloaded from the Address pane's form values and then re-saved, which means it was saved without the commerce_coupon value attached.
Attached is a patch which fixes this!
| Comment | File | Size | Author |
|---|---|---|---|
| commerce_addressbook-stale-order.patch | 939 bytes | torgospizza |
Comments
Comment #2
torgospizzaNote that the solution is to of course load the current order every time an address is selected. This seems to be the only way to go - even with the patch from #1804592: During AJAX form submission in checkout, the $order argument passed by the Form API is incorrect. attached, because this pane is currently not reloaded via ajax whenever a checkout pane value changes aside from itself.
Also, once #2593983: Create a utility method to compare an orders changed date against the database lands we can update this patch (or the module with a follow-up) to utilize it.
Comment #3
mglamanMakes sense, form state's order can't always be trusted.
Comment #6
vasikeThe commit breaks the update of the customer profile form.
Changing the addressbook selection won't update the profile data.
Comment #7
torgospizzaThank you vasike - I wasn't aware of this side effect. What would be the ideal fix? An order refresh? I can work on a re-roll of this.
EDIT: Oddly enough I'm unable to reproduce the original behavior that this patch was created to fix. Even reverting the patch for #1804592: During AJAX form submission in checkout, the $order argument passed by the Form API is incorrect., the updated order is intact after selecting a new address from the dropdown. So I'm going to have to dig in a bit to see what is different about my current working copy, or if this patch (and perhaps the one above) are no longer necessary.
Comment #8
nbchip commentedCan confirm #6
dev version with this patch doesn't return new selected profile, but the old one
$commands[] = ajax_command_replace(NULL, drupal_render($form[$pane_id]));Comment #10
mbatterton commentedUsing patch #6 with with https://www.drupal.org/node/1804592#comment-10430135 fixed this for us when adding userpoints on the checkout. Great work @torgosPizza and @andyg5000.