Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
B2B Company Self-Registration & Activation Mechanisms
Status: Draft — design finalized 2026-08-30, nothing built Target: Spree 6.0 (retargeted 2026-08-30, sequencing review — originally 6.1 on the additive test, pulled forward because the Enterprise onboarding product must ship on 6.0 GA and these mechanisms are its only missing input; every piece remains additive and small) Depends on: B2B Companies & Catalogs (6.0-b2b-companies-and-catalogs.md), B2B Quantity Rules (6.0-b2b-quantity-rules.md — catalog terms), gated storefront access (shipped 5.6) Author: Damian + Claude Last updated: 2026-08-30
Summary
The B2B flow has no front door: there is no storefront way for a business to
register itself (/store/companies is show + update only), and no way for a
merchant to gate pricing on having a commercial relationship. This plan adds
the open-source mechanisms: storefront company self-registration, an
approval_required storefront access posture ("prices and checkout require
an active company standing"), a machine-readable pricing_access reason
code beside hidden prices, and a registered company activation policy
consulted everywhere a company's commercial standing matters. In OSS the
default policy activates every company, so registration is instant and the
posture means "company members only" — a useful trade-store feature on its
own. The merchant-approval flow (pending applications, verification
requirements, review queue, request-more-information) is the Enterprise
onboarding product built on these mechanisms (tier split decided 2026-08-30
— see ee/docs/plans/b2b-company-onboarding.md; no
competitor ships approval in open source, and everyone who has it charges
for it).
Key Decisions (do not deviate without discussion)
- Registration is OSS and companies are born active (2026-08-30, tier
split):
POST /api/v3/store/companieslets an authenticated customer — including an existing retail customer — create a root company (kindcompany) plus their own membership in one call; a guest storefront chainsPOST /store/customersfirst so the UX is one flow. Free-form registration answers land inmetadata['registration']. Rate-limited like customer registration. Core publishescompany.registeredand sends no mail. Spree::Companies::ActivationPolicyis the single seam (2026-08-30): a dependency-registered class (Spree::Dependencies.company_activation_policy_class, mirroringstorefront_access_policy_class) answeringactive?(company)andpricing_access_code(user:, store:). The OSS default answers active for every company. Every place that resolves a company for visibility, pricing, or checkout consults it:Catalog.for_company, bothsole_standing_companyimplementations (Purchase::CompanyandProducts::ForContext— mirrored, by existing constraint), the cartcompany_idwrite validation, and theapproval_requiredposture. Subtree semantics (a suspended parent covering its divisions) are the policy implementation's job, which is why the seam takes the node.- No status column on
spree_companiesin OSS. The lifecycle (pending / review / approved / rejected / suspended, the requirements checklist, the queue) lives on an Enterprise-owned application record referencing the company — OSS tables never reference Enterprise models, and OSS behavior flows entirely through the policy. This supersedes the same-day draft that put five statuses on Company. - A fourth storefront access posture:
approval_required(2026-08-30): besidepublic | prices_hidden | login_required. Guests and authenticated buyers without a standing over a policy-active company browse the catalog with prices null and checkout refused;prices_hiddenkeeps its shipped guest-only semantics untouched. Under the default policy this reads as "prices for company members only"; under the Enterprise policy it becomes "prices for approved companies only". - A reason code travels with hidden prices. Serializers today null
prices with no explanation. The gating concern computes
pricing_access—null(visible) |login_required|company_required| codes the registered policy supplies (Enterprise addsapproval_pending) — surfaced wherever prices are nulled, following the checkout-requirementscode:convention; the channel serializer also exposesstorefront_access. Storefronts render "Awaiting approval" / "Register your business" from the code, never by interpreting bare nulls. - Checkout is gated by a requirement, standing is not gated at all. A
new checkout requirement (
company_activation_requiredcode) refuses customer-initiated completion onapproval_requiredchannels without a policy-active cart company — same shape asguest_checkout_not_allowed. Self-service standing (standing_for?,company_standing,Storefront::AccessPolicy) never consults the policy: members of an inactive company keep their company pages, address book, members and invitations — that is the pre-approval workspace the Enterprise flow needs. - Customer-group membership is never an activation mechanism — groups price (catalog assignments), the policy activates. The seeded Wholesale group's "approval primitive" comment is retired with this plan.
Design Details
Registration
Companies::Register workflow (hooks :validate, :after_register):
builds the root node + membership in one transaction, stamps
metadata['registration'], publishes company.registered. The validate
hook is the screening point (domain rules, fraud checks — host or
Enterprise handlers); it does NOT fire on CompanyInvitations::Accept
(joining an existing company is not founding one), while Customers::Create
hooks keep firing on both paths as today. Controller:
POST /store/companies (authenticated, rate-limited); the account
companies index and company serializer are unchanged except where the
policy adds codes.
One open guard: at most one self-registered root per customer per store
(validation in Register) — keeps duplicate applications out without a
uniqueness constraint on names.
Activation policy
class Spree::Companies::ActivationPolicy
# Whether the company may act commercially (catalogs, pricing, checkout).
def active?(_company) = true
# The pricing_access code for a viewer lacking prices, or nil.
def pricing_access_code(user:, store:)
return 'login_required' if user.blank?
'company_required' unless user.company_standing(store: store).any? { |c| active?(c) }
end
end
Consulted (all existing call sites, no new resolution paths):
Catalog.for_company (assignments of active companies only), both
sole_standing_companys (memberships of active companies only),
customer_has_standing_over_company (cart write gains a distinct
:not_active error), the posture + checkout requirement. Completed orders
answer from their stamped company_id, untouched.
Gating
Channel::Gating::STOREFRONT_ACCESS += ['approval_required']; store-level
fallback validation updated. hide_prices? becomes posture-aware; the
pricing_access code rides serializer_params beside hide_prices and is
exposed on the payloads that null prices.
Migration Path
ActivationPolicy+ dependency registration + the resolution call-site consultations (behavior-neutral under the default policy — specs assert that explicitly; shared-concern battery runs against Cart AND Order).approval_requiredposture +pricing_accesscode + checkout requirement + serializer exposure.Companies::Register+POST /store/companies+ SDK types + docs.- Storefront reference: registration page + code-driven price labels.
- Retire the Wholesale-group seed comment.
Nothing to migrate; every change is additive and inert until a merchant selects the posture or registers a policy.
Constraints on Current Work
- Any new code resolving a company for visibility, pricing, or checkout
consults the activation policy — and the two
sole_standing_companyimplementations stay mirrored. - Never approval-gate self-service standing.
- New prices-hidden surfaces carry the
pricing_accesscode — no bare nulls. - No status/approval columns on
spree_companies— lifecycle state is the Enterprise application record's; OSS asks the policy. - Don't build interim approval primitives beside this mechanism (customer-group membership, boolean flags); anything approval-shaped waits for this mechanism.
Open Questions
None for the OSS scope. The flow-side questions (statuses, requirements, queue) belong to the Enterprise plan.
References
- Merchant feedback, 2026-08 (register → browse "awaiting approval" → verify → assign the agreement → ordering enabled).
- Tier split + rationale:
docs/plans/decisions.md2026-08-30;ee/docs/plans/b2b-company-onboarding.md(the flow). docs/plans/6.0-b2b-companies-and-catalogs.md— tree, memberships, self-service,Catalog.for_context.- Gating:
spree/core/app/models/spree/channel/gating.rb,spree/api/app/controllers/concerns/spree/api/v3/storefront_gating.rb. - Registration hook precedent:
spree/core/app/workflows/spree/customers/create.rb.