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

[Core] Maintain previous cart after logging in #6904

Merged

Conversation

Zales0123
Copy link
Member

Q A
Bug fix? yes
New feature? yes
BC breaks? no
Related tickets
License MIT

This PR solves two issues:

  • when we had some products in the cart (or even some checkout steps already passed) and logged out, cart was still available for the not logged in user
  • after logging out with unfinished order, it was impossible to continue shopping after session expired/on different browser etc.

@Zales0123 Zales0123 force-pushed the maintain-previous-cart-after-logging-in branch 4 times, most recently from 89f7677 to 24780d2 Compare November 29, 2016 08:46
try {
$channel = $this->channelContext->getChannel();
} catch (ChannelNotFoundException $exception) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

throw new CartNotFoundException?

throw new CartNotFoundException('Sylius was not able to find the cart, as there is no logged in user.');
}

$cart = $this->orderRepository->findLatestCartByChannelAndCustomer($channel, $customer);
Copy link
Contributor

Choose a reason for hiding this comment

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

We should return only one cart. Can't we use getOneOrNullResult?

Copy link
Member Author

@Zales0123 Zales0123 Nov 29, 2016

Choose a reason for hiding this comment

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

Well, sure we can! 🐃

@Zales0123 Zales0123 force-pushed the maintain-previous-cart-after-logging-in branch from 5f322f0 to 98c4e53 Compare November 29, 2016 15:03
@pjedrzejewski pjedrzejewski merged commit a4c3f49 into Sylius:master Nov 29, 2016
@pjedrzejewski
Copy link
Member

Thank you Mateusz!

@Zales0123 Zales0123 deleted the maintain-previous-cart-after-logging-in branch November 30, 2016 13:28
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