Problem/Motivation

There are two organizations, like current store vs order store: the current one (resolver chain, per request) and the order's one (the organization_id field). Once orders have the field, nothing copies the current organization onto them. Parent: #3638816: [META] Commerce 4.x roadmap.

Proposed resolution

  • CartProvider::createCart() sets the organization resolved for the account and store, the same moment the store is set. setOrganization() throws if it is not of the site's target type. Whether a cart gets an organization at all is up to the resolver (none in core), so commerce_b2b decides.
  • OrderAssignment::assign() sets the organization resolved for the new customer and the order's store. This covers anonymous carts assigned on login (commerce_cart's user_login hook calls assignMultiple()), and admin reassignment gets the same rule.
  • Once the order exists, the order organization wins: OrderRefresh, processors, tax and access use it, never the current one.
  • uid keeps its meaning (the person who buys); order emails still go to the customer email.

Remaining tasks

  • Kernel tests with a test organization resolver: cart creation, login assignment, admin reassignment, no resolver means no organization.

Issue fork commerce-3641081

Command icon Show commands

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

jsacksick created an issue. See original summary.

  • jsacksick committed 4f6379e3 on 4.x
    feat: #3641081 Set the organization when carts are created and orders...
jsacksick’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.