Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for advancing carts correctly in admin checkout #4253

Merged
merged 3 commits into from
Mar 2, 2022

Conversation

tmtrademarked
Copy link
Contributor

Description:

This PR adds a minor fix for cart behavior in Admin. When updating the customer details, the current code only calls next. This will move th order one state down the checkout flow - so, for instance, from address to delivery. But if the order could move further, it won't. And this can leave orders in a slightly unexpected state.

As an example, in our store, when the order is in the delivery state, there is no admin UI element to cause it to move into the payment state, short of selecting a different shipping method or adding a new item to the cart. And since for us, taxes aren't calculated until the order reaches the payment state, we can't render the correct cost in the payment detail admin page to allow our admins to enter the correct payment.

This fix is rather simple - rather than moving only one state, move as far as possible via advance. This essentially preserves the same behavior as before if the order could not advance, but allows the order to move forward into payment if the shipments all have shipping rates selected. By default, the default estimator should be selecting a shipping rate for every shipment when the shipments are proposed.

I tested this in my store with shipments which had multiple shipment rates, and observed no problem advancing to the payment state. We could potentially make this opt-in if desired, but that felt like slight overkill.

Checklist:

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have updated Guides and README accordingly to this change (if needed)
  • I have added tests to cover this change (if needed)

This PR adds a minor fix for cart behavior in Admin. When updating the customer details, the current code only calls `next`. This will move th order *one* state down the checkout flow - so, for instance, from `address` to `delivery`. But if the order could move further, it won't. And this can leave orders in a slightly unexpected state.

As an example, in our store, when the order is in the `delivery` state, there is no admin UI element to cause it to move into the `payment` state, short of selecting a different shipping method or adding a new item to the cart. And since for us, taxes aren't calculated until the order reaches the `payment` state, we can't render the correct cost in the payment detail admin page to allow our admins to enter the correct payment.

This fix is rather simple - rather than moving only *one* state, move as far as possible via `advance`. This essentially preserves the same behavior as before if the order could not advance, but allows the order to move forward into payment if the shipments all have shipping rates selected. By default, the default estimator should be selecting a shipping rate for every shipment when the shipments are proposed.

I tested this in my store with shipments which had multiple shipment rates, and observed no problem advancing to the `payment` state. We could potentially make this opt-in if desired, but that felt like slight overkill.
@tmtrademarked
Copy link
Contributor Author

It seems like the remaining failure might be a flake of some sort - seems unlikely my change in a controller broke a core spec. Is anyone able to re-run that failing test?

@tmtrademarked
Copy link
Contributor Author

It seems like the tests are green - anyone able to review?

@waiting-for-dev
Copy link
Contributor

Seems legit, but I don't have enough background to confirm we aren't missing something. Thoughts, @kennyadsl?

Copy link
Member

@kennyadsl kennyadsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes total sense. Thanks @tmtrademarked!

@waiting-for-dev waiting-for-dev merged commit 9e65c92 into solidusio:master Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants