Skip to content

armgit / spree

Public Imported from GitHub
0

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.

30.8 KB
Raw Blame

Shipping Labels and Deliveries

Status: Implemented 2026-09-03 (phases 1–6; phase 7 is 6.1 cleanup) Target: Spree 6.0 Depends on: 6.0-fulfillment-and-delivery.md (status model, PurchaseLabel, UpdateTracking), 6.0-delivery-rate-provider.md (EasyPost reference provider), 6.0-returns-exchanges-claims.md (the Return owner). Coordinates with: 6.0-b2b-wholesale-shipping.md (freight consignments are deliveries too; freight paperwork is not a label), 6.1-b2b-order-documents.md (where a bill of lading goes). Author: Damian Legawiec Last updated: 2026-09-03

Summary

A shipping label is today three provider-private keys written into fulfillment.metadata by the EasyPost gem, surfaced through a per-read provider.documents(fulfillment) call, and bought or refunded through a PATCH .../purchase_label member action. That leaves Spree not knowing what the merchant paid the carrier, unable to reprint once the carrier's hosted URL is gone, unable to buy a second label after a refund, and with nowhere to put a return label. The carrier journey of a parcel is in the same shape: one tracking number and one carrier status per fulfillment, in seven columns on spree_fulfillments, with a spree_fulfillment_trackings model deferred to 6.1 and required to absorb that whole axis when it comes.

This plan promotes both into first-class records now, while 6.0 is still the breaking window. Spree::ShippingLabel is a purchased (or uploaded) carrier document with a cost, a file in private storage, a lifecycle (purchased → refund_requested → refunded) and a polymorphic owner — a Fulfillment for outbound parcels, a Return for inbound ones. Spree::Delivery is one tracked consignment's carrier journey — a parcel, or three pallets under one PRO number — with tracking number, carrier, tracking status, estimate and arrival time, the same polymorphic owner, and optionally born from a label. The fulfillment keeps its merchant lifecycle (unfulfilled → fulfilled → delivered) and rolls delivered up from its deliveries. Both become nested REST resources under the fulfillment in the Admin API; purchase_label and mark_delivered stop being the only doors.

