/spree-commerce:spree-shipping-fulfillmentfrom spree-commerce
Build and customize Spree's shipping and fulfillment including ShippingMethod, ShippingCategory, Zone/ZoneMember, ShippingRate, Stock::Estimator, StockLocation/StockItem/StockMovement, multi-shipment orders, ShippingCalculator classes (FlatRate, FlatPercentItemTotal, PerItem, FlexiRate), shipment state machine, returns (ReturnAuthorization to…
Ships in spree-commerce. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Fetch live docs:
Spree::Stock::Estimator and Spree::Stock::Splitter in the live spree gem source.Spree::ShippingMethod source for column names and associations.spree-active-shipping, spree-ups, spree-fedex) — verify which are maintained for v5.| Model | Purpose |
|---|---|
ShippingMethod | Named shipping option (UPS Ground, FedEx 2-Day) |
ShippingRate | Computed cost option offered to the user during checkout |
ShippingCategory | Categorize products by shipping needs (Hazmat, Frozen, Standard) |
Zone / ZoneMember | Geographic regions a method ships to |
Shipment | A subset of order items shipped together from one StockLocation |
InventoryUnit | One unit of a Variant in a Shipment |
StockLocation | Physical/logical warehouse |
StockItem | Count of a Variant in a StockLocation |
StockMovement | Append-only ledger of stock changes |
StockTransfer | Move stock between StockLocations |
If an order's items span multiple StockLocations, Spree creates one Shipment per location. The Spree::Stock::Splitter allocates items by stock availability and configured policy (closest, fastest, cheapest, etc.).
A ShippingMethod is offered for a Shipment if:
Polymorphic Calculator (same base class as promotion/tax calculators):
| Calculator | Math |
|---|---|
Spree::Calculator::Shipping::FlatRate | Fixed cost |
Spree::Calculator::Shipping::FlatPercentItemTotal | % of cart |
Spree::Calculator::Shipping::PerItem | Per-item flat |
Spree::Calculator::Shipping::FlexiRate | Tiered by total |
Spree::Calculator::Shipping::PriceSack | Free over threshold |
Spree::Calculator::Shipping::DigitalDelivery | Free for digital |
Carrier-API calculators (UPS, FedEx, USPS) come from community gems — they compute rates by calling the carrier's API live.
Spree::Stock::Estimator.new(order).shipping_rates(package) returns the ShippingRate options for a given Package. Replaceable via Spree::Dependencies:
Spree::Dependencies.shipping_rate_estimator = MyCustomEstimator
This is the canonical extension point for custom shipping logic — preferable to decorating the model.
pending → ready → shipped
↓
canceled
pending — awaiting payment / stockready — paid and stocked, ready to fulfillshipped — shipped_at set, tracking number capturedcanceled — canceled with orderReturnAuthorization (authorized | canceled)
└── ReturnItem[]
↓
CustomerReturn (when physically received)
└── ReturnItem[]
↓
Reimbursement (pending | reimbursed | errored)
└── Refund (against original Payment)
OR StoreCredit
# A US zone
us = Spree::Zone.create!(name: 'US')
us.zone_members.create!(zoneable: Spree::Country.find_by(iso: 'US'))
# A shipping category
standard = Spree::ShippingCategory.find_or_create_by!(name: 'Standard')
# A shipping method
method = Spree::ShippingMethod.create!(
name: 'Standard Shipping',
display_on: 'both',
shipping_categories: [standard],
zones: [us],
tax_category: Spree::TaxCategory.find_by(name: 'Shipping')
)
method.calculator = Spree::Calculator::Shipping::FlatRate.new(preferred_amount: 5.00)
method.save!
# A stock location
loc = Spree::StockLocation.create!(
name: 'Main Warehouse',
default: true,
active: true,
country: Spree::Country.find_by(iso: 'US')
)
If you need custom logic (e.g., "always offer free shipping for Gold customers"):
Option A — Subscribe to events (preferred when reacting):
class FreeGoldShippingSubscriber < Spree::Subscriber
subscribes_to 'order.recalculate'
on 'order.recalculate', :apply_free_shipping
end
Option B — Swap the Estimator (preferred when modifying rate generation):
class MyEstimator < Spree::Stock::Estimator
def shipping_rates(package, frontend_only = true)
rates = super
rates.each { |r| r.cost = 0 } if package.order.user&.gold_tier?
rates
end
end
# config/initializers/spree.rb
Spree::Dependencies.shipping_rate_estimator = MyEstimator
Community gems for UPS/FedEx/USPS exist; verify v5 compatibility before adoption. The pattern:
Spree::Calculator::Shipping::CarrierName calculatorcompute(package) calls the carrier's rate APIWhen the fulfillment provider ships:
shipment.update!(tracking: 'TRACKING123', shipped_at: Time.current)
shipment.ship!
# Fires shipment.shipped event → webhook → customer email
# Increase stock
stock_item.adjust_count_on_hand(10)
# Decrease (validates sufficient stock)
stock_item.reduce_count_on_hand(2)
# Transfer between locations
Spree::StockTransfer.create!(
source_location: loc_a,
destination_location: loc_b,
stock_movements_attributes: [
{ quantity: 5, stock_item_id: source_item.id }
]
)
If track_inventory is on and stock hits zero, Spree marks the InventoryUnit as backordered. The shipment goes into backorder state until stock returns.
To disable backorders globally:
Spree::Config[:allow_backorders] = false
Verify the exact preference name in current config.
# Customer requests return
ra = Spree::ReturnAuthorization.create!(
order: order,
return_items_attributes: items.map { |i| { inventory_unit_id: i.id } },
stock_location: order.shipments.first.stock_location
)
ra.authorize!
# Warehouse receives
cr = Spree::CustomerReturn.create!(
return_items: ra.return_items,
stock_location: ra.stock_location
)
# Reimburse
reimb = Spree::Reimbursement.create!(
customer_return: cr,
order: order,
return_items: cr.return_items
)
reimb.perform! # creates Refunds and/or StoreCredits
delivery.propagate_all_variants or pin to a primary location.shipped! when manually marking a shipment — no event, no email, no webhook.adjust_count_on_hand — bypasses the ledger and breaks reconciliation.Always verify model relationships and calculator names against the live source — shipping is one of the most decoupled subsystems and has community gems that vary in v5 readiness.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
spree, shipping, fulfillment, ecommerce, carrier-integration
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin spree-commerce22 skills in this plugin
/spree-admin-customizationCustomize the Spree v5 Admin Dashboard — Tailwind 4 + Hotwire/Turbo/Stimulus stack, the `Spree.admin.navigation` declarative API (v5.2+) for menu items, partial injection slots (`store_nav_partials`, `store_products_nav_partials`, `store_orders_nav_partials`, `settings_nav_partials`), the Admin SDK components + form builder, custom dashboard reports, the Page Builder for storefront editing, and theme management. Use when adding admin pages, injecting UI into existing screens, or building admin extensions./spree-api-v3Build with Spree's v3 APIs (v5.4+) — Store API at `/api/v3/store/*` (publishable key + per-user JWT, customer-facing) and Admin API at `/api/v3/admin/*` (per-user API keys + OAuth2 Doorkeeper, admin/operations). Covers the flat-JSON Stripe-like envelope, `?expand=` / `?include=` parameters, prefixed IDs (`prod_…`, `ord_…`), OpenAPI 3.0 spec, rate limiting, idempotency, and migration from v2 JSON:API. Use when building API clients, SDKs, or extending API endpoints in a Spree v5.4+ deployment./spree-catalogBuild and customize Spree's catalog — Products with Variants and OptionTypes/OptionValues, Taxonomies and Taxons (nested set), Properties, Images via ActiveStorage, multi-currency Prices, the v5.3+ PriceList feature for customer/segment overrides, MeiliSearch faceted search (v5.4+), product archiving/activation, CSV import/export, and SEO. Use when modeling products, customizing the catalog UI, indexing search, or importing inventory./spree-checkoutImplement Spree's checkout — the Order state machine (cart → address → delivery → payment → confirm → complete), the Payment and Shipment sub-state machines, the return flow (ReturnAuthorization → CustomerReturn → Reimbursement → Refund), guest checkout, payment-step skipping for credit-covered orders, and the V3 checkout API surface. Use when building or customizing checkout flows, debugging state transitions, or wiring custom checkout steps./spree-data-modelNavigate Spree's canonical data model — the Catalog (Product/Variant/OptionType/Taxon/Property/Metafield), Pricing (Price/PriceList), Order graph (Order/LineItem/Adjustment/Shipment/Payment/PaymentSession/Refund/Reimbursement), Inventory (StockLocation/StockItem/StockMovement), Shipping (ShippingMethod/Zone), Promotions, Identity (User/Role/Address/StoreCredit/GiftCard), Taxes, and the v5.4+ Markets + Store multi-region model. Use when designing a feature that touches Spree models, writing decorators, or building admin/storefront UIs./spree-deploymentDeploy Spree to production — PostgreSQL + Redis + Sidekiq stack, Docker multi-arch images on GHCR, the `spree-starter` Dockerfile + Compose, Heroku/Render/Fly.io/AWS targets, env-var conventions, RAILS_MASTER_KEY, asset precompilation (Tailwind 4 + Propshaft), Action Cable, MeiliSearch indexing, S3 / ActiveStorage for media, log/observability setup, zero-downtime deploys, and migration strategy. Use when going from local dev to production, scaling Spree, or troubleshooting deploys.Other plugins' skills for the same job