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!

CommentFileSizeAuthor
commerce_addressbook-stale-order.patch939 bytestorgospizza

Comments

torgosPizza created an issue. See original summary.

torgospizza’s picture

Note 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.

mglaman’s picture

Status: Needs review » Fixed

Makes sense, form state's order can't always be trusted.

  • mglaman committed e9992e5 on 7.x-2.x authored by torgosPizza
    Issue #2624586 by torgosPizza: Selecting saved address loads stale order...

Status: Fixed » Closed (fixed)

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

vasike’s picture

Status: Closed (fixed) » Needs work

The commit breaks the update of the customer profile form.
Changing the addressbook selection won't update the profile data.

torgospizza’s picture

Thank 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.

nbchip’s picture

Can 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]));

  • mglaman committed e9992e5 on 7.x-3.x authored by torgosPizza
    Issue #2624586 by torgosPizza: Selecting saved address loads stale order...
mbatterton’s picture

Using 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.