Scope user cart lookups to the current channel (#2607) - #2659
Open
wakqasahmed wants to merge 4 commits into
Open
Scope user cart lookups to the current channel (#2607)#2659wakqasahmed wants to merge 4 commits into
wakqasahmed wants to merge 4 commits into
Conversation
Resolving a cart from the session id no longer returns one that belongs to a different channel - the stale session key is forgotten and the manager falls through to creating a new cart, which also covers guest carts. AssociateUser now scopes its merge/override lookups to the current channel too, so logging in on one channel can't pull in or override a cart from another.
glennjacobs
marked this pull request as draft
August 27, 2026 13:29
glennjacobs
marked this pull request as ready for review
August 27, 2026 13:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carts weren't scoped to the current channel when resolved from the session, so a cart created on one channel could still surface (and get reused or merged into) after switching to a different channel. Closes #2607.
CartSessionManagernow checks the channel on a session-resolved cart and forgets the session key if it doesn't match the current one, falling through to create a fresh cart instead — this covers guest carts too, since it doesn't depend on there being a user relation to scope through.AssociateUsergot the same channel check on its merge/override lookups, since login was another path where a channel-B guest cart could end up attached to a channel-A user cart.Added tests that model a fresh request (no cart pre-loaded, no
current()call priming state) resolving a session-held cart under a different channel, and a couple coveringAssociateUseracross channels. Couldn't run the suite here (no PHP in this environment) so I traced through both call paths by hand against the tests to check they'd actually fail without the fix.