Skip to content

Conversation

@vencious
Copy link

Summary

Fixes an issue where an authenticated user could have a previously-merged cart selected during cart resolution, leading to unexpected “missing” items after login/logout cycles. Also makes the Cart::active() scope grouping explicit for readability/intent.

Why is this needed?

When a user has carts that were merged into a newer cart, selecting ->active()->first() may return a merged/source cart depending on ordering and query shape. We now prefer the latest unmerged active cart.

Changes

  • In CartSessionManager, prefer the latest unmerged active cart when resolving an authenticated user's cart.
  • Make the Cart::active() scope grouping explicit (readability/intent).
  • Add regression tests covering merged cart selection and user-context active cart querying.

Fixes #2397

@alecritson
Copy link
Collaborator

Thanks @vencious Can you quickly update the tests so the comments are in English otherwise we're unsure of what's happening :)

@vencious
Copy link
Author

vencious commented Feb 3, 2026

Sorry about that — I’ve updated and pushed: removed the non-English comments and clarified the test intent via naming/assertions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Potential bug in scopeActive and CartSessionManager login logic

2 participants