Key Decisions (do not deviate without discussion)

  • The label is a record, the delivery is a record, delivered stays a transition (2026-09-03, probed and confirmed). POST .../deliveries was considered as the way to say "it arrived" and rejected, because a delivery row is born when a tracking number is attached — at fulfil time or label purchase, days before anything arrives — so POST already means "this fulfilment went out as another consignment". Arrival is a state change on an existing row, and every lifecycle transition in the Admin API (fulfill, cancel, capture, approve, receive) is a PATCH member action. The fulfilment-level mark_delivered stays beside a per-delivery twin for three reasons: some fulfilments have no delivery rows at all (pickup, hand delivery, freight with no carrier feed) and still need to become delivered for the returns window; staff saying "it arrived" outranks the carrier and closes every open consignment in one call; and Fulfillments::MarkDelivered already carries public hooks. The alternative — redefining a delivery as a handover so a pickup gets a row with no tracking number and delivered_at set, making the status a pure rollup — was rejected because that row would be a flag wearing a table.
  • Spree::Delivery is the name (2026-09-03, revisited twice). The row must be modality-neutral: 6.0-b2b-wholesale-shipping.md uses "parcel" as the antonym of freight ("different from parcel shipping"), and a freight consignment is one PRO or container number covering several pallets, so Spree::Parcel — briefly chosen — contradicted the sibling plan's fixed vocabulary. Spree::Tracking is the tracking industry's own resource name but collides permanently with Fulfillment#tracking, the 5.6 string field that stays; TrackingStatus names one column of the row; FulfillmentTracking (the 6.1 deferral's name) is wrong for a Return owner. Carriers say "track your delivery" for a parcel and a pallet alike. Accepted trade-off: the word now carries two meanings in the codebase — DeliveryMethod, DeliveryRate, DeliveryProfile and DeliveryZone describe what a store offers, a Delivery is one consignment actually travelling. Workflows live under Spree::Deliveries::, which no existing namespace uses.
  • Polymorphic owner on both tables (2026-09-03). One concept — a carrier document, a consignment in flight — held by different kinds of party, which is the 2026-08-22 tax-identifier ruling, not the dual-FK case (a type string hiding several meanings). Fulfillment and Return are the 6.0 owners; exchanges ship their replacements through fulfillments, so they need no owner of their own. Cardinality is declared owner-side: a fulfillment has_many of each, a return has_many of each.
  • The delivery absorbs the entire carrier axis (honours decisions.md 2026-08-11). tracking, tracking_carrier, tracking_status, tracking_details, estimated_delivery_at move to spree_deliveries. Webhooks match a delivery row, UpdateTracking takes a delivery:, and a fulfillment is delivered when every one of its deliveries is — or when staff say so for a fulfillment that has none. delivered_at on the fulfillment stays as the lifecycle stamp (the returns window and withdrawal anchor), exactly like fulfilled_at: it is when the fulfillment became delivered, a rollup, not a second copy of the carrier's report.
  • The fulfillment keeps tracking and tracking_url, nothing else (2026-09-03). Those two fields shipped in the 5.6 Store API, so they stay permanently as a read-only summary of the primary delivery (the earliest row) — single-parcel storefronts and the fulfilled email stay one-field simple, and tracking: (with tracking_carrier:) on Fulfillments::Fulfill/Update stays as the write shortcut that creates or corrects that delivery. Everything the 6.0 edge added to the fulfillment — tracking_carrier, tracking_carrier_name, tracking_status, tracking_details, estimated_delivery_at — is removed from the serializers and the table rather than bridged: it was never released, so there is nobody to bridge for, and the four columns come out of their own 20260811 migrations in place (the unreleased-edge rule the catalog and company work already used). delivered_at and fulfilled_at stay: they are lifecycle stamps, not carrier data.
  • One label, at most one delivery (2026-09-03). A purchased label mints a delivery carrying its tracking number; the delivery points back through shipping_label_id (unique). Hand-entered tracking is a delivery with no label. A refunded label's delivery is removed only if the consignment never moved (the fulfillment is still unfulfilled); once fulfilled, the journey is history and stays.
  • Idempotency moves into core (2026-09-03). Fulfillments::PurchaseLabel refuses when the owner already has a non-refunded label. Providers no longer need metadata keys to avoid double-buying; the contract for create_fulfillment idempotency (decisions.md 2026-08-12) is retired because the workflow never asks twice.
  • Purchase is a typed result, never a hash (2026-09-03). A label-generating provider implements purchase_label(owner) returning a Spree::LabelPurchase value object (ActiveModel::Model + Attributes: external_id, carrier, service, tracking_number, tracking_url, cost, currency, format, file_url, metadata) and refund_label(shipping_label) returning the resulting status. create_fulfillment/cancel_fulfillment stay for providers whose dispatch is not a label (a 3PL pick, a pickup counter). documents(owner) stays for documents that are not the label — customs forms, commercial invoices — and stops reporting the label.
  • The file lives in Spree (2026-09-03). Right after purchase the label file is fetched from the provider's URL into a private-storage attachment on the row (same declaration and spoofing protection as po_document). The download endpoint streams the attachment, and proxies the provider URL only while the fetch is still pending. Merchants reprint without the carrier account being connected, and a disconnected integration never breaks a warehouse.
  • Cost is recorded, never displayed to the shopper (2026-09-03). cost + currency on the label is what the merchant paid the carrier — accounting data, admin-only. It never touches the order's shipping charge (cost on the fulfillment is what the customer was charged) and never appears on a store serializer.
  • Uploaded labels are in scope (2026-09-03). Merchants without a carrier integration buy postage elsewhere and still need the PDF and the cost on the consignment. POST .../labels with a signed blob id records a source: 'uploaded' label (tracking number, carrier, cost, currency) and mints its delivery through ShippingLabels::Record; the same request without a file purchases through the provider. The serializer's source tells them apart, and refund is refused on an uploaded label (nothing to refund — the merchant deletes it instead, which is the one destroy the resource allows). Sellers get upload but never purchase.
  • Freight paperwork is not a shipping label (2026-09-03, wholesale cross-check). A bill of lading, a pallet placard or a packing list is issued by the forwarder or printed by the merchant; it has no cost to refund and no carrier lifecycle. It goes to Spree::OrderDocument (6.1-b2b-order-documents.md) or the client-side prints, never to a source: 'uploaded' label. What freight does share with parcels is the delivery row: the forwarder's PRO or container number is hand-entered as a delivery with a free-text carrier and a pasted tracking_url, and delivered is staff-confirmed through mark_delivered — which is exactly why that fulfilment-level action stays.
  • Return labels ship in this plan (2026-09-03). The Return owner is what makes the polymorphic shape earn its keep, so it is written in 6.0: Returns::PurchaseLabel (thin, like the fulfillment twin) over ShippingLabels::Purchase(owner: return_record), the EasyPost provider buying an is_return shipment from the customer's address back to the return's stock location, the same labels controller mounted under /orders/:order_id/returns/:return_id/, a customer download on the Store API, and a Return delivery for the inbound parcel whose delivered report never auto-receives — Returns::Receive stays a staff act because arrival is not inspection. The returns plan's interim "URL in metadata" advice is withdrawn.
  • A return label buys the cheapest rate the account offers (2026-09-03). Unlike an outbound parcel there is no rate the customer selected: return postage is the merchant's own money and nobody chose a service for it, so EasyPost::Util.get_lowest_object_rate picks across every connected carrier. Reusing the outbound carrier was considered and rejected — an outbound parcel whose tracking was hand-entered has no carrier to reuse, and mirroring the outbound service inbound is usually the most expensive answer to a question the merchant never asked. A merchant who wants a specific return service configures it on the integration later; that is additive.
  • No transition graph, no state machine. ShippingLabel uses has_status; every status change is a workflow (ShippingLabels::Purchase, ::Refund, ::Record for uploads). Delivery#status is the carrier's vocabulary and stays data written by Deliveries::UpdateTracking — a pending value replaces today's nil so the creating workflow sets it and the column never carries a database default.

