Fixed
Project:
Commerce Core
Version:
4.x-dev
Component:
Commerce
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
23 Nov 2026 at 20:12 UTC
Updated:
24 Nov 2026 at 12:01 UTC
Jump to comment: Most recent
A user buying for several organizations needs one cart per organization, and switching organization must change which carts are returned. Today CartProvider caches carts per uid and filters by store only. Parent: #3638816: [META] Commerce 4.x roadmap.
getCart(), getCartId(), getCarts(), getCartIds()) is scoped to the organization the account acts for in the store: personal (no organization) returns carts without one. createCart() sets that same organization on the new cart, and its duplicate cart check is per organization.getCarts() and getCartIds() resolve the organization per cart's store (once per store), since the organization can differ per store (#3639236: Add OrganizationInterface and an optional organization on the Context).CurrentOrganization: resolved once per request, consistently with the organization cache context and the pricing context. Other accounts and stores go through the resolver chain. Anything changing which organization a user acts for mid-request dispatches OrganizationEvents::SWITCH, which resets CurrentOrganization.isEligibleCart() also requires the cart's organization, if any, to be published.cart cache context derives from getCartIds(), so its value follows the current organization.CartProviderInterface keeps its signatures: no organization parameter, since NULL would mean both "resolve it" and "personal cart". Code needing another organization's cart creates the order and calls setOrganization(); code listing carts across organizations queries orders directly.CartOrganizationTest.Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
jsacksick commentedComment #4
jsacksick commentedComment #6
jsacksick commented