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 Order#restart_checkout_flow for empty orders #5330

Conversation

waiting-for-dev
Copy link
Contributor

@waiting-for-dev waiting-for-dev commented Aug 11, 2023

Summary

#4369 introduced a regression where when calling Spree::Order#restart_checkout_flow on an empty order, an error would be added to the order. That happened when calling #next and the validation failed because no line items were present.

We restore the previous behavior where we only try going to the "address" state if the order has line items.

Context: That regression was a problem on the GraphQL extension, as #restart_checkout_flow was called to bring the order back to the cart state. It was confusing in case of a user requesting the errors node. See https://github.com/solidusio/solidus_graphql_api/blame/main/lib/solidus_graphql_api/mutations/checkout/empty_cart.rb#L13-L15.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@waiting-for-dev waiting-for-dev requested a review from a team as a code owner August 11, 2023 09:30
@github-actions github-actions bot added the changelog:solidus_core Changes to the solidus_core gem label Aug 11, 2023
@waiting-for-dev waiting-for-dev self-assigned this Aug 11, 2023
@waiting-for-dev waiting-for-dev added type:bug Error, flaw or fault backport-v3.2 backport-v3.3 Backport this pull-request to v3.3 backport-v3.4 Backport this pull-request to v3.4 backport-v4.0 Backport this pull-request to v4.0 backport-v4.1 Backport this pull-request to v4.1 labels Aug 11, 2023
waiting-for-dev added a commit to solidusio/solidus_graphql_api that referenced this pull request Aug 11, 2023
We are resetting the order flow after emptying an order to get the
"cart" state back. However, there's an upstream bug where an error is
added in that scenario.

See solidusio/solidus#5330

[skip ci]
waiting-for-dev added a commit to solidusio/solidus_graphql_api that referenced this pull request Aug 11, 2023
We are resetting the order flow after emptying an order to get the
"cart" state back. However, there's an upstream bug where an error is
added in that scenario.

See solidusio/solidus#5330

[skip ci]
Copy link
Member

@spaghetticode spaghetticode left a comment

Choose a reason for hiding this comment

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

@waiting-for-dev thanks for the fix, looks good to me, and I left a suggestion for the spec, please let me know if it works for you.

core/spec/models/spree/order_spec.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@rainerdema rainerdema left a comment

Choose a reason for hiding this comment

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

👍

solidusio#4369 introduced a regression
where when calling `Spree::Order#restart_checkout_flow` on an empty
order, an error would be added to the order. That happened when calling
`#next` and the validation failed because no line items were present.

We restore the previous behavior where we only try going to the
`"address"` state if the order has line items.
@github-actions
Copy link

💚 All backports created successfully

Status Branch Result
v3.2
v3.3
v3.4
v4.0
v4.1

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

waiting-for-dev added a commit to solidusio/solidus_graphql_api that referenced this pull request Aug 14, 2023
We are resetting the order flow after emptying an order to get the
"cart" state back. However, there's an upstream bug where an error is
added in that scenario.

See solidusio/solidus#5330

[skip ci]
@elia elia changed the title Fix error added when resetting order flow on an empty order Fix Order#restart_checkout_flow for empty orders Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v3.3 Backport this pull-request to v3.3 backport-v3.4 Backport this pull-request to v3.4 backport-v4.0 Backport this pull-request to v4.0 backport-v4.1 Backport this pull-request to v4.1 changelog:solidus_core Changes to the solidus_core gem type:bug Error, flaw or fault
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants