Skip to content

Scope user cart lookups to the current channel (#2607) - #2659

Open
wakqasahmed wants to merge 4 commits into
lunarphp:1.xfrom
wakqasahmed:fix/cart-channel-scoping
Open

Scope user cart lookups to the current channel (#2607)#2659
wakqasahmed wants to merge 4 commits into
lunarphp:1.xfrom
wakqasahmed:fix/cart-channel-scoping

Conversation

@wakqasahmed

Copy link
Copy Markdown
Contributor

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.

CartSessionManager now 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. AssociateUser got 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 covering AssociateUser across 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.

wakqasahmed and others added 3 commits August 27, 2026 16:21
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.
@github-actions github-actions Bot added the 1.x label Aug 27, 2026
@glennjacobs
glennjacobs marked this pull request as draft August 27, 2026 13:29
@glennjacobs
glennjacobs marked this pull request as ready for review August 27, 2026 13:29
@github-actions github-actions Bot added the high label Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Cart lookups by user aren't scoped to the current channel

3 participants