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.
Seller Order Management
Status: Draft — designed, nothing built
Target: Spree 6.0
Depends on: 6.0-multi-vendor-marketplace.md (Seller identity, the /api/v3/seller branch, order splitting, the fund ledger — all shipped), 6.0-returns-exchanges-claims.md (Return/Exchange/Claim + their fifteen workflows — shipped), 6.0-fulfillment-and-delivery.md (Fulfillment status model, Fulfillments::Fulfill/Cancel/Resume — shipped), 6.0-admin-spa.md (panel composition, the three-package split)
Author: Damian Legawiec
Last updated: 2026-09-05
Summary
The seller panel's order screens are a hand-rolled minimum — a flat list of items, one tracking input, and a cancel button — while the operator dashboard grew a full order surface: a fulfillments card with carrier-aware tracking, partial fulfillment and splitting, and cards for returns, exchanges and claims. A seller running their own back office needs the same operations on their own orders, because on a marketplace the seller is the merchant of record for their child order: they pack it, post it, take the goods back and make the customer whole.
This plan rebuilds the seller order views to match the dashboard's, and adds the seller-branch endpoints they need. It is deliberately a port of an existing, proven surface rather than a new design: the operator dashboard's components are the reference, and the seller panel reproduces their structure and vocabulary with an operator-only subset removed.
Key Decisions (do not deviate without discussion)
1. A seller may refund their own orders — restoring legacy behavior, and this amends the marketplace plan
6.0-multi-vendor-marketplace.md says twice that a seller gets no refunds — "What a seller may not do (publish to channels, edit orders, refund, approve itself…) is an endpoint that does not exist" (Decision 10) and "No refunds, order edits, approvals, payments" (the Phase 4 scope note). Both are wrong about the module they are opening up, and this plan supersedes them on that one point.
The legacy Enterprise multi-vendor module granted vendors the whole money-back surface, scoped to their own orders, in SpreeMultiVendor::PermissionSets::VendorUser#apply_returns_permissions:
can :create, Spree::Refund
can :manage, Spree::Refund, payment: { order: { vendor_id: @vendor_ids } }
can :create, Spree::Reimbursement
can :manage, Spree::Reimbursement, order: { vendor_id: @vendor_ids }
can :manage, Spree::ReturnAuthorization, order: { vendor_id: @vendor_ids }
can :manage, Spree::CustomerReturn, stock_location: { vendor_id: @vendor_ids }
can :manage, Spree::ReturnItem, inventory_unit: { order: { vendor_id: @vendor_ids } }
can :read, Spree::RefundReason
can :read, Spree::ReimbursementType
Reimbursement was 5.x's money-back mechanism and Refund is the gateway refund itself. The module shipped no return screens of its own — vendors reached the stock admin order tabs, narrowed by that permission set. So refunding is shipped Enterprise behavior a marketplace operator already relies on, not new latitude, and opening the marketplace core without it would be a regression for every migrating customer.
The commercial logic agrees. A seller is merchant of record for their child order (the marketplace plan's own transfer-basis decision: consumer tax and shipping revenue are theirs). The party who owes the customer their money back is the party who took it. Routing every seller refund through the operator makes the operator a ticket queue for other people's customer service, which is exactly the cost a marketplace exists to avoid.
What bounds it is arithmetic, not permission. Three bounds hold, and all three are already in the code:
Returns::Refundrefuses an amount abovereturn_record.refundable_total(refund_total - refunded_total), and a return belongs to exactly one seller's order — so a seller can only ask for what their own order's returned units are worth.Spree::Refund#order_is_covered_by_paymentvalidates which child a refund names — on a grouped payment theorder_idis required and must be named by one of the payment's splits.Spree::Refunds::Create#refundable_sharecaps the amount at that child's captured share, counting refunds from the rows rather than the split's subscriber-written figure (so two refunds landing together cannot each see an unrefunded share) and re-checking under the payment's row lock. It is the only path that creates aSpree::Refundanywhere in the codebase, so nothing bypasses it.
Legacy needed none of this because each sub-order carried its own real Payment row, so credit_allowed was already per-vendor. In 6.0 payments hang off the OrderGroup and the split is what attributes money to a child — refundable_share is where that lands.
Prerequisite (Decision 1a, revised 2026-09-03). The bound was never the problem; reaching the payment at all was. Returns::Refund, Claims::Resolve and Exchanges::Fulfill all drained order.payments.completed, which is empty on a grouped child — so all three failed with :no_refundable_payments on exactly the orders a seller refunds, and no spec covered the grouped case in any of them. They now share Spree::RefundsOrderPayments, which refunds through the order's payment_splits when grouped (skipping a share mid-capture, as Orders::Cancel does) and through order.payments when not. This is a correctness fix for operators too — refunds, claims and exchanges were broken on every marketplace order — so it lands as its own commit ahead of any seller work.
The reversal path needs nothing new either: a refund on a fulfilled order already writes a negative SellerTransfer (kind: 'refund_reversal', bounded by reversible_amount) through the shipped subscriber, so a seller refunding themselves correctly reduces their own payout.
Still not the seller's: the group's Payment (capture, void, adding a payment), order edits, approvals, and refunds on an order that is not theirs. Those remain endpoints that do not exist.
Cancelling refunds too (amended 2026-09-05). The seller cancel endpoint first shipped without refund_payments, on the reasoning that returning money already taken was the operator's call. That contradicted this very decision: a seller who withdraws from an order they cannot fulfil is the party who took that money, and routing the refund through the operator makes them a ticket queue exactly as described above. The endpoint now accepts refund_payments, and the seller panel offers the same switch the operator has.
The bound needs nothing new. Orders::Cancel#amount_paid sums only this order's payment_splits on a grouped order, and settle_grouped_payments refunds share by share, capped at each net_captured_amount and skipping any share mid-capture — so a seller cancelling can only reach their own child's money. refund_amount stays off the seller endpoint: withdrawing from the whole order returns what that order was paid, and a partial figure is a return, which has its own endpoint and its own ceiling.
2. The seller panel reproduces the dashboard's structure, minus operator-only cards
The order page becomes the same two-column ResourceLayout the dashboard uses, with the same card vocabulary in the same order. What a seller sees is a subset, decided per card by whether the seller owns the question:
| Card | Seller | Why |
|---|---|---|
| Fulfillments (tracking, partial fulfill, split, cancel/resume) | yes | the seller packs and posts |
| Returns / Exchanges / Claims | yes | the seller takes the goods back and makes it right |
| Order summary (totals) | yes | already serialized, never rendered today |
| Items, both addresses, customer note | yes | merchant of record |
| Customer (name only) | yes, without email | see Decision 3 |
| Payments, tax lines, discounts, fees | no | the marketplace's money surface |
| Purchase order, internal note, tags, marketplace card, digital links, custom fields, metadata | no | operator bookkeeping |
Amended 2026-11-02: order custom fields that shoppers can write at checkout (
storefront_writable, 6.1) are the exception: sellers see them read-only on their order view, and they are copied to each seller's split order, because the seller who ships needs the delivery date or gift message. Admin-only custom fields stay hidden. See6.0-6.1-custom-fields-roadmap.md(Part 3).
The panel keeps composing from @spree/dashboard-ui and @spree/dashboard-core and does not import from @spree/dashboard — the operator app is not a library, and its components are wired to adminClient. Where a component is genuinely identical modulo its SDK, it is reimplemented against sellerClient() rather than parameterised across the two, because the two clients return different types and a shared generic component would have to be generic over both.
3. The customer's email stays hidden, and no new endpoint may leak it
Seller::OrderSerializer withholds the buyer's email deliberately, with the reasoning recorded in the class: it is the one contact detail that lets a marketplace's customer be taken off it, and packing, posting and invoicing need only the phone on the shipping address. Spree::Exports::Orders::SELLER_OMITTED_HEADERS drops it from the CSV for the same reason.
That rule now has to survive three new nested resources. Returns, exchanges and claims all reach order.customer transitively, so the seller serializers for them are declared from V3::BaseSerializer, never subclassed from their admin counterparts, and none of them expands a customer.
4. Reasons are read-only on the seller branch
Creating a return or a claim wants a reason, and the vocabulary (Spree::ReturnReason, Spree::ClaimReason) is the marketplace's to define — a Spree::NamedType the operator curates. Sellers get GET /seller/return_reasons and GET /seller/claim_reasons, index only, active rows, exactly as they already get product_types and delivery_profiles. No CRUD: a seller inventing private reasons would fragment the operator's reporting dimension.
5. Controllers are written scope-first, never subclassed from admin
The marketplace plan's Decision 10 is binding here: "Do not subclass admin controllers into the seller namespace — inherited current_store.* lookups are precisely the leak; share workflows and permitted-param lists, never controllers." Every new controller roots at current_seller_orders and reaches its records through the order, so a foreign id is a 404 by construction rather than a 403 by rule.
The workflows are shared unchanged — Spree.return_*_workflow, Spree.claim_*_workflow, Spree.exchange_*_workflow, Spree.fulfillment_*_workflow — so hooks, emails, tax credits and ledger reversals fire identically whoever triggers them.
6. No new permission keys
Spree::Return, Spree::Exchange and Spree::Claim are already resources of the orders catalog scope, and orders is already audiences: %i[store seller]. So read_orders/write_orders gate all of this, and the seeded default seller role (which holds write_orders) needs no change. Spree::Refund is a subject of the separate refunds resource, which is not seller-grantable — but a seller refunds through Returns::Refund on their own return, not through the refunds endpoint, so no key changes there either. Adding refunds to the seller audience would open /admin-shaped refund creation and is explicitly not part of this.
7. Seller users are already the right principal
Return#created_by, Exchange#created_by and Claim#created_by are typed Spree.admin_user_class, and a seller's team member is an AdminUser (marketplace plan, Decision 10 — one class, several hats). So attribution works with no model change; a return a seller files records that seller's user.
Design Details
API surface added to /api/v3/seller
Nested under the seller's own order, mirroring the admin routes minus the money-surface ones:
resources :orders, only: [:index, :show] do
member { patch :cancel }
resources :fulfillments, only: [:index, :show], controller: 'orders/fulfillments' do
member do
patch :fulfill
patch :update # tracking number + carrier
patch :cancel
patch :resume
patch :split
patch :mark_delivered
end
end
resources :returns, only: [:index, :show, :create], controller: 'orders/returns' do
member { patch :approve; patch :receive; patch :refund; patch :cancel }
end
resources :exchanges, only: [:index, :show, :create], controller: 'orders/exchanges' do
member { patch :approve; patch :receive; patch :fulfill; patch :cancel }
end
resources :claims, only: [:index, :show, :create], controller: 'orders/claims' do
member { patch :approve; patch :resolve; patch :deny; patch :cancel }
end
end
resources :return_reasons, only: [:index]
resources :claim_reasons, only: [:index]
resources :tracking_carriers, only: [:index]
Deliberately absent from the fulfillments member list: purchase_label. Carrier accounts live on the store-scoped Spree::Integration and a seller method is internal-rate/manual-fulfillment only (marketplace plan, Decision 13), so a seller buys no labels in 6.0.
update on a fulfillment is narrowed to tracking: the admin endpoint also moves a parcel between stock locations and re-picks a delivery rate, and a seller's origin move is a different question that is not in this cut. Permitted params are tracking and tracking_carrier only.
Serializers
New, all declared from V3::BaseSerializer and none expanding a customer: Seller::ReturnSerializer, Seller::ReturnLineItemSerializer, Seller::ExchangeSerializer, Seller::ExchangeLineItemSerializer, Seller::ClaimSerializer, Seller::ClaimLineItemSerializer, Seller::ReasonSerializer (one, serving both vocabularies — a reason is id/name/active).
Seller::FulfillmentSerializer gains nothing: it already carries tracking, tracking_carrier, tracking_url, tracking_status, fulfilled_at, delivery_method_name and stock_location_name, all of which the current UI ignores.
Seller::OrderSerializer gains the money fields the summary card needs that it does not already have (shipping_total, promo_total, additional_tax_total, included_tax_total and their display_ twins), plus canceled_at. It does not gain email, customer, payments, fees or discounts.
Panel structure
pages/order.tsx → composition only, like the dashboard's route
components/orders/order-header.tsx → PageHeader + cancel in destructiveItems
components/orders/fulfillments-card.tsx
components/orders/fulfillment-fulfill-form.tsx
components/orders/fulfillment-tracking-dialog.tsx
components/orders/fulfillment-split-dialog.tsx
components/orders/fulfillment-item-list.tsx
components/orders/order-items-card.tsx
components/orders/order-summary-card.tsx
components/orders/order-customer-card.tsx → name + addresses, no email
components/orders/returns-card.tsx
components/orders/post-sale-cards.tsx → exchanges + claims
components/orders/post-sale-create-dialogs.tsx → create return/exchange/claim, resolve claim
hooks/use-order.ts, use-fulfillments.ts, use-returns.ts, use-post-sale.ts, use-reasons.ts
The seller panel has no hooks/ directory today — every page inlines useQuery. This introduces one, matching the dashboard's convention, because eleven mutations across four resources inlined into cards is how the current page became unmaintainable.
Orders list
Largely already right (it has the export button, quick filters and the status vocabularies). Two additions: a status quick filter so canceled orders can be found, and row selection is deliberately still not added — the dashboard's orders table has no bulk actions either.
Migration Path
- Grouped-order refunds (Decision 1a), not additive.
Spree::RefundsOrderPayments+PaymentSplit#refundable_amount, adopted byReturns::Refund,Claims::ResolveandExchanges::Fulfill, with a spec covering the grouped case for all three. Ships first and separately — it corrects operator refunds as well, and the seller endpoint cannot work without it. - Backend, additive only. Routes, six controllers (
orders/returns,orders/exchanges,orders/claims,return_reasons,claim_reasons,tracking_carriers), seven serializers, the fulfillments controller's four new member actions. Specs per controller: a happy path, a cross-seller 404, and the money bound on refund. - SDK.
seller-sdkgainsorders.returns,orders.exchanges,orders.claims,returnReasons,claimReasons,trackingCarriers, and the new fulfillment verbs. Regenerate types (typelizer:generate). - Panel. Port the components in the order listed above; the fulfillments card first, since it is what a seller touches daily.
- OpenAPI + i18n. Integration specs for the new endpoints,
swaggerize, and every new key into all six locale files.
No data migration: everything here is additive, and no existing column, route or serializer field changes meaning.
Constraints on Current Work
- Never subclass an admin controller into the seller namespace. Root at
current_seller_ordersand reach nested records through the order. - A seller serializer is never a subclass of an admin or store one. Declare from
V3::BaseSerializer; a subclass inherits fields (email, payments, cost price) that the seller branch must not carry. - No new seller endpoint may expose the buyer's email, directly or through an expansion. If a new surface needs to contact the customer, it uses the phone on the shipping address.
- Money moves only through the shared workflows, never a hand-rolled refund.
Refunds::Createowns the per-child ceiling, the row lock and the gateway credit; a call site that writes aSpree::Refundanother way is a cross-seller money bug. payment.credit_allowedis group-wide on a grouped payment — it sums refunds across every child order, so it is never a per-seller ceiling. The child's share isPaymentSplit#refundable_amount.- Never read
order.paymentson a path that may see a grouped order — it is empty there. Useorder.payment_splits(orOrder#settlement_paymentswhere a payment list is genuinely wanted); a new post-sale money path usesSpree::RefundsOrderPayments. - Do not add
refunds,paymentsorcommissionsto the seller audience in the permission catalog. A seller refunds through their own return, and that is the only path. - No label purchase on the seller branch while carrier credentials are store-scoped.
- The marketplace plan's "no refunds" lines are superseded by Decision 1 here; update them rather than re-deriving the old conclusion.
Open Questions
- Should a seller see the customer's name at all? This plan says yes (it is on the addresses regardless, and a packing slip carries it), but a stricter marketplace might want initials only. Deferred: it is a serializer field, changeable without restructuring.
- Exchange fulfillment origin.
Exchanges::Fulfillbuilds replacement fulfillments; which of the seller's stock locations they draw from is currently the order's default. Worth revisiting when seller pickup lands. - Cross-order returns list for sellers. The operator has read-only
/returns,/exchanges,/claimspages. A seller arguably wants the same "what is open right now" view; left out of this cut because the per-order cards answer the daily question first.
References
docs/plans/6.0-multi-vendor-marketplace.md— Decision 10 (the seller branch), Decision 13 (seller delivery), Phase 3/3a (split + ledger). Amended by Decision 1 above.docs/plans/6.0-seller-ledger-ui.md— the money surfaces this plan left out. It adds the payment card (this order's share of the basket's payment, amounts only) and the earnings card to the order page, so the "Payments — no" row in the card table above means the group'sPayment, not the child's share.docs/plans/6.0-returns-exchanges-claims.md— the three models and their fifteen workflows.docs/plans/6.0-fulfillment-and-delivery.md— fulfillment status model, partial fulfillment, tracking axis.- Legacy Enterprise module,
SpreeMultiVendor::PermissionSets::VendorUser— the source of truth for what a vendor could already do.