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

[4.x]: Cart gets overwritten with previous cart when login, even when already other items in cart #3512

Closed
WHITE-developer opened this issue May 22, 2024 · 3 comments
Labels
bug commerce4 Issues related to Commerce v4 Craft Commerce

Comments

@WHITE-developer
Copy link

What happened?

Description

Don't know if the logic for restoring a previous cart is correct.
For example: you have items in your cart when you were logged in. If you are logged out and are going to shop at a later time and add (other) items in you cart, when you log in, you're current cart is being replaced with your old cart when you were logged in before.

Don't think this is the best logic. Because you want to shop the items you have in your cart at that moment, not the ones from an earlier time. Best would be to merge the carts? Or at least get the last cart you have added items to.

Steps to reproduce

  1. Without logging in, add some items to your shopping cart
  2. Log into an existing user account that does have a previous saved cart

Expected behavior

You would expect the item added in 1. to be in the cart.

Actual behavior

Cart has only the item from previous saved cart.

Craft CMS version

4.9.1

Craft Commerce version

4.6.0

PHP version

8.3.4

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

@WHITE-developer WHITE-developer added bug commerce4 Issues related to Commerce v4 Craft Commerce labels May 22, 2024
@nfourtythree
Copy link
Contributor

Hi @WHITE-developer

Thanks for reporting, we have pushed a fix for this which will be included in the next release of Commerce 4.x.

For reference, the priority order for restoring carts is as follows:

  1. Give the cart in session to the current customer if they are logging in and there are items in the cart
  2. Restore a previous cart belonging to the customer that has line items
  3. Restore any other previous cart for the customer

Thanks!

@nfourtythree
Copy link
Contributor

Commerce 4.6.1 and 5.0.7 have been released with this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug commerce4 Issues related to Commerce v4 Craft Commerce
Projects
None yet
Development

No branches or pull requests

2 participants