Design Details

Models

Spree::ShippingLabel (spree_shipping_labels, prefix lbl, Spree::SingleStoreResource, Spree::Metadata, has_status :purchased, :refund_requested, :refunded)

Column Notes
owner_type, owner_id polymorphic, null: false, indexed together
store_id null: false
integration_id nullable — the connected carrier account that sold it; nil for uploaded labels
source purchased | uploaded, null: false
external_id provider's shipment/label id
carrier, service strings, carrier key from Spree.tracking_carriers when known
tracking_number the number printed on the label — a frozen purchase fact; the delivery holds the live one
cost, currency decimal(10,2) default 0 + string; what the merchant paid
format pdf | png | zpl
status string, set by the workflow
refunded_at datetime
metadata JSON — provider ids (tracker id, original file URL)
file has_one_attached, Spree.private_storage_service_name, content type limited to PDF/PNG/ZPL, spoofing-protected

Associations: belongs_to :owner, polymorphic: true, belongs_to :store, belongs_to :integration, optional: true, has_one :delivery. Scopes: active (where.not(status: 'refunded')). Fulfillment has_many :shipping_labels, as: :owner, dependent: :destroy; Return the same.

Spree::Delivery (spree_deliveries, prefix dlv, Spree::SingleStoreResource)

Column Notes
owner_type, owner_id polymorphic, null: false
store_id null: false
shipping_label_id nullable, unique index — the label that minted it
tracking_number null: false, indexed (webhook lookup); unique per owner. A parcel's carrier number, or a freight PRO / container number
tracking_url nullable — a pasted link or the provider's tracker page; the resolved URL falls back to the carrier template then format detection, as today
carrier free-text string. Detected from the number when not given (today's detect_tracking_carrier); Spree.tracking_carriers supplies URL templates and display names, never validation — a forwarder's name is a legal value
service string, nullable
status pending | pre_transit | in_transit | out_for_delivery | available_for_pickup | delivered | return_to_sender | failure | unknown — the carrier axis, inclusion-validated, no graph
estimated_delivery_at, delivered_at datetimes
details JSON — the carrier payload worth keeping (scan history, signature, failure reason)

Associations: belongs_to :owner, polymorphic: true, belongs_to :store, belongs_to :shipping_label, optional: true. Fulfillment has_many :deliveries, as: :owner, dependent: :destroy (ordered by created_at; the first is the primary delivery the summary fields read). Return the same.

Fulfillment lifecycle with deliveries

  • Fulfillments::Fulfill — tracking: (and tracking_carrier:) still accepted as the one-parcel shortcut: it creates a delivery through Deliveries::Create inside the same transaction as the split. The label step becomes external_step :purchase_label calling ShippingLabels::Purchase when the provider generates labels and no active label exists; failure still degrades to "no label yet". The fulfilled email reads tracking from the primary delivery.
  • Fulfillments::PurchaseLabel — thin: validate, refuse on an active label, delegate to ShippingLabels::Purchase. Kept as a workflow because its hooks (validate, after_purchase_label) are public since 2026-08-12.
  • Fulfillments::Update — tracking: upserts the primary delivery (creates it, or corrects its number; a corrected number resets status to pending).
  • Fulfillments::Cancel — tell_provider_to_stand_down refunds every active label through ShippingLabels::Refund (notify_provider: false still lets Orders::Cancel batch the carrier I/O), then the 3PL cancel_fulfillment.
  • Fulfillments::MarkDelivered — staff confirmation. Marks every non-delivered delivery delivered at the given time (a human saying "it arrived" outranks a carrier that never sent the last scan), then the fulfillment. Unchanged signature. This is the freight path: no webhook ever arrives for a container.
  • Deliveries::UpdateTracking (renamed from Fulfillments::UpdateTracking; fulfillment_update_tracking_workflow stays readable one release and resolves the primary delivery) — writes the carrier axis onto one row with update_columns, as today. When the report is delivered it stamps the row and, if every sibling delivery is delivered, delegates to Fulfillments::MarkDelivered with the latest delivered_at. A Return owner never auto-transitions anything: goods arriving is not goods inspected, and Returns::Receive stays a staff act. A per-delivery mark_delivered from staff is this workflow with tracking_status: 'delivered'.
  • Deliveries::Create / Deliveries::Destroy — Tier 1 services (no hook earned). Destroy refuses a delivery that has a label — refund the label.

Label workflows

  • ShippingLabels::Purchase(owner:) — validate hook, ensure_purchasable (provider generates_labels?, owner not fulfilled/canceled, no active label, order not draft), external_step :purchase (provider purchase_label(owner) → LabelPurchase), then in one transaction create the label row and its delivery, then external_step :store_file (fetch file_url into the attachment; on failure enqueue ShippingLabels::StoreFileJob and leave the URL in metadata). Publishes shipping_label.purchased. Hook after_purchase.
  • ShippingLabels::Refund(shipping_label:) — validate, ensure_refundable (status purchased, source purchased), external_step :refund (provider refund_label → refund_requested or refunded), write the status, remove the delivery when the owner never shipped. Publishes shipping_label.refunded. A provider whose refund resolves later reports it through its webhook by calling ShippingLabels::ConfirmRefund (plain service).
  • ShippingLabels::Record(owner:, file:, tracking_number:, carrier:, cost:, currency:) — an uploaded label: creates a source: 'uploaded' row and its delivery, no provider involved.

Provider contract (Spree::FulfillmentProvider::Base)

def self.generates_labels? = false           # unchanged
def purchase_label(owner)                     # → Spree::LabelPurchase | nil
def refund_label(shipping_label)              # → 'refunded' | 'refund_requested' | false
def create_fulfillment(fulfillment)           # unchanged — non-label dispatch
def cancel_fulfillment(fulfillment)           # unchanged
def documents(owner)                          # unchanged shape, label excluded
def tracking_url(delivery)                    # was tracking_url(fulfillment); deprecated twin one release

The EasyPost provider implements purchase_label from today's buy_quoted/requote_and_buy (returning postage_label.label_url, rate.rate/currency, label_file_type; is_return: true when the owner is a Return, shipping from the customer's address to the return's stock location), refund_label from cancel_fulfillment, drops remember_purchase and every metadata['easypost_*'] read, and keeps documents for shipment.forms. Its tracker webhook resolves the delivery by tracking number scoped to the integration's store. The freight rate provider from the wholesale plan pairs with the Manual fulfilment provider and generates no labels; its consignments are hand-entered deliveries.

Admin API (spree/api)

Nested under the order's fulfillment (there is no top-level fulfillments resource in the Admin API). Both ride the fulfillments permission resource — their subjects join its list.

GET    /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/labels
POST   /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/labels           buy through the provider; with `file` (signed blob id), record an uploaded label
GET    /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/labels/:id
GET    /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/labels/:id/download   streamed, read scope
PATCH  /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/labels/:id/refund
DELETE /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/labels/:id        uploaded labels only

GET    /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/deliveries
POST   /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/deliveries       tracking_number, carrier, tracking_url
GET    /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/deliveries/:id
PATCH  /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/deliveries/:id   correct number / carrier / url
DELETE /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/deliveries/:id   422 when it has a label
PATCH  /api/v3/admin/orders/:order_id/fulfillments/:fulfillment_id/deliveries/:id/mark_delivered

PATCH .../fulfillments/:id/purchase_label stays one release as a deprecated alias of POST .../labels returning the fulfillment. mark_delivered on the fulfillment is unchanged. The same labels controller mounts under /orders/:order_id/returns/:return_id/ for return labels.

Serializers: Admin::ShippingLabelSerializer (id, owner_id, source, status, carrier, service, tracking_number, cost, currency, display_cost, format, download_url, refunded_at, metadata, timestamps) and Admin::DeliverySerializer extending a store DeliverySerializer (id, tracking_number, tracking_url, carrier, carrier_name, status, estimated_delivery_at, delivered_at; admin adds shipping_label_id, details, timestamps). The fulfillment serializers embed deliveries always (small, and the customer's question), keep tracking and tracking_url as the primary delivery's summary, lose tracking_carrier, tracking_carrier_name, tracking_status, tracking_details and estimated_delivery_at; the admin one embeds labels; documents and provider_generates_labels stay. Fulfillment write params keep tracking and tracking_carrier (forwarded to the primary delivery) and nothing else tracking-shaped.

Seller branch: sellers fulfill on manual methods only (Decision 13 of the marketplace plan), so they get deliveries index/create/update/destroy and labels index/upload/download/destroy under /seller/orders/:id/fulfillments/:id/ — never purchase or refund, which need the operator's carrier account.

Store API

fulfillment.deliveries[] on the order serializer beside the permanent tracking/tracking_url summary. The only label surface is the customer's return label: GET /store/orders/:order_id/returns/:id/label streams the active label's file to the order's customer (or order-token holder) — the label row itself is never serialized to the storefront, since its cost and provider ids are merchant data.

Dashboard

The fulfillment card lists deliveries (one badge per consignment with its carrier status; "Add tracking" opens a sheet; a delivery with a label is not deletable), renders the label row (Buy label → POST labels; Print → download; Refund with a destructive confirm; Upload label for manual methods), and shows postage cost. Return page gets the same label block. Every string through i18next in all locales.

Events

shipping_label.purchased, shipping_label.refunded (new, with an event serializer). fulfillment.delivered unchanged. No per-scan delivery event — the after_update_tracking hook is that surface, as today.

Migration Path

  1. Schema — one migration creating spree_shipping_labels and spree_deliveries. The two 20260811 fulfillment migrations are amended in place to stop adding tracking_status, tracking_details, estimated_delivery_at and tracking_carrier (unreleased edge — a dev database that already has them keeps harmless dead columns until pnpm wt:template rebuilds it). spree_fulfillments.tracking and its index stay: they are the 5.6 data the task below reads.
  2. Core — models, LabelPurchase, workflows and services, provider base contract, Fulfill/Update/Cancel/MarkDelivered/PurchaseLabel rewired, Deliveries::UpdateTracking, tracking/tracking_url readers delegating to the primary delivery, Spree::Dependencies keys (shipping_label_purchase_workflow, shipping_label_refund_workflow, shipping_label_record_workflow, delivery_update_tracking_workflow, return_purchase_label_workflow; legacy fulfillment_update_tracking_workflow readable one release).
  3. Data task — spree:upgrade:migrate_deliveries in the 5.6→6.0 manifest after migrate_fulfillment_statuses: every fulfillment with a tracking gets one pending delivery row carrying that number (a pasted link lands in tracking_url, the carrier is detected from the number as today); idempotent by (owner, tracking_number) existence. No label backfill: the EasyPost metadata keys only ever existed on the unreleased 6.0 edge.
  4. EasyPost — purchase_label for both owners (is_return for a Return), refund_label, webhook matching by delivery, documents reduced to forms.
  5. API + SDK — fulfillment- and return-nested labels, deliveries, store return-label download, serializers, typelizer/Zod/OpenAPI, admin-sdk and sdk resources, seller branch.
  6. Dashboard — fulfillment card rework, return page label block, e2e.
  7. 6.1 — drop spree_fulfillments.tracking and its index, remove the deprecated purchase_label alias, fulfillment_update_tracking_workflow and tracking_url(fulfillment).

Phases 1–6 are one PR train on one branch; the data task ships with phase 3.

Constraints on Current Work

  • Never write spree_fulfillments.tracking*, estimated_delivery_at or tracking_details in new code — tracking is a Delivery row created through Deliveries::Create (or the tracking: shortcut on Fulfillments::Fulfill/Update, which does the same). delivered_at on the fulfillment is written only by Fulfillments::MarkDelivered.
  • No provider reads or writes fulfillment.metadata for label state. Label facts live on Spree::ShippingLabel; a provider that needs to remember its own ids puts them in the label's metadata.
  • A label's cost is merchant accounting, never shopper money — it never feeds fulfillment.cost, totals, or a store serializer.
  • Webhook matching resolves a Delivery, scoped to the integration's store — never Fulfillment.where(tracking:).
  • Return labels attach to the Return as its owner — no return_label_url column, no URL in metadata (the returns plan's interim advice is withdrawn once this ships).
  • Fulfillment#delivered is a rollup: a new owner or a new carrier integration may never mark a fulfillment delivered directly — it reports a delivery and lets Deliveries::UpdateTracking roll up.
  • No new readers of tracking_status, tracking_carrier, estimated_delivery_at or tracking_details on a fulfillment — the storefront, emails and dashboard read deliveries; a fulfillment only ever summarizes tracking and tracking_url.
  • Delivery#carrier is free text. Spree.tracking_carriers supplies URL templates and display names; nothing may validate a carrier against it, or a forwarder's PRO number becomes unenterable.
  • Freight paperwork is never a ShippingLabel. A bill of lading, pallet placard or packing list goes to Spree::OrderDocument or the client-side prints (6.1-b2b-order-documents.md); the label table holds carrier labels only.
  • A Return delivery never transitions the return. Anything that wants "the parcel came back" to do something hangs it on Deliveries::UpdateTracking's after_update_tracking hook and calls Returns::Receive itself, staff-style.
  • Label files are private-storage attachments streamed by the API — never a public blob URL on any serializer, never attachment.url.
  • Fulfillment#tracking is a read-through summary, and tracking= is a deprecated shell. New code creates a delivery (Deliveries::Create, or the tracking: keyword on Fulfillments::Fulfill/Update); assigning tracking still works one release, writing the primary delivery on save with a warning, and is removed in 6.1 with the column.
  • The label's file format is written as file_format on the API. format is Rails' own request-format parameter, so a controller permitting it receives "json" and the label refuses to save; the model attribute keeps the name format.

Open Questions

None blocking. Three items are deliberately deferred:

  • Refund outcome from the carrier. ShippingLabels::Refund records what the provider answers synchronously (refunded or refund_requested). A provider that settles refunds later (EasyPost's refund.successful / refund.rejected events) can complete the story through ShippingLabels::ConfirmRefund, but a refund_rejected status and the webhook wiring wait for a merchant to ask — unblocked by that request.
  • Several labels for one delivery (a multi-piece shipment under one tracking number). Not modeled: one label mints one delivery. Unblocked by a carrier provider that actually returns multi-piece labels.
  • Packaging on the delivery. The wholesale plan names its pallet and container PackageType rows as "the natural anchor for future label/BOL work"; a nullable package_type_id (plus a count) on spree_deliveries is the additive hook — "3 pallets under PRO 4471923". Unblocked by the wholesale plan landing and a merchant needing the consignment's packaging recorded, not just its number.

References

  • docs/plans/6.0-fulfillment-and-delivery.md — resolved questions 14 and 15, the "label leads" amendment
  • docs/plans/decisions.md — 2026-08-11 (one tracking number per fulfillment), 2026-08-12 (the label leads), 2026-08-22 (polymorphic tax identifier owner — the precedent for owner here), 2026-09-03 (this plan)
  • docs/plans/6.0-returns-exchanges-claims.md — resolved question 2 (return labels ride with the carrier provider)
  • docs/plans/6.0-delivery-rate-provider.md — EasyPost as the reference provider
  • docs/plans/6.0-b2b-wholesale-shipping.md — freight tiers, the freight rate provider, PackageType, and the parcel-versus-freight vocabulary that settled the model's name
  • docs/plans/6.1-b2b-order-documents.md — where bills of lading and packing lists live
  • spree/core/app/workflows/spree/fulfillments/{purchase_label,fulfill,cancel,mark_delivered,update_tracking}.rb
  • spree/providers/easypost/app/models/spree_easypost/{fulfillment_provider,tracker_event}.rb
  • spree/api/app/controllers/spree/api/v3/webhooks/fulfillments_controller.rb