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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Let a seller choose a product type and delivery profile (#14541)
Damian Legawiec97102973030a
diff --git a/CLAUDE.md b/CLAUDE.mdindex 2aea10d730..d63299d021 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -22,7 +22,7 @@ Active plans (6.0 target, work pending):- `6.0-b2b-customer-po-numbers.md` — Buyer PO reference on orders (design finalized 2026-08-30): `po_number` string on cart + order (industry-exact name; copied at completion; staff may correct post-placement as a plain write — it is not money) + optional **`po_document`** private-storage attachment (direct upload, spoofing-protected, blob re-attached to the order at completion — no competitor has order-native PO upload) + **`po_number_required` boolean on `Spree::Company`** (per-company is the market's control granularity; deliberately NOT a catalog term — buyer process ≠ agreement; not governance, so the OSS-companies constraint holds) enforced as a `Carts::Complete` validation (`code: 'po_number_required'`, staff-created orders skip); `po_number` ransackable + the dashboard order search matches number OR PO; surfaced on admin order page, customer order history, confirmation email, and every future order-facing document. The Enterprise quote plan's `customer_reference`/attachment were replaced by these order fields (amended 2026-08-30). **Constraints now:** never model the buyer PO as a payment method or couple it to tender choice; `po_number` (buyer reference) and `Spree::PurchaseOrder` (merchant procurement, inventory-operations) never mix — no shared endpoints/serializers/vocabulary; new order-facing documents/emails render `po_number` when present; post-placement PO edits never route through the order-change substrate.- `6.0-draft-order-negotiation-mechanics.md` — Manual line pricing on draft orders + cart→draft copy (design finalized 2026-08-30; **implemented in full 2026-08-30**, including `Orders::CreateFromCart` and the payment-terms plan's payment-number fixes riding along; OSS half of the quotes tier split — the quote product is Enterprise `b2b-quotes.md`). **6.0:** admin item endpoints accept `price` on incomplete orders, stamping **`price_source: 'manual'`** — the provenance column's first readers land as guards (`Carts::PriceItems` skips manual rows, `LineItem#should_update_price?` false for them) so quantity edits stop silently re-pricing negotiated lines; `'manual'` is a reserved key no pricing provider may register; `price: null` = explicit revert; `price_source` exposed admin-only, never on store serializers; plus fixes — `Orders::Create` stamps `created_by`, and the `payment_pending` docstring corrected (completion yields `payment_status: 'none'`, not `'balance_due'`; a distinct unpaid value is the wholesale-deposit rollup work's call). **6.0, late (retargeted 2026-08-30 so Enterprise quotes need nothing beyond 6.0 GA):** `Spree::Orders::CreateFromCart` copies a customer cart into a fresh draft order leaving the cart untouched (not the completion copier — no money re-pointing, no `cart_id` claim). **Constraints now:** nothing reprices a `manual` line except the explicit revert and new repricing call sites must honor the guard; no post-placement price overrides (fees/discounts until the order-change substrate's `update_item_price` kind); quote lifecycle/statuses/expiry/customer surfaces never grow here (Enterprise plan).- `6.0-b2b-company-self-registration.md` — B2B front door, OSS mechanisms only (design finalized 2026-08-30; **retargeted 6.1 → 6.0 the same day**: the Enterprise onboarding product must ship on 6.0 GA and these small additive mechanisms are its only missing input): `POST /store/companies` (authenticated customer — including an existing retail customer — founds a root company + membership in one call; companies **born active**; registration answers → `metadata['registration']`; `company.registered` event, core sends no mail), fourth storefront access posture **`approval_required`** (prices + checkout need a standing over an active company; `prices_hidden` guest-only semantics untouched), **`pricing_access`** reason code beside every nulled price (`login_required` | `company_required` | policy-supplied), and **`Spree::Companies::ActivationPolicy`** (dependency-registered, default: every company active) consulted by `Catalog.for_company`, BOTH `sole_standing_company`s, cart `company_id` writes and the posture. The approval FLOW (pending lifecycle, requirements checklist mirroring seller onboarding, queue, request-more-info) is **Enterprise** (`spree-enterprise-v2/docs/plans/b2b-company-onboarding.md`) via the policy — no competitor ships approval OSS. **Constraints now:** new company-resolving code (visibility/pricing/checkout) consults the policy and the two `sole_standing_company`s stay mirrored; self-service standing never approval-gated; no status columns on `spree_companies`; no interim approval primitives beside it (customer-group membership prices, never approves); prices-hidden surfaces always carry the `pricing_access` code.-- `6.0-multi-vendor-marketplace.md` — Open-source the marketplace core (Seller, OrderGroup-based order splitting, commission engine with EU commission taxation, `SellerTransfer`/`SellerPayout` ledger + pluggable `PayoutProvider`) per spree/spree#13323. 6.0 headline feature; rebuilds the legacy Enterprise multi-seller module as native models on the Cart/Order split. Basic Stripe Connect payouts (Express onboarding + on-fulfillment transfers) ship OSS in the monorepo, alongside the Stripe core gateway pulled in from the standalone `spree_stripe` repo (payment-sessions classes only, likely `spree/core` — decisions.md 2026-07-15); Enterprise keeps refund clawbacks/netting, reconciliation, KYC ops, DAC7 payout reports, facilitator taxes + Shopify/WooCommerce seller apps. **Seller principal + surface (Decision 10, 2026-08-15):** seller staff are `Spree.admin_user_class` (no `SellerUser`; membership by `RoleUser.resource_type`, never `store_id`) on a dedicated `/api/v3/seller` branch — own `seller_api` JWT audience, own `Spree.seller_authentication_strategies` + `/seller/auth/*`, audience-stamped refresh tokens, every endpoint scope-fetched through `current_seller` (store derived from the seller); sellers never call the Admin API and admin controllers are never subclassed into the seller namespace.+- `6.0-multi-vendor-marketplace.md` — Open-source the marketplace core (Seller, OrderGroup-based order splitting, commission engine with EU commission taxation, `SellerTransfer`/`SellerPayout` ledger + pluggable `PayoutProvider`) per spree/spree#13323. 6.0 headline feature; rebuilds the legacy Enterprise multi-seller module as native models on the Cart/Order split. Basic Stripe Connect payouts (Express onboarding + on-fulfillment transfers) ship OSS in the monorepo, alongside the Stripe core gateway pulled in from the standalone `spree_stripe` repo (payment-sessions classes only, likely `spree/core` — decisions.md 2026-07-15); Enterprise keeps refund clawbacks/netting, reconciliation, KYC ops, DAC7 payout reports, facilitator taxes + Shopify/WooCommerce seller apps. **Seller principal + surface (Decision 10, 2026-08-15):** seller staff are `Spree.admin_user_class` (no `SellerUser`; membership by `RoleUser.resource_type`, never `store_id`) on a dedicated `/api/v3/seller` branch — own `seller_api` JWT audience, own `Spree.seller_authentication_strategies` + `/seller/auth/*`, audience-stamped refresh tokens, every endpoint scope-fetched through `current_seller` (store derived from the seller); sellers never call the Admin API and admin controllers are never subclassed into the seller namespace. **Seller delivery (Decision 13, 2026-09-01 — design only):** delivery profiles, zones and origin groups stay operator-owned (never a `seller_id`; a seller assigns a profile and a product type to their product — shipped 2026-09-01), `DeliveryMethod` gains a nullable `seller_id` + `available_to_sellers`, a seller's package (its stock location's seller) is offered its own methods plus shared marketplace ones — decided in `Stock::Estimator#filter_delivery_methods` and nowhere else; seller methods are internal-rate/manual-fulfillment only (carrier accounts stay the operator's), `DeliveryOriginGroup#covers_location?` is true for seller locations, and `delivery_methods` becomes its own seller-grantable catalog resource.- `6.0-seller-onboarding-requirements.md` — Operator-configured seller onboarding checklist (design finalized 2026-08-18): `Spree::SellerRequirement` = store-scoped STI rows (`acts_as_list`, `active`/`required`, per-kind preferences) over developer-written kinds registered in `Spree.seller_requirements` (same `registers_subclasses_via` + `PreferenceSchema` types-discovery pattern as `DeliveryMethodRule`); three completion families — computed from seller data, attested by the seller, verified by the operator/a provider — the last two through one persisted `Spree::SellerRequirementSubmission` (`pending | accepted | rejected | waived`, optional private file attachment; generic `Attestation`/`OperatorReview`/`Document` kinds); evaluated on read by `Spree::Sellers::Requirements` into `SellerRequirementStatus` value objects (`complete | incomplete | pending | rejected`), never denormalized onto sellers. **Exactly two enforcement points:** `Sellers::SubmitForReview` (new; `onboarding → ready_for_review`, `auto_approve_sellers` store preference chains into Approve) and `Sellers::Approve` (refuses unless `override_requirements: true`, recorded on the event); post-approval drift is flagged, never enforced (`sellable?` unchanged, payouts gated by the provider). `Sellers::StartOnboarding` on invitation acceptance, `Sellers::ReopenOnboarding` for send-back. Admin API `/admin/seller_requirements` (+`/types`) under `write_sellers`, `include=onboarding` on sellers, submission accept/reject/waive; seller branch `GET /seller/onboarding`, `POST /seller/onboarding/submit_for_review`, `POST /seller/requirements/:id/submissions`. Defaults provisioned per store (`provision_defaults` + seed); empty = nothing required. **Constraints now:** no `Seller#onboarding_completed?`-style methods or step-done columns on `spree_sellers` — new admission checks are kinds (or `validate` hooks on the seller workflows), per-seller check state is a submission; nothing but the two workflows reads the checklist as a gate.- `6.0-store-policies.md` — Store + seller policy documents (**implemented 2026-08-27**): the missing back-office surface for `Spree::Policy` — Admin API v3 CRUD (five endpoints, `settings` scope, writes take the plain `body`, sanitized on save) + dashboard Settings → Policies page (MediaRichTextEditor, delete confirm, no reorder) — and extend ownership to sellers: `Seller has_many :policies, as: :owner` (no seeding — stores keep their four seeded defaults, sellers start empty), seller-branch CRUD (`Seller::ResourceController` derives the scope; `scoped_resource :seller_profile`), seller panel Settings → Policies page (plain `RichTextEditor` — media embedding is admin-only), new computed `Spree::SellerRequirements::Policy` kind (**one row per document** — `allow_multiple?`, so the row's own `name` is the policy required and two required policies are two separately-tracked lines; matched case/space-insensitively + non-blank body; no preferences; not in `DEFAULT_KINDS`; status exposes `required_policy_name`), store seller serializer exposes policies behind `?expand=policies`, store policy serializer gains `updated_at` (recorded exception to the no-timestamps rule). **Constraints now:** the leaky `Policy.for_store` override is deleted and must never come back — read policies through the owner association (`store.policies` / `seller.policies`), never a class-level scope (the deletion is a prerequisite for seller policies: the override leaked non-store-owned policies into every store's public endpoint); no `kind` enum, `position` column or fixed policy vocabulary (open set is the design); rich-text writes go to the plain attribute — `body_html` is a read-only reader and the `*_html`-on-write line in `6.0-admin-api.md`/`6.0-rich-text-descriptions.md` was wrong and is corrected; nothing persists checkout consent (that's `5.4-6.0-eu-legal-compliance.md` scope); storefront policy links stay hardcoded until a `store/info`-style endpoint embeds the policy list.- `6.0-cart-order-split.md` — Cart/Order model separation, dual-FK owner everywhere (`cart_id`/`order_id` exactly-one, `#owner` as method — NOT polymorphic), idempotent copy-on-completion (`Order#cart_id` unique, order-before-payment), Order state machine removed (Checkout::Requirements for steps; payment/fulfillment statuses derived-then-persisted via one recompute service). **Shipped to 6-0-dev (feature/6-0-core-rewrite Waves 1+5):** Cart owns checkout end to end, machine + `spree_orders.state` gone, `Carts::Complete` three-phase pipeline live, `Orders::UpdateStatuses` sole status writer; only Wave 7 data migration (incomplete orders → carts) remainsdiff --git a/docs/api-reference/seller-api/introduction.mdx b/docs/api-reference/seller-api/introduction.mdxindex 0f2b22fc23..a0ccd5f6ae 100644--- a/docs/api-reference/seller-api/introduction.mdx+++ b/docs/api-reference/seller-api/introduction.mdx@@ -67,7 +67,7 @@ const { data: products } = await client.products.list({ limit: 25 })<CardGroup cols={2}><Card title="Catalog" icon="tag">- List, create, update, and delete the products they own outright.+ List, create, update, and delete the products they own outright, picking a product type and a delivery profile from the marketplace's lists.</Card><Card title="Profile" icon="store">Maintain presentation, contact details, addresses, and tax registration.@@ -93,6 +93,6 @@ Some fields are readable but never writable, because they belong to the marketpl- **`status`** — the seller lifecycle belongs to the operator's workflows. A seller says they are ready via `POST /api/v3/seller/onboarding/submit_for_review`; the operator decides.- **`slug`** — renaming a storefront address would break every link pointing at it.- **Settlement and commission terms** — what the marketplace charges is the marketplace's to set.-- **Tax category, delivery profile, and promotionability on products** — marketplace-wide merchandising settings.+- **Tax category and promotionability on products** — marketplace-wide merchandising settings. A product's type and delivery profile, by contrast, are the seller's to assign — the marketplace defines the list, the seller picks from it.Sending these fields is not an error; they are simply ignored.diff --git a/docs/api-reference/seller.yaml b/docs/api-reference/seller.yamlindex 37fffe81c3..104454fada 100644--- a/docs/api-reference/seller.yaml+++ b/docs/api-reference/seller.yaml@@ -304,7 +304,7 @@ paths:avatar_url:sellers:- id: sel_UkLWZg9DAJ- name: Seller 21+ name: Seller 22status: approvedschema:"$ref": "#/components/schemas/AuthResponse"@@ -420,7 +420,7 @@ paths:avatar_url:sellers:- id: sel_UkLWZg9DAJ- name: Seller 42+ name: Seller 43status: approvedschema:"$ref": "#/components/schemas/AuthResponse"@@ -489,8 +489,8 @@ paths:avatar_url:sellers:- id: sel_UkLWZg9DAJ- name: Seller 30- slug: seller-30+ name: Seller 31+ slug: seller-31status: approvedpermissions:- allow: true@@ -12293,6 +12293,74 @@ paths:required:- data- meta+ "/api/v3/seller/delivery_profiles":+ get:+ summary: List delivery profiles+ tags:+ - Delivery Profiles+ security:+ - bearer_auth: []+ description: |+ The marketplace's delivery profiles — what kind of goods a product is+ (parcel, digital, pallet), which decides how it can be shipped.++ Read only. A seller assigns one to a product as `delivery_profile_id`;+ the profiles themselves, and the zones and methods behind them, are the+ marketplace's. A product created without one lands on the profile+ marked `default`.+ parameters:+ - name: X-Spree-Seller-Id+ in: header+ required: true+ schema:+ type: string+ - name: page+ in: query+ required: false+ description: Page number+ schema:+ type: integer+ - name: limit+ in: query+ required: false+ description: Records per page (max 100)+ schema:+ type: integer+ responses:+ '200':+ description: delivery profiles listed+ content:+ application/json:+ example:+ data:+ - id: fp_UkLWZg9DAJ+ name: General+ default: true+ - id: fp_gbHJdmfrXB+ name: Oversized+ default: false+ meta:+ page: 1+ limit: 25+ count: 2+ pages: 1+ from: 1+ to: 2+ in: 2+ previous:+ next:+ schema:+ type: object+ properties:+ data:+ type: array+ items:+ "$ref": "#/components/schemas/DeliveryProfile"+ meta:+ "$ref": "#/components/schemas/PaginationMeta"+ required:+ - data+ - meta"/api/v3/seller/onboarding":get:summary: Get onboarding checklist@@ -12724,6 +12792,100 @@ paths:responses:'204':description: policy deleted+ "/api/v3/seller/product_types":+ get:+ summary: List product types+ tags:+ - Product Types+ security:+ - bearer_auth: []+ description: |+ The product types a seller may list a product against.++ Read only. A type is the template that hands a product its option types+ and its delivery profile, so a seller picks one when listing; defining+ types is the marketplace's. Send the chosen `id` as `product_type_id`+ on the product.+ parameters:+ - name: X-Spree-Seller-Id+ in: header+ required: true+ schema:+ type: string+ - name: page+ in: query+ required: false+ description: Page number+ schema:+ type: integer+ - name: limit+ in: query+ required: false+ description: Records per page (max 100)+ schema:+ type: integer+ responses:+ '200':+ description: product types listed+ content:+ application/json:+ example:+ data:+ - id: pt_UkLWZg9DAJ+ name: Apparel+ option_type_labels: []+ meta:+ page: 1+ limit: 25+ count: 1+ pages: 1+ from: 1+ to: 1+ in: 1+ previous:+ next:+ schema:+ type: object+ properties:+ data:+ type: array+ items:+ "$ref": "#/components/schemas/ProductType"+ meta:+ "$ref": "#/components/schemas/PaginationMeta"+ required:+ - data+ - meta+ "/api/v3/seller/product_types/{id}":+ get:+ summary: Get a product type+ tags:+ - Product Types+ security:+ - bearer_auth: []+ parameters:+ - name: X-Spree-Seller-Id+ in: header+ required: true+ schema:+ type: string+ - name: id+ in: path+ required: true+ description: Product type ID+ schema:+ type: string+ responses:+ '200':+ description: product type found+ content:+ application/json:+ example:+ id: pt_UkLWZg9DAJ+ name: Apparel+ option_type_labels: []+ schema:+ "$ref": "#/components/schemas/ProductType""/api/v3/seller/products":get:summary: List products@@ -12769,8 +12931,8 @@ paths:example:data:- id: prod_UkLWZg9DAJ- name: Product 1423250- slug: product-1423250+ name: Product 1433250+ slug: product-1433250meta_title:meta_description:meta_keywords:@@ -12819,6 +12981,8 @@ paths:metadata: {}created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'+ product_type_id:+ delivery_profile_id: fp_UkLWZg9DAJmeta:page: 1limit: 25@@ -12904,6 +13068,8 @@ paths:metadata: {}created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'+ product_type_id:+ delivery_profile_id: fp_UkLWZg9DAJschema:"$ref": "#/components/schemas/Product"'422':@@ -13009,8 +13175,8 @@ paths:application/json:example:id: prod_UkLWZg9DAJ- name: Product 1456710- slug: product-1456710+ name: Product 1466710+ slug: product-1466710meta_title:meta_description:meta_keywords:@@ -13054,6 +13220,8 @@ paths:metadata: {}created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'+ product_type_id:+ delivery_profile_id: fp_UkLWZg9DAJschema:"$ref": "#/components/schemas/Product"'404':@@ -13087,7 +13255,7 @@ paths:example:id: prod_UkLWZg9DAJname: Hand-thrown mug, large- slug: product-1488212+ slug: product-1498212meta_title:meta_description:meta_keywords:@@ -13127,6 +13295,8 @@ paths:metadata: {}created_at: '2026-01-15T12:00:00.000Z'updated_at: '2026-01-15T12:00:00.000Z'+ product_type_id:+ delivery_profile_id: fp_UkLWZg9DAJschema:"$ref": "#/components/schemas/Product"requestBody:@@ -13198,8 +13368,8 @@ paths:application/json:example:id: sel_UkLWZg9DAJ- name: Seller 57- slug: seller-57+ name: Seller 60+ slug: seller-60about: ''about_html: ''logo_url:@@ -13271,7 +13441,7 @@ paths:example:id: sel_UkLWZg9DAJname: Acme Supplies- slug: seller-59+ slug: seller-62about: ''about_html: ''logo_url:@@ -14014,10 +14184,10 @@ paths:application/json:example:direct_upload:- url: http://www.example.com/rails/active_storage/disk/eyJfcmFpbHMiOnsiZGF0YSI6eyJrZXkiOiJuem5oOGdra3VxendvbDc1ODBxNHNwZmpmMjVxIiwiY29udGVudF90eXBlIjoiYXBwbGljYXRpb24vcGRmIiwiY29udGVudF9sZW5ndGgiOjUxMjM0LCJjaGVja3N1bSI6IlZqaHowNGxRdUVHdXY0bkR2aHNhTlE9PSIsInNlcnZpY2VfbmFtZSI6InRlc3QifSwiZXhwIjoiMjAyNi0wMS0xNVQxMjowNTowMC4wMDBaIiwicHVyIjoiYmxvYl90b2tlbiJ9fQ==--58a641a639a7fc8dd127772326a8ed6da4fbcf25+ url: http://www.example.com/rails/active_storage/disk/eyJfcmFpbHMiOnsiZGF0YSI6eyJrZXkiOiJuem5oOGdra3VxendvbDc1ODBxNHNwZmpmMjVxIiwiY29udGVudF90eXBlIjoiYXBwbGljYXRpb24vcGRmIiwiY29udGVudF9sZW5ndGgiOjUxMjM0LCJjaGVja3N1bSI6IlZqaHowNGxRdUVHdXY0bkR2aHNhTlE9PSIsInNlcnZpY2VfbmFtZSI6InRlc3QifSwiZXhwIjoiMjAyNi0wMS0xNVQxMjowNTowMC4wMDBaIiwicHVyIjoiYmxvYl90b2tlbiJ9fQ==--64df88e13fbbd7bb2787ec2a2d7871d2f8473840headers:Content-Type: application/pdf- signed_id: eyJfcmFpbHMiOnsiZGF0YSI6MSwicHVyIjoiYmxvYl9pZCJ9fQ==--8daa562c0917e5095f42256aae1474497fe1b382+ signed_id: eyJfcmFpbHMiOnsiZGF0YSI6MSwicHVyIjoiYmxvYl9pZCJ9fQ==--444fd0fa6ae1549b84a2ef7c39e5f2fd9f672093schema:"$ref": "#/components/schemas/DirectUploadResponse"requestBody:@@ -14281,8 +14451,8 @@ paths:- id: fi_UkLWZg9DAJquantity: 1line_item_id: li_UkLWZg9DAJ- name: Product 1359315- sku: SKU-173+ name: Product 1369315+ sku: SKU-174options_text: ''schema:type: object@@ -14351,8 +14521,8 @@ paths:- id: fi_UkLWZg9DAJquantity: 1line_item_id: li_UkLWZg9DAJ- name: Product 136961- sku: SKU-174+ name: Product 137961+ sku: SKU-175options_text: ''schema:"$ref": "#/components/schemas/Fulfillment"@@ -14452,7 +14622,7 @@ paths:display_total: "$110.00"items:- id: li_UkLWZg9DAJ- name: Product 13795+ name: Product 13895options_text: ''quantity: 1currency: USD@@ -14461,7 +14631,7 @@ paths:total: '10.0'display_total: "$10.00"variant_id: variant_UkLWZg9DAJ- sku: SKU-175+ sku: SKU-176thumbnail_url:fulfillments:- id: ful_UkLWZg9DAJ@@ -14481,8 +14651,8 @@ paths:- id: fi_UkLWZg9DAJquantity: 1line_item_id: li_UkLWZg9DAJ- name: Product 13795- sku: SKU-175+ name: Product 13895+ sku: SKU-176options_text: ''shipping_address:id: addr_gbHJdmfrXB@@ -14601,7 +14771,7 @@ paths:display_total: "$110.00"items:- id: li_UkLWZg9DAJ- name: Product 1389755+ name: Product 1399755options_text: ''quantity: 1currency: USD@@ -14610,7 +14780,7 @@ paths:total: '10.0'display_total: "$10.00"variant_id: variant_UkLWZg9DAJ- sku: SKU-176+ sku: SKU-177thumbnail_url:fulfillments:- id: ful_UkLWZg9DAJ@@ -14630,8 +14800,8 @@ paths:- id: fi_UkLWZg9DAJquantity: 1line_item_id: li_UkLWZg9DAJ- name: Product 1389755- sku: SKU-176+ name: Product 1399755+ sku: SKU-177options_text: ''shipping_address:id: addr_gbHJdmfrXB@@ -14739,7 +14909,7 @@ paths:display_total: "$110.00"items:- id: li_UkLWZg9DAJ- name: Product 1416554+ name: Product 1426554options_text: ''quantity: 1currency: USD@@ -14748,7 +14918,7 @@ paths:total: '10.0'display_total: "$10.00"variant_id: variant_UkLWZg9DAJ- sku: SKU-179+ sku: SKU-180thumbnail_url:fulfillments:- id: ful_UkLWZg9DAJ@@ -14768,8 +14938,8 @@ paths:- id: fi_UkLWZg9DAJquantity: 1line_item_id: li_UkLWZg9DAJ- name: Product 1416554- sku: SKU-179+ name: Product 1426554+ sku: SKU-180options_text: ''shipping_address:id: addr_gbHJdmfrXB@@ -15034,11 +15204,16 @@ tags:do- name: Countriesdescription: Country and state reference data for the panel's address forms+- name: Delivery Profiles+ description: The marketplace's delivery vocabulary — what kind of goods a product+ is, which decides how it ships- name: Onboardingdescription: The marketplace checklist a seller completes before admission, andwhat they submit against it- name: Policiesdescription: The seller's own legal documents, as the marketplace asks them to publish+- name: Product Types+ description: The types a seller may list a product against, and what each adds- name: Productsdescription: The seller's own catalog- name: Profile@@ -15858,6 +16033,20 @@ components:- display_compare_at_amount- price_list_idx-typelizer: true+ DeliveryProfile:+ type: object+ properties:+ id:+ type: string+ name:+ type: string+ default:+ type: boolean+ required:+ - id+ - name+ - default+ x-typelizer: trueExport:type: objectproperties:@@ -16513,6 +16702,12 @@ components:type: stringupdated_at:type: string+ product_type_id:+ type: string+ nullable: true+ delivery_profile_id:+ type: string+ nullable: truesubmission:allOf:- "$ref": "#/components/schemas/ProductSubmission"@@ -16545,6 +16740,8 @@ components:- metadata- created_at- updated_at+ - product_type_id+ - delivery_profile_idx-typelizer: trueProductSubmission:type: object@@ -16571,6 +16768,22 @@ components:- created_at- product_idx-typelizer: true+ ProductType:+ type: object+ properties:+ id:+ type: string+ name:+ type: string+ option_type_labels:+ type: array+ items:+ type: string+ required:+ - id+ - name+ - option_type_labels+ x-typelizer: trueProfile:type: objectproperties:@@ -16717,6 +16930,9 @@ components:action_url:type: stringnullable: true+ blocker:+ type: object+ nullable: trueblocking:type: booleanaccepts_submissions:@@ -16745,6 +16961,7 @@ components:- position- status- action_url+ - blocker- blocking- accepts_submissions- requires_filediff --git a/docs/plans/6.0-multi-vendor-marketplace.md b/docs/plans/6.0-multi-vendor-marketplace.mdindex dadc94b749..2f8abd053c 100644--- a/docs/plans/6.0-multi-vendor-marketplace.md+++ b/docs/plans/6.0-multi-vendor-marketplace.md@@ -245,6 +245,24 @@ Core already models exactly this. `Spree::TaxIdentifier` (from `6.0-tax-provider**Supersedes** the `belongs_to :returns_address` line in the Seller model sketch below, and the `Spree::SellerRequirements::ReturnsAddress` checklist kind becomes "has a returns location".+### 13. Seller delivery: the marketplace owns the profiles, the seller owns their methods (RESOLVED 2026-09-01 — design only, nothing built)++A marketplace has two different delivery questions, and they get two different owners.++**"What kind of goods is this?" is the marketplace's question.** A `DeliveryProfile` (parcel, digital, pallet, …) is the hub the zones, origin groups and methods hang off, so a shared vocabulary of profiles is what keeps a buyer's shipping options readable across sellers and lets the operator reason about the store as one. Profiles, zones and origin groups stay operator-owned and store-scoped — none of them gets a `seller_id`, ever. A seller **assigns** a profile to their product (directly, or through a product type whose template stamps one at creation — shipped 2026-09-01) and never creates one.++**"Who ships it, how, and at what price?" is the seller's question.** `DeliveryMethod` gains a nullable `seller_id`. A seller creates, prices and retires their own methods against the marketplace's profiles and zones; the operator's methods stay `seller_id: nil`. This is what the Seller API surface and the Order splitting section have assumed since 2026-08-15, and what `Carts::SplitBySeller#divide_delivery_cost` names as the real answer to per-seller quoting — it was never built, and it is now designed:++- **Eligibility is one rule in one place.** A package's seller is its stock location's (`stock_location.seller_id`) — the derivation the legacy module used, and still correct: a seller's goods only ever sit in that seller's locations. A seller's package is offered that seller's own methods plus any marketplace method the operator has marked **`available_to_sellers`** (new boolean on `spree_delivery_methods`, default `false`); a first-party package is offered marketplace methods only. Enforced in `Stock::Estimator#filter_delivery_methods` beside the existing audience/address/location/rule filters, so calculator- and provider-priced methods obey it alike. The one boolean covers both marketplace shapes: an operator who runs shipping for everyone shares their methods and sellers create none; an operator who lets each seller quote shares nothing.+- **Origins need no new layer.** A seller method belongs to a profile and optionally a zone from the marketplace's list, and takes the profile's default origin group like any other method. Which packages it may quote is settled by the seller filter above, so no per-seller origin group exists. The one change is to coverage: `DeliveryOriginGroup#covers_location?` answers **true for any seller-owned location**, because a group's member list narrows the *operator's* warehouses ("pallets ship from Warehouse B") and says nothing about where a seller keeps stock. Today a narrowed group silently makes every seller's stock unallocatable — a defect this design fixes.+- **Carriers stay the operator's in 6.0.** A seller method prices through the internal rate provider (flat or calculated rates, plus `DeliveryMethodRule`s) and fulfils through the manual provider with the hand-entered tracking number a seller already supplies today; a validation refuses any other `rate_provider` or `fulfillment_provider` on a row carrying `seller_id`, because carrier credentials live on the store-scoped `Spree::Integration`. Neither marketplace platform we studied lets a seller register a carrier account in-platform either — both hand that to the seller's own tools. A seller-owned integration is a later, purely additive step (Open Question 3). Pickup at a seller's own counter follows the same shape (a seller method on the Pickup provider whose pickup locations are the seller's) and is not in the first cut.+- **Checkout is already per package.** Packages come out per stock location, so with seller methods a seller's goods are quoted by that seller's methods from the start, and the buyer picks one rate per package through `store/carts/:id/fulfillments` exactly as today. `SplitBySeller#divide_delivery_cost` stays as the fallback for the one case that still spans sellers — a first-party location holding several sellers' variants.+- **"At least one way to ship" is an onboarding requirement, not a gate.** `Spree::SellerRequirements::DeliveryMethod`, a computed kind in `DEFAULT_KINDS`: complete when the seller has an active method of their own **or** the store shares at least one active method with sellers. Read only by the two enforcement points `6.0-seller-onboarding-requirements.md` allows — a seller who later retires their last method is flagged, never blocked.+- **Permission:** `DeliveryMethod`, `DeliveryMethodRule` and `DeliveryMethodService` leave `settings` for a `delivery_methods` catalog resource (`read_delivery_methods`/`write_delivery_methods`, group `settings`, seller-grantable) — `settings` is never seller-grantable, and per `6.0-admin-rbac.md` a capability a new audience holds gets its own entry. Unreleased edge, so no bridge: operator roles are data and the seeded admin role is a super-role.+- **Surface:** `/api/v3/seller/delivery_methods` CRUD rooted in `current_seller.delivery_methods` (nested rules and services in the same payload shape the operator's endpoint takes), read-only `GET /seller/delivery_zones?delivery_profile_id=` for the zone picker, and the seller panel gains Settings → Fulfillment → **Delivery methods** beside Stock locations. The operator's delivery-method form gains one switch, "Available to sellers", and the operator's list shows which seller owns a method. The Enterprise Shopify/WooCommerce seller apps may write a seller's shipping setup into these rows; core provides the rows only.++**Phases:** (1) schema + estimator filter + validations + the coverage fix; (2) seller API + requirement kind + permission split; (3) seller panel page + operator switch; (4) a storefront pass proving one rate per seller package on a mixed cart.+## Design Details### Seller identity & teams@@ -698,9 +716,9 @@ A third v3 branch, `/api/v3/seller/…`, anchored by `Spree::Api::V3::Seller::Ba- **Auth & context:** `POST /seller/auth/login|refresh|logout`, password reset — `Spree.seller_authentication_strategies`, `seller_api` JWT audience, audience-stamped refresh token + own cookie. `X-Spree-Seller-Id` selects the seller; membership = `role_users` on `resource: seller`; a header naming a seller the caller does not belong to is 403; `Spree::Current.store` is set from `current_seller.store`. `GET /seller/me` — user + seller memberships + `permission_keys` for the selected seller. Invitation acceptance stays on the existing `/admin/invitation_acceptances` (it is store-agnostic and already handles `resource: seller`).- **Own resources:** `GET/PATCH /seller/profile` (name, about, branding uploads, billing/returns addresses, `payouts_schedule_interval`, ToS acceptance, holiday mode), `GET /seller/onboarding_tasks` + `POST /seller/onboarding/submit_for_review`, `GET /seller/team` + team invitations (`RoleGrantGuard`-bounded to seller-audience roles), `GET /seller/balance`, `GET /seller/transfers`, `GET /seller/payouts` (read-only ledger).-- **Catalog:** products (+ nested variants, prices, media, stock items) — every lookup through `current_seller.products`; create force-stamps `seller_id`; approval state per the store's seller-product preference. No channel publication, no categories/collections/tags management (read-only pickers where a product form needs them, store-scoped read).+- **Catalog:** products (+ nested variants, prices, media, stock items) — every lookup through `current_seller.products`; create force-stamps `seller_id`; approval state per the store's seller-product preference. No channel publication, and no categories/collections/tags at all — filing a listing is the operator's, done at review (2026-08-26). A seller does assign a **product type** and a **delivery profile** (2026-09-01): the type is what hands them option types and the profile template, the profile is what makes their goods quotable, and read-only `GET /seller/product_types` and `GET /seller/delivery_profiles` back the two pickers.- **Orders:** the seller's child orders (`current_seller.orders`), fulfillments with `Fulfillments::Fulfill`/`Cancel`/`UpdateTracking`, returns/claims on those orders. **No** refunds, order edits, approvals, payments — the seller sees its `payment_split`, never the group's `Payment`.-- **Delivery:** the seller's own delivery methods (`seller_id` = self); store-wide methods read-only.+- **Delivery:** profiles are read-only vocabulary (shipped 2026-09-01); the seller's own delivery methods (`seller_id` = self) with read-only zones under a profile, and shared marketplace methods read-only — Decision 13, pending.- **Exports/imports:** the seller's own runs on the `Spree::Export`/`Import` pipeline, scoped by `seller_id`.- **Serializers:** `Spree::Api::V3::Seller::*Serializer < V3::*Serializer` (the store serializer) plus an explicit list of operational fields — never a subclass of the admin serializer, so nothing leaks by inheritance. Own typelizer output and a generated `docs/api-reference/seller.yaml` from `spree/api/spec/integration/spree/api/v3/seller/`.- **Tripwires:** the branch enters `Spree::StoreScopeGuard`'s coverage, and Phase 1 adds a seller-scope guard on the same pattern (flag store-scoped-but-not-seller-scoped scans on seller-owned tables under `/seller`).@@ -739,6 +757,7 @@ Even before this lands, work touching adjacent areas should:- **Inventory operations (`6.0-inventory-operations.md`)**: the procurement model is `Spree::Supplier` — never reuse `Spree::Seller` (reserved for marketplace sellers) for purchase-order sources. See `decisions.md` 2026-07-14.- **External-store sync stays Enterprise**: do **not** add external store/resource models, associations, or callbacks to core (no `external_store` on Seller, no external product/order/category tables, no platform sync hooks). The Shopify/WooCommerce connection layer is an Enterprise concern that decorates core's Seller from outside; core only needs to stay decorable (events + the onboarding task registry are the seams it plugs into).- **Fulfillment & delivery (`6.0-fulfillment-and-delivery.md`)**: the ledger trigger is defined against Fulfillment ("all fulfillments fulfilled"), and `DeliveryMethod` gets an optional `seller_id` — keep the fulfillment-status surface queryable per order (child orders fulfill independently) and don't assume one order per checkout in fulfillment UIs.+- **Seller delivery (Decision 13)**: never give `DeliveryProfile`, `DeliveryZone` or `DeliveryOriginGroup` a `seller_id` — the seller's row is the method; which methods a seller's package sees is decided in `Stock::Estimator#filter_delivery_methods` and nowhere else (no seller checks in serializers, splitters or the storefront); code reading `DeliveryOriginGroup#covers_location?` must not assume its member list says anything about seller-owned locations; a seller product's `product_type_id` and `delivery_profile_id` are the seller's to assign, so nothing may treat them as operator-only again; and a seller's product form never offers categories, collections or tags.- **Order routing (`6.0-order-routing.md`)**: the per-child stock-location decision must come from the routing strategy, so a seller's items allocate from that seller's stock location. Keep `for_allocation` seller-aware-friendly (it already takes `order:`).- **Tax provider (`6.0-tax-provider.md`)** and **Delivery rate provider (`6.0-delivery-rate-provider.md`)**: the `PayoutProvider` follows the same pluggable-strategy shape — keep the provider-registration convention consistent so all three (tax, delivery rate, payout) register and resolve the same way.- **Admin API (`6.0-admin-api.md`)**: the `Seller` prefix is `sel_`. The "Marketplace (new in 6.0)" endpoint group there is the *operator's* API surface — keep it in sync. Seller users never call the Admin API (Decision 10).@@ -748,6 +767,8 @@ Even before this lands, work touching adjacent areas should:## Resolved Decisions+- **Seller delivery → marketplace-owned profiles, seller-owned methods** (RESOLVED 2026-09-01, design only). Decision 13: profiles, zones and origin groups never carry a `seller_id`; `DeliveryMethod` gains a nullable `seller_id` and an `available_to_sellers` switch; a package's seller is its stock location's and its eligible methods are decided in the estimator alone; seller methods are internal-rate and manual-fulfillment only, carrier accounts staying the operator's; `DeliveryOriginGroup#covers_location?` is true for seller locations; "at least one way to ship" is a computed onboarding requirement; `delivery_methods` becomes its own seller-grantable catalog resource. Replaces the bare `seller_id` promise the Seller API and Order splitting sections carried since 2026-08-15.+- **A seller assigns their product's type and delivery profile; the operator files it** (RESOLVED 2026-09-01, shipped). Partly reverses the 2026-08-26 change that took the whole Categorization card off the seller branch. A product type is not filing — it is the template that hands a seller their option types and delivery profile — and the profile is what makes their goods quotable at all: every seller product was landing on the store default, so nothing a seller sold could be digital or oversized. `product_type_id` and `delivery_profile_id` are readable and writable on `/seller/products`, resolved against the seller's store (a foreign id is a 404), backed by read-only `GET /seller/product_types` (under `read_product_types`, the key `6.0-seller-product-submission.md` minted for exactly this) and `GET /seller/delivery_profiles` (under `read_products` — the vocabulary a product form fills in, not a setting a seller holds a key on). Categories, collections and tags stay off the branch: filing a listing is the operator's, done at review.- **The split adopts the paid order rather than replacing it, and moves rows rather than copying them** (RESOLVED 2026-08-20, shipped). Completion builds one draft order holding the whole basket so it can be paid as one; the split then makes that order the group's first child and hands the other partitions' rows to new siblings. The alternative — build N fresh orders and destroy the original — was written first and rejected on two counts: the original is the record the payment was taken against and the row carrying the unique `cart_id` that makes completion replayable, so destroying it orphans money and breaks resumption. Rows **move** (`update_all` on the owner FK) rather than being re-copied from the cart, because everything was costed once inside the completion lock and re-deriving would ask the pricing and tax engines a question already answered — possibly getting a different one. The group takes the order's number so the customer keeps the reference they saw at checkout, and children suffix off it (`R1001-1`), following the same reads-its-parent shape as fulfillment and payment numbers.- **Splitting a parcel between sellers divides everything hanging off it** (RESOLVED 2026-08-20, shipped). A fulfillment holding two sellers' goods becomes two, and the cost the customer was quoted is apportioned between them by the value each half carries (largest-remainder), never copied onto both. The first implementation cloned the fulfillment wholesale and charged delivery twice — the group totalled more than the customer paid, caught by a totals spec rather than by review. The honest reading is that one quote for one parcel no longer describes two; a marketplace wanting each seller quoted separately gets that by giving sellers their own delivery methods, which packs their goods separately from the start and leaves nothing to divide. **Three things divide with it**, each missed on the first pass because a divided parcel is the only case where a row's owner keeps its id while its contents change: the parcel's own tax lines, discounts and fees (re-pointing by `fulfillment_id` finds nothing for the clone, so the source kept tax on a charge it no longer bore and the sibling shipped untaxed), the **selected delivery rate** (a fulfillment restates its cost from its rate whenever amounts refresh, so leaving the rate whole quietly restored the full charge on both halves the next time anything touched them), and the **stock reservations** on the moving line items (scoped by `order_id` at release, so one child would have released everyone's and each sibling none).- **Per-seller commission needed no commission-engine change** (RESOLVED 2026-08-20, verified). Each child order publishes its own `order.placed`, which `OrderCommissionSubscriber` already answers, and `Commissions::CommissionOrder` already partitions by `line_item.seller_id` and skips nil-seller lines — so the seller children are commissioned and the first-party child correctly is not, with no marketplace branch anywhere in the engine. This is the payoff of the Phase 2 decision to key commission on the line item's own seller snapshot rather than on the order.@@ -806,6 +827,8 @@ Even before this lands, work touching adjacent areas should:1. **Seller-funded vs platform-funded promotions.** v1: discounts reduce the seller's sale value (seller-funded). Platform-funded promos ("we run a 10% site-wide sale and make sellers whole") need a funding flag on Promotion and a compensating ledger line — **post-6.0**. Unblocked by: a merchant asking for platform-funded campaigns once the ledger is live; the shape is a `funded_by` on Promotion + a positive `SellerTransfer` compensating row.2. **Seller-scoped promotions** (a seller creates promotions limited to its own products) — **post-6.0** (resolved 2026-08-15 as deferred). Shape when it lands: `spree_promotions.seller_id` (nullable), a `/api/v3/seller/promotions` endpoint on the seller branch, and a rule guard that a seller promotion only matches line items with the same `seller_id`. Cheap on the single-store Promotion model; unblocked by the 6.0 headline scope shipping first.+3. **Seller-owned carrier accounts.** Decision 13 keeps carrier-backed methods with the operator. When a seller needs to buy labels on their own account, the additive shape is `spree_integrations.seller_id` (nullable), an integrations page on the seller branch, and the seller-method validation widened to rate and fulfillment providers whose integration is the seller's own — nothing in the first cut has to change.+## References- [spree/spree#13323](https://github.com/spree/spree/issues/13323) — "Open source Spree Multi Seller for Spree 6" (the OSS/Enterprise scope split; amended 2026-07-15 — basic Stripe Connect execution moved to OSS, see `decisions.md`; the issue text needs a matching update).diff --git a/docs/plans/6.0-seller-product-submission.md b/docs/plans/6.0-seller-product-submission.mdindex b9c658371e..56bb6031ec 100644--- a/docs/plans/6.0-seller-product-submission.md+++ b/docs/plans/6.0-seller-product-submission.md@@ -55,12 +55,26 @@ drift.define types. Per `6.0-admin-rbac.md`, a new sensitive capability gets itsown catalog entry rather than riding an existing key.+ **Revised 2026-09-01:** read-only for a seller to *pick from*, not merely+ to look at — a seller assigns a type to their own product, and a delivery+ profile with it. The type is the template that hands them option types and+ a delivery profile, and the profile is what makes their goods quotable; on+ 2026-08-26 both had left the branch with the Categorization card, and every+ seller product was landing on the store's default profile. See+ `6.0-multi-vendor-marketplace.md`, Decision 13 and the 2026-09-01 resolved+ decisions.+6. **`ProductPublication` moves off the `products` key onto a publishingresource with no seller audience.** Which channels carry a product ismarketplace merchandising, not a seller's to set.7. **A seller files a product into the marketplace's groupings; they do not- extend them.** `category_ids` and `collection_ids` are writable — filing a+ extend them.** **Revised 2026-08-26 (recorded 2026-09-01):** they do not+ file it either — categories, collections and tags all left the seller+ branch with the Categorization card, since filing a listing is the+ operator's, done at review. The two fields that came back on 2026-09-01+ are the product type and the delivery profile, which are not filing. The+ original reasoning stays below for the record. `category_ids` and `collection_ids` are writable — filing aproduct is part of maintaining it, which is why the operator's own endpointpermits them under `write_products` rather than `write_collections`. Thecategories and collections themselves are read-only pickers.@@ -267,7 +281,9 @@ each headless: no `adminClient`, no `useStore`, no locale import. The two appssupply data, mutations and translated labels by prop.The seller panel composes: General, Media, Prices, Variants, Inventory, SEO,-Categorization, Custom Fields, Metadata, Status (restricted), Translations.+Categorization (product type and delivery profile only — no categories,+collections or tags; revised 2026-09-01), Custom Fields, Metadata, Status+(restricted), Translations.It omits Publishing (channels), Tax, and the JSON preview.`StatusCard` takes the allowed transitions as a prop rather than derivingdiff --git a/docs/plans/decisions.md b/docs/plans/decisions.mdindex 2c7fc5d867..2604037eb1 100644--- a/docs/plans/decisions.md+++ b/docs/plans/decisions.md@@ -1,3 +1,11 @@+## 2026-09-01: Seller delivery — the marketplace owns the profiles, the seller owns their methods++**Context:** `6.0-multi-vendor-marketplace.md` had promised `DeliveryMethod#seller_id` since 2026-08-15 without ever designing it, and the shipped code went the other way: every delivery record is store-scoped, the estimator knows nothing about sellers, a seller's only delivery lever is where their stock sits, and `Carts::SplitBySeller#divide_delivery_cost` apportions one quote after payment. Meanwhile the seller branch had taken product type and delivery profile off the product form (2026-08-26), so every seller product landed on the store's default profile. The legacy multi-vendor module owned methods per vendor and kept zones and categories global; of the two marketplace platforms studied, one lets sellers build the whole shipping tree themselves and the other keeps an operator vocabulary the seller prices within.++**Decision:** Two questions, two owners. "What kind of goods is this" — `DeliveryProfile`, with its zones and origin groups — is the marketplace's vocabulary and never carries a `seller_id`; a seller assigns a profile (and a product type) to their product, shipped the same day. "Who ships it, how, at what price" — `DeliveryMethod` — is the seller's: nullable `seller_id`, plus an `available_to_sellers` switch on marketplace methods so an operator who runs shipping for everyone shares theirs. A package's seller is its stock location's, and the methods it is offered are decided in `Stock::Estimator#filter_delivery_methods` alone. Seller methods price through the internal rate provider and fulfil manually; carrier accounts stay on the store-scoped `Integration` until a seller-owned integration is needed. `DeliveryOriginGroup#covers_location?` answers true for seller locations, fixing the narrowed-group defect that made seller stock unallocatable. "At least one way to ship" becomes a computed seller requirement, and `delivery_methods` its own seller-grantable catalog resource.++**Consequences:** No per-seller profile, zone or origin-group layer, ever; no seller checks outside the estimator; the post-payment cost division stays only as the fallback for a first-party location holding several sellers' goods; carrier-backed seller methods are refused by validation rather than half-supported. Full design: `6.0-multi-vendor-marketplace.md`, Decision 13.+## 2026-08-23: BusinessAddress stays a table-sharing subclass, not STI**Context:** `Spree::BusinessAddress` overrides three predicates on `Spree::Address` — `require_name?` false, `require_company?` true, `show_company_address_field?` true — and is used by a seller's billing address. It was briefly converted to real STI (a `type` column on `spree_addresses`, an index, a backfill, `CompanyLocation`'s two addresses typed to it), on the argument that the rules should travel with the row so a company address copied onto a cart's base-typed `bill_address` would still validate as a business address. That was reverted the next day.diff --git a/packages/dashboard-core/src/api-client.ts b/packages/dashboard-core/src/api-client.tsindex 7652d5db82..b659594abe 100644--- a/packages/dashboard-core/src/api-client.ts+++ b/packages/dashboard-core/src/api-client.ts@@ -137,8 +137,13 @@ export interface PanelApiClient {get(id: string): Promise<PanelProductType>}/**- * Marketplace configuration a seller does not write, so a seller's client- * registers neither and the cards that read them hide.+ * Tax category is marketplace configuration a seller does not write, so+ * their client registers none and the card that reads it hides.+ *+ * Delivery profiles are different: the marketplace defines them, but a+ * seller assigns one to their own product — it decides how their goods can+ * be shipped at all — so both panels register this one+ * (docs/plans/6.0-multi-vendor-marketplace.md, Decision 13).*/taxCategories?: {list(params?: Record<string, unknown>): Promise<{ data: PanelNamedRecord[] }>@@ -405,6 +410,13 @@ export interface PanelProductType {id: stringname: stringoption_type_ids?: string[]+ /**+ * The option types picking this type will add, already named. A panel that+ * manages no option-type vocabulary (a seller's) cannot resolve+ * `option_type_ids` against a list it never loads, so its API sends the+ * labels instead and the form reads whichever it was given.+ */+ option_type_labels?: string[]category_ids?: string[]custom_field_definitions?: unknown[]}diff --git a/packages/dashboard-core/src/products/product-form-cards.tsx b/packages/dashboard-core/src/products/product-form-cards.tsxindex 886ea74d5e..0fe8b16466 100644--- a/packages/dashboard-core/src/products/product-form-cards.tsx+++ b/packages/dashboard-core/src/products/product-form-cards.tsx@@ -904,6 +904,10 @@ export function StatusCard({export function CategorizationCard({ form }: FormCardProps) {const { t } = useTranslation()+ // Each picker shows only when the panel's client registers its source: a+ // seller's registers types and delivery profiles but not the filing+ // vocabulary (categories, collections, tags), which is the operator's.+ const client = getApiClient()const { data: categoriesData } = useCategories()const { data: collectionsData } = useCollections()const { data: productTypesData } = useProductTypes()@@ -928,15 +932,25 @@ export function CategorizationCard({ form }: FormCardProps) {// builder won't surface these, so the name is the only signal the merchant// gets about what the type contributes.const typeOptionTypeNames = useMemo(() => {+ // Served already named where the panel has no option-type list to resolve+ // ids against — a seller's API sends labels for exactly this reason.+ const labels = selectedProductType?.option_type_labels+ if (labels?.length) return labels+const ids = selectedProductType?.option_type_ids ?? []return ids.map((id) => optionTypes.find((optionType) => optionType.id === id)).filter((optionType) => optionType !== undefined).map((optionType) => optionType.label ?? optionType.name ?? '').filter(Boolean)- }, [selectedProductType?.option_type_ids, optionTypes])+ }, [selectedProductType?.option_type_labels, selectedProductType?.option_type_ids, optionTypes])useEffect(() => {+ // Only where the panel files products at all: a seller's client registers+ // no categories, so seeding them would dirty the form with ids their API+ // drops on save — an unsaved-changes prompt over a field they cannot see.+ if (!client.categories) return+const categoryIds = selectedProductType?.category_idsif (!categoryIds?.length) return@@ -945,7 +959,7 @@ export function CategorizationCard({ form }: FormCardProps) {if (missing.length === 0) returnform.setValue('category_ids', [...current, ...missing], { shouldDirty: true })- }, [selectedProductType, form])+ }, [selectedProductType, form, client.categories])// Automatic collections rebuild their members from rules, so a hand-picked// membership would be dropped on the next regeneration — offer manual only.// Memoized: `initialItems` feeds a useEffect + useMemo inside@@ -961,48 +975,52 @@ export function CategorizationCard({ form }: FormCardProps) {<CardTitle>{t('admin.pages.products.section_categorization')}</CardTitle></CardHeader><CardContent className="flex flex-col gap-4">- <Field>- <FieldLabel>{t('admin.fields.product.product_type_id.label')}</FieldLabel>- <Controller- name="product_type_id"- control={form.control}- render={({ field }) => (- <Select value={field.value ?? ''} onValueChange={(v) => field.onChange(v || null)}>- <SelectTrigger className="w-full">- <SelectValue placeholder={t('admin.products.product_type_placeholder')}>- {(v) =>- productTypes.find((pt) => pt.id === v)?.name ??- t('admin.products.product_type_placeholder')- }- </SelectValue>- </SelectTrigger>- <SelectContent>- {productTypes.map((productType) => (- <SelectItem key={productType.id} value={productType.id}>- {productType.name}- </SelectItem>- ))}- </SelectContent>- </Select>- )}- />- <span className="text-muted-foreground text-xs">- {t('admin.fields.product.product_type_id.help')}- </span>- {typeOptionTypeNames.length > 0 && (+ {client.productTypes && (+ <Field>+ <FieldLabel>{t('admin.fields.product.product_type_id.label')}</FieldLabel>+ <Controller+ name="product_type_id"+ control={form.control}+ render={({ field }) => (+ <Select value={field.value ?? ''} onValueChange={(v) => field.onChange(v || null)}>+ <SelectTrigger className="w-full">+ <SelectValue placeholder={t('admin.products.product_type_placeholder')}>+ {(v) =>+ productTypes.find((pt) => pt.id === v)?.name ??+ t('admin.products.product_type_placeholder')+ }+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ {productTypes.map((productType) => (+ <SelectItem key={productType.id} value={productType.id}>+ {productType.name}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ )}+ /><span className="text-muted-foreground text-xs">- {t('admin.products.product_type_adds_options', {- options: typeOptionTypeNames.join(', '),- count: typeOptionTypeNames.length,- })}+ {t('admin.fields.product.product_type_id.help')}</span>- )}- </Field>+ {typeOptionTypeNames.length > 0 && (+ <span className="text-muted-foreground text-xs">+ {t('admin.products.product_type_adds_options', {+ options: typeOptionTypeNames.join(', '),+ count: typeOptionTypeNames.length,+ })}+ </span>+ )}+ </Field>+ )}- {/* Marketplace configuration: a panel whose client registers no- delivery profiles cannot write one, so it does not offer the- field rather than showing an edit that goes nowhere. */}- {deliveryProfiles.length > 0 && (+ {/* A panel whose client registers no delivery profiles cannot write+ one, so it does not offer the field rather than showing an edit+ that goes nowhere. Gated on the registration, not on the rows+ having arrived: keyed on the list, the field would vanish and+ reappear as the fetch settles. */}+ {client.deliveryProfiles && (<Field><FieldLabel>{t('admin.fields.product.delivery_profile_id.label')}</FieldLabel><Controller@@ -1034,44 +1052,48 @@ export function CategorizationCard({ form }: FormCardProps) {</Field>)}- <Field>- <FieldLabel>{t('admin.fields.product.category_ids.label')}</FieldLabel>- <Controller- name="category_ids"- control={form.control}- render={({ field }) => (- <ResourceMultiAutocomplete- {...categoryAutocompleteProps('product-edit-category-picker')}- initialItems={categoriesData?.data}- value={field.value ?? []}- onChange={field.onChange}- />- )}- />- </Field>+ {client.categories && (+ <Field>+ <FieldLabel>{t('admin.fields.product.category_ids.label')}</FieldLabel>+ <Controller+ name="category_ids"+ control={form.control}+ render={({ field }) => (+ <ResourceMultiAutocomplete+ {...categoryAutocompleteProps('product-edit-category-picker')}+ initialItems={categoriesData?.data}+ value={field.value ?? []}+ onChange={field.onChange}+ />+ )}+ />+ </Field>+ )}- <Field>- <FieldLabel>{t('admin.fields.product.collection_ids.label')}</FieldLabel>- <Controller- name="collection_ids"- control={form.control}- render={({ field }) => (- <ResourceMultiAutocomplete- {...collectionAutocompleteProps('product-edit-collection-picker')}- initialItems={manualCollections}- value={field.value ?? []}- onChange={field.onChange}- />- )}- />- <span className="text-muted-foreground text-xs">- {t('admin.fields.product.collection_ids.help')}- </span>- </Field>+ {client.collections && (+ <Field>+ <FieldLabel>{t('admin.fields.product.collection_ids.label')}</FieldLabel>+ <Controller+ name="collection_ids"+ control={form.control}+ render={({ field }) => (+ <ResourceMultiAutocomplete+ {...collectionAutocompleteProps('product-edit-collection-picker')}+ initialItems={manualCollections}+ value={field.value ?? []}+ onChange={field.onChange}+ />+ )}+ />+ <span className="text-muted-foreground text-xs">+ {t('admin.fields.product.collection_ids.help')}+ </span>+ </Field>+ )}{/* Tags are the store's own vocabulary, so only a panel that managesit offers the field (docs/plans/6.0-multi-vendor-marketplace.md). */}- {getApiClient().tags && (+ {client.tags && (<Field><FieldLabel>{t('admin.fields.product.tags.label')}</FieldLabel><Controllerdiff --git a/packages/dashboard-core/src/products/product-types.ts b/packages/dashboard-core/src/products/product-types.tsindex ebe7433e11..68f37be753 100644--- a/packages/dashboard-core/src/products/product-types.ts+++ b/packages/dashboard-core/src/products/product-types.ts@@ -109,6 +109,7 @@ export interface PanelProduct {unpublished_at?: string | null}>tax_category_id?: string | null+ /** Both panels: a seller picks a profile from the marketplace's list. */delivery_profile_id?: string | null}diff --git a/packages/seller-dashboard/src/api-client.ts b/packages/seller-dashboard/src/api-client.tsindex b6029c525d..39076eca2a 100644--- a/packages/seller-dashboard/src/api-client.ts+++ b/packages/seller-dashboard/src/api-client.ts@@ -116,10 +116,16 @@ export function createSellerApiClient({create: (params) => sellerClient().stockLocations.create(params),update: (id, params) => sellerClient().stockLocations.update(id, params),},- // No catalog reference data is registered: how a product is filed — its- // type, categories, collections and tags — is the marketplace's own- // merchandising, so the shared form's Categorization card has nothing to- // read and hides (docs/plans/6.0-seller-product-submission.md).+ // The marketplace's vocabulary the product form picks from: types and+ // delivery profiles only. Categories, collections and tags are filing,+ // which is the operator's at review, so they are not registered and the+ // shared Categorization card offers just these two+ // (docs/plans/6.0-multi-vendor-marketplace.md, Decision 13).+ productTypes: {+ list: (params) => sellerClient().productTypes.list(params),+ get: (id) => sellerClient().productTypes.get(id),+ },+ deliveryProfiles: { list: (params) => sellerClient().deliveryProfiles.list(params) },})return clientdiff --git a/packages/seller-dashboard/src/pages/product.tsx b/packages/seller-dashboard/src/pages/product.tsxindex 5611704317..ea89caf789 100644--- a/packages/seller-dashboard/src/pages/product.tsx+++ b/packages/seller-dashboard/src/pages/product.tsx@@ -1,5 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import {+ CategorizationCard,GeneralCard,InventoryCard,MediaCard,@@ -35,9 +36,11 @@ const PRODUCT_EXPAND = 'variants,media,default_variant,submission'* The same cards the operator's dashboard renders, in the same order, from* `@spree/dashboard-core` — the two forms are one form, and the differences* are only what a seller may not do. Publishing to channels and tax category- * are absent because they are marketplace configuration, and status is not a- * field here at all: a seller submits for review and the marketplace decides- * (docs/plans/6.0-seller-product-submission.md).+ * are absent because they are marketplace configuration, the Categorization+ * card offers only the product type and delivery profile (filing a listing+ * under categories, collections and tags is the operator's at review), and+ * status is not a field here at all: a seller submits for review and the+ * marketplace decides (docs/plans/6.0-seller-product-submission.md).*/export function ProductPage({ mode }: { mode: 'new' | 'edit' }) {const { t } = useTranslation()@@ -99,6 +102,11 @@ export function ProductPage({ mode }: { mode: 'new' | 'edit' }) {slug: values.slug || undefined,meta_title: values.meta_title ?? undefined,meta_description: values.meta_description ?? undefined,+ // Null is a real value here — it detaches the type. The profile has+ // no such state: a product always ships under one, so an empty pick+ // means "leave it".+ product_type_id: values.product_type_id ?? null,+ delivery_profile_id: values.delivery_profile_id ?? undefined,// Both lists are the whole intent: anything the seller removed is// absent here, which is what tells the API to drop it.// The video address and the focal point ride along because the@@ -208,16 +216,18 @@ export function ProductPage({ mode }: { mode: 'new' | 'edit' }) {</>}sidebar={- productId &&- product && (- <ProductStatusCard- product={product}- onDone={() => {- void queryClient.invalidateQueries({ queryKey: productKey })- void queryClient.invalidateQueries({ queryKey: ['seller-products'] })- }}- />- )+ <>+ {productId && product && (+ <ProductStatusCard+ product={product}+ onDone={() => {+ void queryClient.invalidateQueries({ queryKey: productKey })+ void queryClient.invalidateQueries({ queryKey: ['seller-products'] })+ }}+ />+ )}+ <CategorizationCard form={form} />+ </>}/></form>diff --git a/packages/seller-sdk/src/seller-client.ts b/packages/seller-sdk/src/seller-client.tsindex 202e85bed3..fb7c0b5e9e 100644--- a/packages/seller-sdk/src/seller-client.ts+++ b/packages/seller-sdk/src/seller-client.ts@@ -2,6 +2,7 @@ import type { ListParams, PaginatedResponse, RequestFn, RequestOptions } from '@import { transformListParams } from '@spree/sdk-core'import type {AuthTokens,+ DeliveryProfile,Export,Fulfillment,Import,@@ -10,6 +11,7 @@ import type {Order,Policy,Product,+ ProductType,Profile,RequirementStatus,RequirementSubmission,@@ -451,6 +453,41 @@ export class SellerClient {this.request<Export>('GET', `/exports/${id}`, options),}+ /**+ * The types a seller may list a product against. Read only — defining a+ * type is the operator's. A seller picks one because it is the template+ * that hands their product its option types and delivery profile.+ */+ readonly productTypes = {+ list: (+ params?: ListParams & Record<string, unknown>,+ options?: RequestOptions,+ ): Promise<PaginatedResponse<ProductType>> =>+ this.request<PaginatedResponse<ProductType>>('GET', '/product_types', {+ ...options,+ params: params ? transformListParams(params) : undefined,+ }),++ get: (id: string, options?: RequestOptions): Promise<ProductType> =>+ this.request<ProductType>('GET', `/product_types/${id}`, options),+ }++ /**+ * The marketplace's delivery profiles — what kind of goods a product is+ * (parcel, digital, pallet). Read only: a seller assigns one to their+ * product and never defines one.+ */+ readonly deliveryProfiles = {+ list: (+ params?: ListParams & Record<string, unknown>,+ options?: RequestOptions,+ ): Promise<PaginatedResponse<DeliveryProfile>> =>+ this.request<PaginatedResponse<DeliveryProfile>>('GET', '/delivery_profiles', {+ ...options,+ params: params ? transformListParams(params) : undefined,+ }),+ }+/*** Where this seller keeps stock, and so where their returns are sent.*@@ -749,6 +786,18 @@ export interface ProductParams {meta_description?: stringmeta_keywords?: stringmetadata?: Record<string, unknown>+ /**+ * The marketplace's type this product is listed against, from+ * `productTypes.list()`. `null` detaches it. Saving with a type seeds its+ * option types onto the product.+ */+ product_type_id?: string | null+ /**+ * Which of the marketplace's delivery profiles the product ships under,+ * from `deliveryProfiles.list()`. A new product sent without one lands on+ * the profile marked `default`.+ */+ delivery_profile_id?: string/*** The gallery, as a whole. A file absent from the list is removed, so send* every image the product should end up with. `signed_id` attaches a freshdiff --git a/packages/seller-sdk/src/types/generated/DeliveryProfile.ts b/packages/seller-sdk/src/types/generated/DeliveryProfile.tsnew file mode 100644index 0000000000..73d3995286--- /dev/null+++ b/packages/seller-sdk/src/types/generated/DeliveryProfile.ts@@ -0,0 +1,11 @@+// Typelizer digest 8ce4c1bf5263e2261b9440cdb0e3c3cb+//+// DO NOT MODIFY: This file was automatically generated by Typelizer.++type DeliveryProfile = {+ id: string;+ name: string;+ default: boolean;+}++export default DeliveryProfile;diff --git a/packages/seller-sdk/src/types/generated/Product.ts b/packages/seller-sdk/src/types/generated/Product.tsindex 3ce67ab98f..28e5294464 100644--- a/packages/seller-sdk/src/types/generated/Product.ts+++ b/packages/seller-sdk/src/types/generated/Product.ts@@ -1,4 +1,4 @@-// Typelizer digest 0430e027945117a3c2381da52f2b51d3+// Typelizer digest 96daad199da6294cf8e52999a9a37200//// DO NOT MODIFY: This file was automatically generated by Typelizer.import type {Price, PriceHistory, ProductSubmission, Seller, Media, Variant, OptionType, OptionValue, Category, CustomField} from '@/types'@@ -41,6 +41,8 @@ type Product = {metadata: Record<string, unknown>;created_at: string;updated_at: string;+ product_type_id: string | null;+ delivery_profile_id: string | null;submission?: ProductSubmission | null;}diff --git a/packages/seller-sdk/src/types/generated/ProductType.ts b/packages/seller-sdk/src/types/generated/ProductType.tsnew file mode 100644index 0000000000..01b4148c06--- /dev/null+++ b/packages/seller-sdk/src/types/generated/ProductType.ts@@ -0,0 +1,11 @@+// Typelizer digest 02cf0ec6fcb0a1c8c444accc4d080a3c+//+// DO NOT MODIFY: This file was automatically generated by Typelizer.++type ProductType = {+ id: string;+ name: string;+ option_type_labels: Array<string>;+}++export default ProductType;diff --git a/packages/seller-sdk/src/types/generated/index.ts b/packages/seller-sdk/src/types/generated/index.tsindex e78f04d205..a2a0ee3b7f 100644--- a/packages/seller-sdk/src/types/generated/index.ts+++ b/packages/seller-sdk/src/types/generated/index.ts@@ -1,4 +1,4 @@-// Typelizer digest cf0f09dbd45d4d3d524ee7e96a73cb1c+// Typelizer digest be09aa60aec3b0dbb7406d6375c4910e//// DO NOT MODIFY: This file was automatically generated by Typelizer.export type { default as Address } from './Address'@@ -8,6 +8,7 @@ export type { default as OptionType } from './OptionType'export type { default as OptionValue } from './OptionValue'export type { default as PriceHistory } from './PriceHistory'export type { default as Price } from './Price'+export type { default as DeliveryProfile } from './DeliveryProfile'export type { default as Export } from './Export'export type { default as FulfillmentItem } from './FulfillmentItem'export type { default as Fulfillment } from './Fulfillment'@@ -21,6 +22,7 @@ export type { default as Order } from './Order'export type { default as Policy } from './Policy'export type { default as Product } from './Product'export type { default as ProductSubmission } from './ProductSubmission'+export type { default as ProductType } from './ProductType'export type { default as Profile } from './Profile'export type { default as RequirementCustomField } from './RequirementCustomField'export type { default as RequirementStatus } from './RequirementStatus'diff --git a/spree/api/app/controllers/spree/api/v3/seller/delivery_profiles_controller.rb b/spree/api/app/controllers/spree/api/v3/seller/delivery_profiles_controller.rbnew file mode 100644index 0000000000..5ff69bc2f6--- /dev/null+++ b/spree/api/app/controllers/spree/api/v3/seller/delivery_profiles_controller.rb@@ -0,0 +1,37 @@+module Spree+ module Api+ module V3+ module Seller+ # The marketplace's delivery profiles — what kind of goods a product+ # is (parcel, digital, pallet), which decides how it can be shipped.+ #+ # Read only: a seller assigns a profile to their product and never+ # defines one, since the profile is the vocabulary the marketplace's+ # zones and methods hang off+ # (docs/plans/6.0-multi-vendor-marketplace.md, Decision 13).+ #+ # Gated on `read_products` rather than the operator's `settings` key,+ # which a seller must never hold: this list exists for the product+ # form's picker, so a key that may read products may read the+ # vocabulary that form fills in.+ class DeliveryProfilesController < Seller::ResourceController+ scoped_resource :products++ protected++ def model_class+ Spree::DeliveryProfile+ end++ def serializer_class+ Spree.api.seller_delivery_profile_serializer+ end++ def scope+ current_store.delivery_profiles+ end+ end+ end+ end+ end+enddiff --git a/spree/api/app/controllers/spree/api/v3/seller/product_types_controller.rb b/spree/api/app/controllers/spree/api/v3/seller/product_types_controller.rbnew file mode 100644index 0000000000..70e373b806--- /dev/null+++ b/spree/api/app/controllers/spree/api/v3/seller/product_types_controller.rb@@ -0,0 +1,35 @@+module Spree+ module Api+ module V3+ module Seller+ # The product types a seller may list against.+ #+ # Read only, and deliberately so: a seller picks a type because it is+ # the template that hands their product its option types and delivery+ # profile, but what types the marketplace offers is the operator's+ # decision (docs/plans/6.0-seller-product-submission.md, Decision 5).+ #+ # Types belong to the store rather than to a seller, so this is one of+ # the few seller collections not rooted in `current_seller` — the+ # store comes from the seller, which is what keeps it scoped.+ class ProductTypesController < Seller::ResourceController+ scoped_resource :product_types++ protected++ def model_class+ Spree::ProductType+ end++ def serializer_class+ Spree.api.seller_product_type_serializer+ end++ def scope+ current_store.product_types+ end+ end+ end+ end+ end+enddiff --git a/spree/api/app/controllers/spree/api/v3/seller/products_controller.rb b/spree/api/app/controllers/spree/api/v3/seller/products_controller.rbindex ceb3e351b5..48d4822382 100644--- a/spree/api/app/controllers/spree/api/v3/seller/products_controller.rb+++ b/spree/api/app/controllers/spree/api/v3/seller/products_controller.rb@@ -16,10 +16,14 @@ module Spree# phase) and do not belong to this seller through `products`.## What a seller may change is narrower than the operator's set. Tax- # category, delivery profile and `promotionable` are marketplace- # configuration, and so is how a product is filed: its type,- # categories, collections and tags are the marketplace's own- # merchandising, set when the operator reviews the listing.+ # category and `promotionable` are marketplace configuration, and so+ # is how a product is filed: categories, collections and tags are the+ # marketplace's own merchandising, set when the operator reviews the+ # listing. The product type and the delivery profile are the seller's+ # to pick — from the marketplace's list — because the type is what+ # hands their product its option types, and the profile is what+ # decides how their goods can be shipped at all+ # (docs/plans/6.0-multi-vendor-marketplace.md, Decision 13).## Tags are the clearest case — they are tenanted to the store# (`acts_as_taggable_tenant :store_id`), so a seller typing one would@@ -164,6 +168,7 @@ module Spreeattrs = params.permit(:name, :description, :slug,:meta_title, :meta_description, :meta_keywords,+ :product_type_id, :delivery_profile_id,metadata: {},prices: [:amount, :compare_at_amount, :currency],# Inline media, the same shape the operator sends. `external_url`@@ -191,6 +196,8 @@ module Spree# `stock_levels` key reaches the association setter as nil, which# raises rather than meaning "leave alone".attrs[:prices] = default_price_currencies(attrs[:prices]) if attrs.key?(:prices)+ attrs[:product_type_id] = own_product_type_id(attrs[:product_type_id]) if attrs.key?(:product_type_id)+ attrs[:delivery_profile_id] = own_delivery_profile_id(attrs[:delivery_profile_id]) if attrs.key?(:delivery_profile_id)attrs[:variants] = attrs[:variants]&.map do |variant|variant = variant.merge(prices: default_price_currencies(variant[:prices])) if variant.key?(:prices)@@ -215,6 +222,25 @@ module Spreeendend+ # A type or a profile is picked from the marketplace's own list, so+ # the id is resolved against this seller's store here rather than+ # handed to the model: a type from another store would seed its+ # option types onto the product, and a picker value that cannot+ # exist for this seller is a 404, not a validation error. Blank+ # detaches the type; a product always carries a profile, so blank+ # there is left for the model to refuse.+ def own_product_type_id(value)+ return nil if value.blank?++ current_store.product_types.find_by_prefix_id!(value).id+ end++ def own_delivery_profile_id(value)+ return nil if value.blank?++ current_store.delivery_profiles.find_by_prefix_id!(value).id+ end+# Stock belongs to the warehouse it sits in, and a seller has their# own. `Variant#stock_levels=` resolves a location against the# product's *store*, which on a marketplace spans every seller — so adiff --git a/spree/api/app/serializers/spree/api/v3/seller/delivery_profile_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/delivery_profile_serializer.rbnew file mode 100644index 0000000000..583e419bed--- /dev/null+++ b/spree/api/app/serializers/spree/api/v3/seller/delivery_profile_serializer.rb@@ -0,0 +1,19 @@+module Spree+ module Api+ module V3+ module Seller+ # A delivery profile as a seller picks it: a name, and whether it is+ # the one a product lands on when they pick none.+ #+ # Declared rather than subclassed from the admin serializer, like every+ # serializer on this branch: which warehouses and methods sit behind a+ # profile is the marketplace's configuration, not a seller's to read.+ class DeliveryProfileSerializer < BaseSerializer+ typelize name: :string, default: :boolean++ attributes :name, :default+ end+ end+ end+ end+enddiff --git a/spree/api/app/serializers/spree/api/v3/seller/product_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/product_serializer.rbindex 4360619426..948792847a 100644--- a/spree/api/app/serializers/spree/api/v3/seller/product_serializer.rb+++ b/spree/api/app/serializers/spree/api/v3/seller/product_serializer.rb@@ -7,15 +7,27 @@ module Spree# Read and write have to name the same fields: the panel loads a# product into a form and sends it back, so anything the controller# accepts but this withholds would be blanked on save. The reverse- # matters too — how a product is filed (type, categories, collections,- # tags) is the marketplace's own merchandising, so it is neither- # written nor read here.+ # matters too — how a product is filed (categories, collections, tags)+ # is the marketplace's own merchandising, so it is neither written nor+ # read here. The type and the delivery profile are: a seller picks+ # both from the marketplace's list+ # (docs/plans/6.0-multi-vendor-marketplace.md, Decision 13).class ProductSerializer < V3::ProductSerializertypelize status: :string, metadata: 'Record<string, unknown>',+ product_type_id: [:string, nullable: true],+ delivery_profile_id: [:string, nullable: true],submission: ['ProductSubmission', nullable: true]attributes :status, :metadata, created_at: :iso8601, updated_at: :iso8601+ attribute :product_type_id do |product|+ product.product_type&.prefixed_id+ end++ attribute :delivery_profile_id do |product|+ product.delivery_profile&.prefixed_id+ end+many :variants,resource: proc { Spree.api.seller_variant_serializer },if: proc { expand?('variants') }diff --git a/spree/api/app/serializers/spree/api/v3/seller/product_type_serializer.rb b/spree/api/app/serializers/spree/api/v3/seller/product_type_serializer.rbnew file mode 100644index 0000000000..a410937b4a--- /dev/null+++ b/spree/api/app/serializers/spree/api/v3/seller/product_type_serializer.rb@@ -0,0 +1,29 @@+module Spree+ module Api+ module V3+ module Seller+ # A product type as a seller sees it: something to list against, and+ # what picking it will bring.+ #+ # The option types are carried as **labels**, not as ids the client+ # then resolves. The operator's form looks them up against the option+ # types page it already loads, but a seller manages no option-type+ # vocabulary and has no such endpoint — sending ids alone would leave+ # the form unable to name them, and the warning it exists to show+ # would silently never appear.+ #+ # No `category_ids` (filing is the operator's, so a seller would be+ # shown a consequence they never see) and no `products_count` or+ # custom field schema, which describe how the operator maintains the+ # type rather than what listing against it does.+ class ProductTypeSerializer < V3::ProductTypeSerializer+ typelize option_type_labels: [:string, multi: true]++ attribute :option_type_labels do |product_type|+ product_type.option_types.map { |option_type| option_type.label.presence || option_type.name }.compact+ end+ end+ end+ end+ end+enddiff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rbindex a8bc83f834..970458272e 100644--- a/spree/api/config/routes.rb+++ b/spree/api/config/routes.rb@@ -873,6 +873,15 @@ Spree::Core::Engine.add_routes doresources :rows, only: [:index], controller: 'import_rows'end+ # The types a seller may list against. Read only — defining a type is+ # the operator's (docs/plans/6.0-seller-product-submission.md).+ resources :product_types, only: [:index, :show]++ # The marketplace's delivery vocabulary, for the product form's picker.+ # Read only: a seller assigns a profile, never creates one+ # (docs/plans/6.0-multi-vendor-marketplace.md, Decision 13).+ resources :delivery_profiles, only: [:index]+# No destroy: a location holds stock levels and is named on historical# fulfillments, so a seller retires one by deactivating it.resources :stock_locations, only: [:index, :show, :create, :update]diff --git a/spree/api/lib/spree/api/dependencies.rb b/spree/api/lib/spree/api/dependencies.rbindex 73edcf2b89..68162ce03f 100644--- a/spree/api/lib/spree/api/dependencies.rb+++ b/spree/api/lib/spree/api/dependencies.rb@@ -172,6 +172,8 @@ module Spreeseller_team_member_serializer: 'Spree::Api::V3::Seller::TeamMemberSerializer',seller_invitation_serializer: 'Spree::Api::V3::Seller::InvitationSerializer',seller_product_serializer: 'Spree::Api::V3::Seller::ProductSerializer',+ seller_product_type_serializer: 'Spree::Api::V3::Seller::ProductTypeSerializer',+ seller_delivery_profile_serializer: 'Spree::Api::V3::Seller::DeliveryProfileSerializer',seller_variant_serializer: 'Spree::Api::V3::Seller::VariantSerializer',seller_media_serializer: 'Spree::Api::V3::Seller::MediaSerializer',seller_stock_level_serializer: 'Spree::Api::V3::Seller::StockLevelSerializer',diff --git a/spree/api/spec/controllers/spree/api/v3/seller/delivery_profiles_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/delivery_profiles_controller_spec.rbnew file mode 100644index 0000000000..e3f4ecf306--- /dev/null+++ b/spree/api/spec/controllers/spree/api/v3/seller/delivery_profiles_controller_spec.rb@@ -0,0 +1,60 @@+require 'spec_helper'++RSpec.describe Spree::Api::V3::Seller::DeliveryProfilesController, type: :controller do+ render_views++ include_context 'API v3 Seller'++ let(:token) do+ Spree::Api::V3::TestingSupport.generate_jwt(+ seller_user, audience: Spree::Api::V3::JwtAuthentication::JWT_AUDIENCE_SELLER+ )+ end++ let!(:profile) { create(:delivery_profile, store: store, name: 'Oversized') }++ before do+ request.headers['Authorization'] = "Bearer #{token}"+ request.headers['X-Spree-Seller-Id'] = seller.prefixed_id+ end++ describe 'GET #index' do+ it "lists the store's profiles so a seller can pick one" do+ get :index, as: :json++ expect(response).to have_http_status(:ok)+ expect(json_response['data'].pluck('name')).to include('Oversized')+ expect(json_response['data'].first.keys).to contain_exactly('id', 'name', 'default')+ end++ it "leaves out another store's profiles" do+ elsewhere = create(:delivery_profile, store: create(:store), name: 'Elsewhere')++ get :index, as: :json++ expect(json_response['data'].pluck('id')).not_to include(elsewhere.prefixed_id)+ end++ # The list exists for the product form, so it opens with the key that+ # reads products — never the operator's settings key.+ context 'without read_products' do+ let(:seller_role) { create(:role, name: 'Seller', resource: seller, permissions: %w[read_orders]) }++ it 'is forbidden' do+ get :index, as: :json++ expect(response).to have_http_status(:forbidden)+ end+ end+ end++ # A seller assigns a profile and never defines one.+ describe 'anything but listing' do+ it 'is not routable' do+ expect(get: '/api/v3/seller/delivery_profiles/dp_x').not_to be_routable+ expect(post: '/api/v3/seller/delivery_profiles').not_to be_routable+ expect(patch: '/api/v3/seller/delivery_profiles/dp_x').not_to be_routable+ expect(delete: '/api/v3/seller/delivery_profiles/dp_x').not_to be_routable+ end+ end+enddiff --git a/spree/api/spec/controllers/spree/api/v3/seller/product_types_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/product_types_controller_spec.rbnew file mode 100644index 0000000000..13849df80b--- /dev/null+++ b/spree/api/spec/controllers/spree/api/v3/seller/product_types_controller_spec.rb@@ -0,0 +1,100 @@+require 'spec_helper'++RSpec.describe Spree::Api::V3::Seller::ProductTypesController, type: :controller do+ render_views++ include_context 'API v3 Seller'++ let(:seller_user) do+ create(:admin_user, :without_admin_role).tap { |user| seller.add_user(user, seller_role) }+ end+ let(:seller_role) do+ create(:role, name: 'Seller', resource: seller, permissions: %w[write_products read_product_types])+ end+ let(:token) do+ Spree::Api::V3::TestingSupport.generate_jwt(+ seller_user, audience: Spree::Api::V3::JwtAuthentication::JWT_AUDIENCE_SELLER+ )+ end++ let!(:product_type) { create(:product_type, store: store, name: 'Apparel') }++ before do+ request.headers['Authorization'] = "Bearer #{token}"+ request.headers['X-Spree-Seller-Id'] = seller.prefixed_id+ end++ describe 'GET #index' do+ it "lists the store's types so a seller can pick one" do+ get :index, as: :json++ expect(response).to have_http_status(:ok)+ expect(json_response['data'].pluck('name')).to include('Apparel')+ end++ it "leaves out another store's types" do+ elsewhere = create(:product_type, store: create(:store), name: 'Elsewhere')++ get :index, as: :json++ expect(json_response['data'].pluck('id')).not_to include(elsewhere.prefixed_id)+ end++ context 'without read_product_types' do+ let(:seller_role) { create(:role, name: 'Seller', resource: seller, permissions: %w[write_products]) }++ it 'is forbidden' do+ get :index, as: :json++ expect(response).to have_http_status(:forbidden)+ end+ end+ end++ describe 'GET #show' do+ it 'returns the type' do+ get :show, params: { id: product_type.prefixed_id }, as: :json++ expect(response).to have_http_status(:ok)+ expect(json_response['name']).to eq('Apparel')+ end++ # The form warns a seller which options the type is about to add to their+ # variants. Labels, not ids: a seller manages no option-type vocabulary+ # and has no endpoint to resolve ids against, so ids alone would leave the+ # warning permanently blank.+ it 'names the option types picking it will add' do+ typed = create(:product_type_with_option_types, store: store)+ expected = typed.option_types.map { |option_type| option_type.label.presence || option_type.name }++ get :show, params: { id: typed.prefixed_id }, as: :json++ expect(json_response['option_type_labels']).to match_array(expected)+ expect(json_response['option_type_labels']).to all(be_present)+ end++ it 'answers an empty list for a type that adds no options' do+ get :show, params: { id: product_type.prefixed_id }, as: :json++ expect(json_response['option_type_labels']).to eq([])+ end++ # Filing is the operator's, so a seller is never shown a consequence they+ # cannot see the result of.+ it 'withholds the categories the type files under' do+ get :show, params: { id: product_type.prefixed_id }, as: :json++ expect(json_response).not_to include('category_ids', 'products_count', 'custom_field_definitions')+ end+ end++ # Defining types is the operator's. A seller sees them to pick one; there is+ # no route here to create, edit or delete one.+ describe 'writing a type' do+ it 'is not routable' do+ expect(post: '/api/v3/seller/product_types').not_to be_routable+ expect(patch: '/api/v3/seller/product_types/pt_x').not_to be_routable+ expect(delete: '/api/v3/seller/product_types/pt_x').not_to be_routable+ end+ end+enddiff --git a/spree/api/spec/controllers/spree/api/v3/seller/products_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/seller/products_controller_spec.rbindex e798b645ad..c649b8f859 100644--- a/spree/api/spec/controllers/spree/api/v3/seller/products_controller_spec.rb+++ b/spree/api/spec/controllers/spree/api/v3/seller/products_controller_spec.rb@@ -105,6 +105,46 @@ RSpec.describe Spree::Api::V3::Seller::ProductsController, type: :controller docurrencies = Spree::Product.find_by(name: 'Euro Lamp').default_variant.prices.map(&:currency)expect(currencies).to eq(['EUR'])end++ # Create is where the type's delivery profile is stamped — the template+ # fires on create only, so a seller who picks a type gets its profile and+ # nothing later moves it.+ it "takes the type's delivery profile when the seller picks a type" do+ profile = create(:delivery_profile, store: store, name: 'Oversized')+ product_type = create(:product_type, store: store, delivery_profile: profile)++ post :create,+ params: { name: 'Typed Lamp', product_type_id: product_type.prefixed_id },+ as: :json++ expect(response).to have_http_status(:created)+ product = Spree::Product.find_by(name: 'Typed Lamp')+ expect(product.product_type).to eq(product_type)+ expect(product.delivery_profile).to eq(profile)+ end++ # The seller's own pick wins over the type's template.+ it 'ships under the profile the seller named' do+ chosen = create(:delivery_profile, store: store, name: 'Pallet')++ post :create,+ params: { name: 'Heavy Lamp', delivery_profile_id: chosen.prefixed_id },+ as: :json++ expect(response).to have_http_status(:created)+ expect(Spree::Product.find_by(name: 'Heavy Lamp').delivery_profile).to eq(chosen)+ end++ # Nothing regressed for a seller who picks neither: the store default is+ # what every seller product landed on before this endpoint offered a+ # choice at all.+ it "falls back to the store's default profile when the seller picks none" do+ post :create, params: { name: 'Plain Lamp' }, as: :json++ expect(response).to have_http_status(:created)+ expect(Spree::Product.find_by(name: 'Plain Lamp').delivery_profile).+ to eq(Spree::DeliveryProfile.default_for(store))+ endend# A seller lists; the marketplace decides what goes on sale. These are the@@ -178,10 +218,13 @@ RSpec.describe Spree::Api::V3::Seller::ProductsController, type: :controller do# seller serializer adds none of it — a field a seller cannot change should# not be shown as though they could. (`tags` rides in from the storefront# serializer, where it is public product data; it is simply not writable.)+ # The type and the delivery profile are the seller's to pick, so those two+ # are read back for the form.it 'withholds the marketplace merchandising fields' doget :show, params: { id: mine.prefixed_id }, as: :json- expect(json_response).not_to include('product_type_id', 'category_ids', 'collection_ids')+ expect(json_response).not_to include('category_ids', 'collection_ids')+ expect(json_response).to include('product_type_id', 'delivery_profile_id')end# The form loads a product with everything it edits in one request, so each@@ -283,15 +326,60 @@ RSpec.describe Spree::Api::V3::Seller::ProductsController, type: :controller doexpect(mine.reload.categories).to be_emptyend- it 'cannot set a product type' do- product_type = create(:product_type, store: store)+ # The type is the seller's to pick: it is what hands their product its+ # option types (docs/plans/6.0-multi-vendor-marketplace.md, Decision 13).+ it "lists the product against one of the marketplace's types" do+ product_type = create(:product_type_with_option_types, store: store)patch :update, params: { id: mine.prefixed_id, product_type_id: product_type.prefixed_id }, as: :jsonexpect(response).to have_http_status(:ok)+ expect(json_response['product_type_id']).to eq(product_type.prefixed_id)+ expect(mine.reload.product_type).to eq(product_type)+ expect(mine.option_types).to match_array(product_type.option_types)+ end++ it 'detaches the type when sent null' do+ mine.update!(product_type: create(:product_type, store: store))++ patch :update, params: { id: mine.prefixed_id, product_type_id: nil }, as: :json++ expect(response).to have_http_status(:ok)+ expect(mine.reload.product_type).to be_nil+ end++ # 404, not 422: a type from another store cannot exist for this seller,+ # and letting the model see it would seed that store's option types.+ it "404s on another store's product type" do+ elsewhere = create(:product_type, store: create(:store))++ patch :update, params: { id: mine.prefixed_id, product_type_id: elsewhere.prefixed_id }, as: :json++ expect(response).to have_http_status(:not_found)expect(mine.reload.product_type).to be_nilend+ # The profile decides how the goods can be shipped, so a seller picks it+ # rather than every listing landing on the store default.+ it "ships the product under one of the marketplace's delivery profiles" do+ profile = create(:delivery_profile, store: store, name: 'Oversized')++ patch :update, params: { id: mine.prefixed_id, delivery_profile_id: profile.prefixed_id }, as: :json++ expect(response).to have_http_status(:ok)+ expect(json_response['delivery_profile_id']).to eq(profile.prefixed_id)+ expect(mine.reload.delivery_profile).to eq(profile)+ end++ it "404s on another store's delivery profile" do+ elsewhere = create(:delivery_profile, store: create(:store))++ patch :update, params: { id: mine.prefixed_id, delivery_profile_id: elsewhere.prefixed_id }, as: :json++ expect(response).to have_http_status(:not_found)+ expect(mine.reload.delivery_profile).not_to eq(elsewhere)+ end+# Marketplace configuration, not a seller's: silently ignored rather than# refused, the same way tax and delivery already are on this endpoint.# Asserted on the column, since the reader falls back to the store default.diff --git a/spree/api/spec/integration/spree/api/v3/seller/delivery_profiles_spec.rb b/spree/api/spec/integration/spree/api/v3/seller/delivery_profiles_spec.rbnew file mode 100644index 0000000000..5ed99277d1--- /dev/null+++ b/spree/api/spec/integration/spree/api/v3/seller/delivery_profiles_spec.rb@@ -0,0 +1,47 @@+# frozen_string_literal: true++require 'swagger_helper'++RSpec.describe 'Seller Delivery Profiles API', type: :request, swagger_doc: 'api-reference/seller.yaml' do+ include_context 'API v3 Seller'++ let!(:delivery_profile) { create(:delivery_profile, store: store, name: 'Oversized') }++ path '/api/v3/seller/delivery_profiles' do+ get 'List delivery profiles' do+ tags 'Delivery Profiles'+ produces 'application/json'+ security [bearer_auth: []]+ description <<~DESC+ The marketplace's delivery profiles — what kind of goods a product is+ (parcel, digital, pallet), which decides how it can be shipped.++ Read only. A seller assigns one to a product as `delivery_profile_id`;+ the profiles themselves, and the zones and methods behind them, are the+ marketplace's. A product created without one lands on the profile+ marked `default`.+ DESC++ parameter name: 'X-Spree-Seller-Id', in: :header, type: :string, required: true+ parameter name: :page, in: :query, type: :integer, required: false, description: 'Page number'+ parameter name: :limit, in: :query, type: :integer, required: false, description: 'Records per page (max 100)'++ response '200', 'delivery profiles listed' do+ let(:Authorization) { "Bearer #{seller_jwt_token}" }+ let(:'X-Spree-Seller-Id') { seller.prefixed_id }++ schema type: :object,+ properties: {+ data: { type: :array, items: { '$ref' => '#/components/schemas/DeliveryProfile' } },+ meta: { '$ref' => '#/components/schemas/PaginationMeta' }+ },+ required: %w[data meta]++ run_test! do |response|+ data = JSON.parse(response.body)['data']+ expect(data.map { |item| item['id'] }).to include(delivery_profile.prefixed_id)+ end+ end+ end+ end+enddiff --git a/spree/api/spec/integration/spree/api/v3/seller/product_types_spec.rb b/spree/api/spec/integration/spree/api/v3/seller/product_types_spec.rbnew file mode 100644index 0000000000..e1d51ba7e5--- /dev/null+++ b/spree/api/spec/integration/spree/api/v3/seller/product_types_spec.rb@@ -0,0 +1,75 @@+# frozen_string_literal: true++require 'swagger_helper'++RSpec.describe 'Seller Product Types API', type: :request, swagger_doc: 'api-reference/seller.yaml' do+ include_context 'API v3 Seller'++ # Types are read under their own key, which the shared context's+ # products-only role omits.+ let(:seller_role) do+ create(:role, name: 'Seller', resource: seller, permissions: %w[write_products read_product_types])+ end++ let!(:product_type) { create(:product_type, store: store, name: 'Apparel') }++ path '/api/v3/seller/product_types' do+ get 'List product types' do+ tags 'Product Types'+ produces 'application/json'+ security [bearer_auth: []]+ description <<~DESC+ The product types a seller may list a product against.++ Read only. A type is the template that hands a product its option types+ and its delivery profile, so a seller picks one when listing; defining+ types is the marketplace's. Send the chosen `id` as `product_type_id`+ on the product.+ DESC++ parameter name: 'X-Spree-Seller-Id', in: :header, type: :string, required: true+ parameter name: :page, in: :query, type: :integer, required: false, description: 'Page number'+ parameter name: :limit, in: :query, type: :integer, required: false, description: 'Records per page (max 100)'++ response '200', 'product types listed' do+ let(:Authorization) { "Bearer #{seller_jwt_token}" }+ let(:'X-Spree-Seller-Id') { seller.prefixed_id }++ schema type: :object,+ properties: {+ data: { type: :array, items: { '$ref' => '#/components/schemas/ProductType' } },+ meta: { '$ref' => '#/components/schemas/PaginationMeta' }+ },+ required: %w[data meta]++ run_test! do |response|+ data = JSON.parse(response.body)['data']+ expect(data.map { |item| item['id'] }).to include(product_type.prefixed_id)+ end+ end+ end+ end++ path '/api/v3/seller/product_types/{id}' do+ get 'Get a product type' do+ tags 'Product Types'+ produces 'application/json'+ security [bearer_auth: []]++ parameter name: 'X-Spree-Seller-Id', in: :header, type: :string, required: true+ parameter name: :id, in: :path, type: :string, required: true, description: 'Product type ID'++ response '200', 'product type found' do+ let(:Authorization) { "Bearer #{seller_jwt_token}" }+ let(:'X-Spree-Seller-Id') { seller.prefixed_id }+ let(:id) { product_type.prefixed_id }++ schema '$ref' => '#/components/schemas/ProductType'++ run_test! do |response|+ expect(JSON.parse(response.body)['name']).to eq('Apparel')+ end+ end+ end+ end+enddiff --git a/spree/api/spec/swagger_helper.rb b/spree/api/spec/swagger_helper.rbindex 2ea925c2a2..99e9a6435e 100644--- a/spree/api/spec/swagger_helper.rb+++ b/spree/api/spec/swagger_helper.rb@@ -281,8 +281,10 @@ RSpec.configure do |config|{ name: 'Authentication', description: 'Seller sign-in, token refresh, logout, and invitation acceptance' },{ name: 'Account', description: 'The signed-in user, the sellers they may act for, and what they may do' },{ name: 'Countries', description: 'Country and state reference data for the panel\'s address forms' },+ { name: 'Delivery Profiles', description: "The marketplace's delivery vocabulary — what kind of goods a product is, which decides how it ships" },{ name: 'Onboarding', description: 'The marketplace checklist a seller completes before admission, and what they submit against it' },{ name: 'Policies', description: "The seller's own legal documents, as the marketplace asks them to publish" },+ { name: 'Product Types', description: 'The types a seller may list a product against, and what each adds' },{ name: 'Products', description: "The seller's own catalog" },{ name: 'Profile', description: "The seller's own record — presentation, contact details, addresses, and tax registration" },{ name: 'Stock Locations', description: 'Where the seller keeps stock, and so where their returns are sent' },