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
Retire ShippingCategory and adopt delivery vocabulary in core
Damian Legawiec39887a69518b
diff --git a/docs/plans/5.5-6.0-display-on-to-boolean.md b/docs/plans/5.5-6.0-display-on-to-boolean.mdindex 213d0bacbc..2fbfc0a32a 100644--- a/docs/plans/5.5-6.0-display-on-to-boolean.md+++ b/docs/plans/5.5-6.0-display-on-to-boolean.md@@ -1,6 +1,6 @@# `display_on` → `storefront_visible` (PaymentMethod, ShippingMethod / DeliveryMethod)-**Status:** 5.5 bridge shipped (`storefront_visible` accessor + Ransacker on the `Spree::DisplayOn` concern); 6.0 schema rename + concern drop pending+**Status:** 5.5 bridge shipped (`storefront_visible` accessor + Ransacker on the `Spree::DisplayOn` concern). **DeliveryMethod completed the 6.0 flip on 2026-08-05** — real `storefront_visible` boolean column (`null: false, default: true`), off the concern, `display_on` kept as a deprecated reader/writer until 6.1; the tri-state `DISPLAY_ON_*` rate filter became `DeliveryMethod::STOREFRONT`/`BACKOFFICE`. **PaymentMethod and MetafieldDefinition are still on the concern** — their schema rename remains pending.**Target:** 5.5 (API alias + `alias_attribute` shim ✓) + 6.0 (schema rename, drop the `Spree::DisplayOn` tri-state concern)**Depends on:** `5.4-6.0-custom-fields-rename.md` (same bridge pattern, already in flight). `6.0-fulfillment-and-delivery.md` (drives the `ShippingMethod → DeliveryMethod` rename — this plan piggybacks on that wave).**Author:** Damian + Claudediff --git a/docs/plans/6.0-delivery-zones.md b/docs/plans/6.0-delivery-zones.mdindex 9153e9647b..3705dadfce 100644--- a/docs/plans/6.0-delivery-zones.md+++ b/docs/plans/6.0-delivery-zones.md@@ -1,10 +1,10 @@# Delivery Zones (Zone → DeliveryZone)-**Status:** Draft+**Status:** Phases A and B shipped, C mostly shipped; `Spree::Zone` removal (Phase D) blocked on the tax provider — see "Implementation status"**Target:** Spree 6.0-**Depends on:** `6.0-tax-provider.md` Phase 5 (tax decoupled from Zone — prerequisite for dropping the model), `6.0-fulfillment-and-delivery.md` Phase 1 (`spree_delivery_method_zones` born pointing at DeliveryZone). Coordinates with: `6.0-delivery-rate-provider.md` (the Estimator's zone check swaps to DeliveryZone matching; provider interface unaffected).+**Depends on:** `6.0-tax-provider.md` Phase 5 (tax decoupled from Zone — prerequisite for dropping the model; **not yet shipped, this is the live blocker**), `6.0-fulfillment-and-delivery.md` Phase 1 (`spree_delivery_method_zones` born pointing at DeliveryZone — **shipped**). Coordinates with: `6.0-delivery-rate-provider.md` (the Estimator's zone check swaps to DeliveryZone matching; provider interface unaffected).**Author:** Damian + Claude-**Last updated:** 2026-07-27+**Last updated:** 2026-08-05## Summary@@ -14,6 +14,14 @@ An earlier revision descoped this because the Zone removal surface (~183 non-spePostal-code zones unlock what Zone structurally cannot express: "free local delivery to postcodes 10001–10099", "express in central Warsaw only", "no islands surcharge zone" — table-stakes for European local-delivery and courier setups, and a gap against carrier-level zone support in hosted platforms.+## Implementation status (verified 2026-08-05 against `feat/fulfillment-delivery-rework`)++**Shipped:** `Spree::DeliveryZone` + `Spree::DeliveryZoneMember` with typed members, `spree_delivery_method_zones` re-pointed at `delivery_zone_id`, `DeliveryMethod#include?` iterating delivery zones (gated by `requires_zone_check?`), the `spree:migrate_zones_to_delivery_zones` rake task wired into the 5.6→6.0 upgrade manifest, admin API delivery-zone CRUD plus the dashboard page, `Store#countries_with_shipping_coverage` rewritten onto DeliveryZone members, and a `:delivery_zone` factory.++**Remaining, unblocked (this plan's own consumers):** permission sets (`default_customer`, `configuration_management`) still grant on `Spree::Zone`; `Spree::Seeds::Zones` still exists; and the test-support surface still carries the `Zone.global` monkey-patch in `factories.rb`, `zone_factory`, `zone_member_factory`, the `GlobalZone` lookup used by `shipping_method_factory`, and `order_walkthrough`.++**Remaining, blocked on `6.0-tax-provider.md` Phase 5:** `Spree::Current.zone` → `tax_country`, the `Pricing::Context` zone dimension, and the tax-side readers (`TaxRate`, `Market#tax_zone`, `VatPriceCalculation`, `Purchase::Taxation`, `controller_helpers/store`). Phase D — dropping `spree_zones`/`spree_zone_members`, the `Zone`/`ZoneMember` models and `Country#zones`/`State#zones` — cannot start until both of the above are clear. `Spree::Zone` still has roughly eighteen non-spec consumer files today.+## Key Decisions (do not deviate without discussion)- **`Spree::DeliveryZone` + `Spree::DeliveryZoneMember`**, prefix ids `dz_` / `dzm_`. Member is typed by `member_type`: `country` (FK), `state` (FK), or `postal_code` (`country_id` FK + `postal_code_from`/`postal_code_to` range, or a single `postal_code_prefix`). A zone mixes member types freely.@@ -82,19 +90,19 @@ Verified 2026-07-27 (~183 non-spec references: core/app 109, core/lib 37, admin/## Migration Path-### Phase A — model + tables (after fulfillment Phase 1)+### Phase A — model + tables (after fulfillment Phase 1) ✅ shipped`spree_delivery_zones`, `spree_delivery_zone_members` (typed members, country-scoped postal columns). `spree_delivery_method_zones` is born (or re-pointed) with `delivery_zone_id`.-### Phase B — data migration (rake `spree:migrate_zones_to_delivery_zones`)+### Phase B — data migration (rake `spree:migrate_zones_to_delivery_zones`) ✅ shippedFor each Zone referenced by a shipping/delivery method: create a DeliveryZone with the same name/description and copy members (country→country, state→state). Zones referenced only by TaxRate are handled by the tax plan's task; zones referenced by neither are logged and skipped. Idempotent, batched.-### Phase C — consumers+### Phase C — consumers — mostly shipped (API, dashboard, matching, coverage, factories done; permission sets, seeds and the Zone.global test-support patch remain)Admin API v3 delivery-zone CRUD (+ nested on delivery method) with admin-sdk resource and a **React dashboard** page under delivery settings (zone list + typed-member editor incl. postal ranges/prefixes; the legacy Rails `zones_controller` + views are deleted with `spree/admin` at 6.0, not rebuilt). Estimator/DeliveryMethod matching, `Spree::Current.tax_country` + `Pricing::Context` country key (jointly with tax-provider), `Store#countries_with_shipping_coverage`, permission sets, factories + test support, seeds, type pipeline regeneration.-### Phase D — drop (end of 6.0)+### Phase D — drop (end of 6.0) — blocked on `6.0-tax-provider.md` Phase 5Drop `spree_zones` + `spree_zone_members`, remove `Zone`/`ZoneMember` models, `Country#zones`/`State#zones`, zone factories and the `Zone.global` monkey-patch. Grep-clean: zero `Spree::Zone` references outside the migration task.diff --git a/docs/plans/6.0-fulfillment-and-delivery.md b/docs/plans/6.0-fulfillment-and-delivery.mdindex 454887385e..96a914497f 100644--- a/docs/plans/6.0-fulfillment-and-delivery.md+++ b/docs/plans/6.0-fulfillment-and-delivery.md@@ -1,10 +1,10 @@# Fulfillment & Delivery Rework-**Status:** Draft+**Status:** Phases 1–5 shipped to `feat/fulfillment-delivery-rework`; remaining 6.0 work is the vendor axis (gated) — see "Implementation status"**Target:** Spree 6.0-**Depends on:** `6.0-product-types.md` (`fulfillment_types` addendum 2026-07-27 — ProductType replaces ShippingCategory; **hard blocker**, `Spree::ProductType` does not exist yet), `6.0-cart-order-split.md` (where fulfillments/rates live pre-completion), `6.0-order-routing.md` (packages come from `for_allocation`), `6.0-normalize-state-to-status.md`. Coordinates with: `6.0-delivery-rate-provider.md` (owns `store_id` on DeliveryMethod; calculators stay per decisions.md 2026-07-27), `5.5-6.0-display-on-to-boolean.md` (`storefront_visible` lands in the same migration wave), `6.0-multi-vendor-marketplace.md` (`vendor_id`, lifecycle events, `delivery_amount`). Gates: `6.0-6.1-split-adjustments.md` and `6.0-typed-stock-movements.md` are born with `fulfillment_id` — **this plan's Phase 1 must land before both**.+**Depends on:** `6.0-product-types.md` (`fulfillment_types` addendum 2026-07-27 — ProductType replaces ShippingCategory; **shipped**, including the `fulfillment_types` column), `6.0-cart-order-split.md` (where fulfillments/rates live pre-completion), `6.0-order-routing.md` (packages come from `for_allocation`), `6.0-normalize-state-to-status.md`. Coordinates with: `6.0-delivery-rate-provider.md` (owns `store_id` on DeliveryMethod; calculators stay per decisions.md 2026-07-27), `5.5-6.0-display-on-to-boolean.md` (`storefront_visible` — DeliveryMethod moved off the `Spree::DisplayOn` concern 2026-08-05), `6.0-multi-vendor-marketplace.md` (`vendor_id`, lifecycle events, `delivery_amount`). Gates: `6.0-6.1-split-adjustments.md` and `6.0-typed-stock-movements.md` are born with `fulfillment_id` — **this plan's Phase 1 must land before both**.**Author:** Damian + Claude-**Last updated:** 2026-08-02+**Last updated:** 2026-08-05## Summary@@ -17,18 +17,32 @@ Three changes in one:**Calculators are NOT touched by this plan.** The 2026-07-27 decision (decisions.md) keeps `ShippingCalculator` + `Calculator::Shipping::*`; rate estimation is the delivery-rate-provider plan's domain. **Zone replacement ships in 6.0 via `6.0-delivery-zones.md`** — this plan's Phase 1 births `spree_delivery_method_zones` pointing at `DeliveryZone` (born correct, never re-migrated).-## Already shipped (verified 2026-07-27, HEAD 4e5b6fd)+## Implementation status (verified 2026-08-05 against `feat/fulfillment-delivery-rework`)-This plan is being implemented ahead of itself — the following exists today and must NOT be redone:+**Phases 1a, 1b, 2, 3, 4 and 5 are implemented.** Verified in code: the rename migrations (`20260728000004/5`) including every FK and the `orders` column pair; model renames with one-release deprecation shells (`Spree::Shipment`, `ShippingMethod`, `InventoryUnit`, `FulfilmentChanger` are constant aliases); `Package#eligible_delivery_methods` + `Stock::Splitter::FulfillmentType`; `ProductType#fulfillment_types` with registry-backed inclusion validation; all five providers plus `PickupPointProvider::Base`; the `Spree.fulfillment_types` / `Spree.fulfillment_providers` registries; lifecycle events with `shipment.*` dual-emit and `order.fulfilled` / `Order#fully_fulfilled?`; dual `cart_id`/`order_id` owner with exactly-one validation; `Estimator` location gating via `serves_location?`; pickup discovery endpoints and the `fulfillment_providers` discovery route; admin delivery-method and delivery-zone CRUD; `FulfillmentMailer` (with a `ShipmentMailer` shell); `return_items.fulfillment_item_id`; and both data rake tasks wired into the 5.6→6.0 upgrade manifest.++**Landed 2026-08-05** (this plan's remaining 6.0 cleanup): `storefront_visible` is now the authoritative column on DeliveryMethod — the model no longer includes `Spree::DisplayOn`, the boolean carries a `null: false, default: true` DB default, and `display_on` survives only as a deprecated reader/writer pair. The magic-integer `DISPLAY_ON_FRONT_END`/`BACK_END` rate filter became `DeliveryMethod::STOREFRONT` / `BACKOFFICE` with `#available_to?(audience)` (`#available_to_display?` kept as a deprecated bridge that still accepts the old integers). `shipping_method_categories` / `shipping_categories` are flagged `deprecated: true`; the product factory no longer auto-assigns a ShippingCategory; and the product factory no longer auto-assigns a ShippingCategory.++**CSV `shipping_category` is a clean break, not a bridge (2026-08-05).** The column is gone from both the import schema and the export presenter, replaced by `product_type` (export never had it before, so import and export now agree). Rationale: ShippingCategory already had **zero** live behavior — delivery eligibility runs entirely through `ProductType#fulfillment_types` via `Package#eligible_delivery_methods`, and nothing reads the category for routing. Carrying a deprecated CSV column plus a name-matching bridge would have been maintaining a translation layer onto a model that no longer decides anything. Also removed as part of the same sweep: `shipping_category_id` from permitted product attributes (replaced by `product_type_id`, which was never permitted — a real gap), the `shipping_category` Ransack association on Product (now `product_type`), the dead `Store#default_shipping_category`/`#digital_shipping_category` helpers, `PermittedAttributes.shipping_category_attributes`, and the two dangling API serializer registrations (the admin one pointed at a class that never existed).++**Ruby-level readers keep working through 6.0**, unlike the CSV column — the break there is justified because a CSV field is data a merchant re-exports, while a model reader is code an extension calls. `Product#shipping_category` and `#shipping_methods` stay as `deprecated: true` associations, and `Variant#shipping_category`/`#shipping_category_id` stay as explicit `Spree::Deprecation.warn` delegates (a plain `delegate` can't warn). `Variant` also gained `product_type`/`product_type_id` delegates alongside them. All four die with the table in 6.1.++**Internal method vocabulary follows the models (2026-08-05).** Core code now calls the delivery/fulfillment names everywhere; the shipping-era names survive one release as `Spree::Deprecation.warn` bridges. Renamed: `Stock::Estimator#shipping_rates` → `#delivery_rates` (and its internals — `calculate_`/`choose_default_`/`sort_`, plus the `shipping_methods` filter seam → `#delivery_methods`, which host apps override), `Stock::Package#shipping_rates`/`#to_shipment` → `#delivery_rates`/`#to_fulfillment`, `Stock::Coordinator#shipments` → `#fulfillments`, `Order#line_items_without_shipping_rates` → `#line_items_without_delivery_rates`, `Order#ensure_available_shipping_rates` → `#ensure_available_delivery_rates` (private — no bridge), and `LineItem#shipping_cost`/`#display_shipping_cost` → `#delivery_cost`/`#display_delivery_cost`. **`Spree::Cart` gets no deprecation bridges at all** — it is new in 6.0, so no legacy caller can exist; its equivalent is simply `#ensure_available_delivery_rates`.++**Remaining for 6.0:** only the vendor axis (`belongs_to :vendor` replacing the `Spree::VendorConcern` decorator seam, `DeliveryMethodStockLocation` vendor-consistency validation, and refusing `pickup_stock_policy: 'any'` on vendor-owned locations). It is gated on `6.0-multi-vendor-marketplace.md` shipping the `vendor_id` column in its schema wave. Everything else outstanding is Phase 6 (6.1) cleanup.++### Shipped earlier (verified 2026-07-27, HEAD 4e5b6fd)++The following predates the phase work above and must NOT be redone:- **API v3 speaks the new vocabulary over the old models**: `FulfillmentSerializer`, `DeliveryMethodSerializer`, `DeliveryRateSerializer` (+ Admin variants), `fulfillments` routes and controllers (store carts + admin orders), dual old/new registrations in `api/lib/spree/api/dependencies.rb:111-128, 191-213`. `FulfillmentSerializer` already emits `status` (from `state`), `fulfilled_at` (from `shipped_at`), and a **computed** `fulfillment_type` (`digital? ? 'digital' : 'shipping'`).- **Prefix IDs claimed**: `ful_` (Shipment), `dm_` (ShippingMethod), `fi_` (InventoryUnit), `dr_` (via `Shipment#selected_delivery_rate_id`, whose YARD comment cites this plan).- **Order aliases**: `alias_attribute :fulfillment_status, :shipment_state` and `alias_attribute :delivery_total, :shipment_total` (`order.rb:211-213`) — the Phase 1 column renames must remove these aliases in the same change.- **`Spree::Fulfillments::Create` service** (`core/app/services/spree/fulfillments/create.rb`), registered as `Spree.fulfillment_create_service`.- **StockLocation pickup columns** (shipped 2026-05-08): `kind`, `pickup_enabled`, `pickup_stock_policy`, `pickup_ready_in_minutes`, `pickup_instructions` + indexes. **Do not re-add.** Reviewed 2026-08-02 — all five stay (shipped 5.x schema + admin API contract; `pickup_stock_policy` is genuinely per-location: which counters accept ship-to-store transfers varies by counter). **Rule going forward: no new per-fulfillment-type column sets on `spree_stock_locations`** — future capabilities (local-delivery radius, courier windows, …) express through the provider/method/`DeliveryMethodStockLocation` axis, not location columns. `kind` is currently unread by business logic and reserved for `6.0-inventory-operations.md` (warehouse vs store operations); do not drop or repurpose without checking that plan.-- **admin-sdk generated types are already clean** (zero `shipment` references); `packages/dashboard/src` still has 8 files on old vocabulary.+- **admin-sdk generated types are already clean** (zero `shipment` references). The dashboard has since followed: its only remaining `shipment` hits are one translation key and legitimate `shipping_address` references.-Outstanding: model/table/column renames, the eligibility rework, FulfillmentProvider, lifecycle events, and the legacy-admin/emails surfaces.+(All of the above has since been superseded by the phase work — see "Implementation status".)## Entity Rename Map@@ -248,20 +262,20 @@ Merchant pickup: `GET /delivery_methods?fulfillment_type=pickup` → `GET /delivPhase 1 as previously drafted was one ~20-operation migration; per CLAUDE.md (data transformations never in migrations) and the verification findings it is now split. **The earlier draft's migration is void** — it re-added shipped columns, targeted the nonexistent `spree_product_types`, and migrated a `spree_store_shipping_methods` join table that has never existed (see decisions.md 2026-03-16 correction).-### Phase 0 — gates+### Phase 0 — gates ✅ shipped- `6.0-product-types.md` shipped — **including the `fulfillment_types` column** (owned by that plan's Phase 1 migration; previously orphaned between the two plans).- `6.0-cart-order-split.md` fleshed out enough to confirm the owner shape (Open Question 1).- `6.0-delivery-rate-provider.md` Phase 1 (`store_id`) — independent, can land before or after.- `6.0-typed-stock-movements.md` confirmed born with `fulfillment_id` (dependency inverted from the earlier draft).-### Phase 1a — renames (schema only)+### Phase 1a — renames (schema only) ✅ shipped- Tables per the rename map; FK columns: `delivery_rates.{shipment_id→fulfillment_id, shipping_method_id→delivery_method_id}`, `fulfillment_items.shipment_id→fulfillment_id`, `delivery_method_zones.shipping_method_id→delivery_method_id`, **`return_items.inventory_unit_id→fulfillment_item_id`** (missed by the earlier draft), `orders.{shipment_state→fulfillment_status, shipment_total→delivery_total}` (removing the shipped aliases in the same change).- `display_on` → `storefront_visible` boolean on `spree_delivery_methods`, jointly with `5.5-6.0-display-on-to-boolean.md` Phase 2 (answering its coordination request).- Rename affected indexes (`spree_shipping_rates_join_index` — keep its uniqueness, it's the one-rate-per-method invariant).-### Phase 1b — new columns/tables (additive)+### Phase 1b — new columns/tables (additive) ✅ shipped- `delivery_methods`: `fulfillment_type` (nullable, indexed — default `'shipping'` lives on the model per house rule; existing rows backfilled by the Phase 2 data task), `fulfillment_provider` (nullable — model default Manual, `#provider` falls back on blank), `pickup_point_provider`.- `fulfillments`: `fulfillment_type`, `pickup_point_data` (JSON, jsonb-guarded), `cart_id` (per owner decision).@@ -269,7 +283,7 @@ Phase 1 as previously drafted was one ~20-operation migration; per CLAUDE.md (da- `products.excluded_delivery_method_ids` (JSON, jsonb-guarded).- NOT here: StockLocation pickup columns (shipped), `store_id` (delivery-rate plan), `vendor_id` (marketplace wave).-### Phase 2 — data rake tasks (`spree:migrate_shipping_to_delivery`)+### Phase 2 — data rake tasks (`spree:migrate_shipping_to_delivery`) ✅ shipped1. **Polymorphic/stored strings** (missed entirely by the earlier draft): `spree_state_changes.stateful_type` + `name`, `spree_adjustments.adjustable_type`, `spree_stock_movements.originator_type` — `'Spree::Shipment'` → `'Spree::Fulfillment'`.2. `fulfillment_type` backfill: methods with a `DigitalDelivery` calculator → `'digital'` + `FulfillmentProvider::Digital`; all others `'shipping'`. Copy to existing fulfillments from their selected method.@@ -278,7 +292,7 @@ Phase 1 as previously drafted was one ~20-operation migration; per CLAUDE.md (daBatched, idempotent, resumable — same guarantees as the split-adjustments migration.-### Phase 3 — model renames + behavior+### Phase 3 — model renames + behavior ✅ shipped- Model/file renames + one-release deprecation aliases (`Spree::Shipment = Spree::Fulfillment` etc.). ShippingCategory gets **no alias** — referencing it raises `NameError` (the earlier draft's `= nil` would produce confusing `NoMethodError`s instead).- `FulfilmentChanger` → `FulfillmentChanger`; `ShipmentHandler` removed in favor of providers.@@ -286,13 +300,13 @@ Batched, idempotent, resumable — same guarantees as the split-adjustments migr- `Package#eligible_delivery_methods` + `Splitter::FulfillmentType`; digital discriminator moved to columns; `Product#digital?`/`#fulfillment_types` on ProductType; remove ShippingCategory validations/auto-assign from Product **in this phase** (the column drops in 6.1 — products must stay saveable in between).- Order rollup rename with `backorder` preserved; CanCanCan grants; permitted attributes; seeds (incl. `Seeds::DigitalDelivery` and the hardcoded `'Digital'`/`'Default'` store category readers); factories (`product_factory` assigns a shipping category to every product — whole-suite impact).-### Phase 4 — providers + events+### Phase 4 — providers + events ✅ shipped- `FulfillmentProvider::{Base,Manual,Digital,Pickup,PickupPoint}` wired into transitions; `PickupPointProvider::Base` + option struct; `Spree.fulfillment_providers` / `Spree.fulfillment_types` registries.- Lifecycle events + `order.fulfilled`; `shipment.*` → `fulfillment.*` webhook migration with one-release dual-emit.- DigitalLink creation moves from the checkout callback into `FulfillmentProvider::Digital` (idempotent, per-quantity).-### Phase 5 — remaining surfaces+### Phase 5 — remaining surfaces ✅ shipped (except the vendor axis, gated on the marketplace schema wave)- API: switch `FulfillmentSerializer#fulfillment_type` from computed to column-backed; pickup endpoints (`/pickup_locations`, `/pickup_points`); `storefront_visible` exposure; regenerate the type pipeline. (Most serializer/route work already shipped — see "Already shipped".)- **Emails gem** (20 files — never mentioned in the earlier draft): `shipment_mailer`, subscriber, templates → fulfillment vocabulary.@@ -301,12 +315,14 @@ Batched, idempotent, resumable — same guarantees as the split-adjustments migr### Phase 6 — cleanup (6.1)- Drop deprecation aliases, `spree_shipping_categories` + `spree_shipping_method_categories`, `products.shipping_category_id`, dual-emitted `shipment.*` events, the dangling `admin_shipping_category_serializer` / v2 platform registrations.+- Also added by the 2026-08-05 work: `DeliveryMethod#display_on` / `#display_on=` / `#available_to_display?` and the `DISPLAY_ON_FRONT_END`/`BACK_END` constants, the `deprecated: true` `shipping_method_categories` / `shipping_categories` associations on DeliveryMethod, the `deprecated: true` `shipping_category` / `shipping_methods` associations on Product, `Variant#shipping_category` / `#shipping_category_id`, and the `spree_delivery_methods.display_on` column. Plus the method bridges listed above: `Estimator#shipping_rates`/`#shipping_methods`, `Package#shipping_rates`/`#to_shipment`, `Coordinator#shipments`, `Order#line_items_without_shipping_rates`, and `LineItem#shipping_cost`/`#display_shipping_cost`. The CSV surface needs no cleanup — it was cut outright in 6.0.+- `FulfillmentSerializer#fulfillment_type` can drop its computed fallback once every install has run `spree:migrate_shipping_to_delivery`.## Constraints on Current Work- **Use "delivery method" / "fulfillment" in all new API v3 code.** No new `shipping_method` / `shipment` references. New tables referencing shipments are born with `fulfillment_id`.- **Don't add features to ShippingCategory or InventoryUnit** — both are being replaced.-- **Don't include `Spree::DisplayOn` in new models** (display-on plan constraint); use `storefront_visible`.+- **Don't include `Spree::DisplayOn` in new models** (display-on plan constraint); use `storefront_visible`. On `DeliveryMethod` the boolean column is already authoritative — never read or write `display_on` there, and filter rate audiences with `DeliveryMethod::STOREFRONT` / `BACKOFFICE`, not the legacy `DISPLAY_ON_*` integers.- **Don't build on `ShipmentHandler`** — it's removed; fulfillment mechanics belong to providers.- **Don't touch calculators here** — kept per decisions.md 2026-07-27; rate estimation belongs to the delivery-rate-provider plan. Zone→DeliveryZone belongs to `6.0-delivery-zones.md` (this plan only births the join table correctly).diff --git a/docs/plans/6.0-product-types.md b/docs/plans/6.0-product-types.mdindex eb2b02aa5c..0779bd6561 100644--- a/docs/plans/6.0-product-types.md+++ b/docs/plans/6.0-product-types.md@@ -1,6 +1,6 @@# ProductType (Prototype → ProductType)-**Status:** Draft+**Status:** Phases 1 and 3 shipped, Phase 4 partly; Phase 2 pending — see "Implementation status"**Target:** Spree 6.0**Depends on:** Custom Fields system (Metafields, shipped 5.4; 6.0 vocabulary per `5.4-6.0-custom-fields-rename.md`), `6.0-store-scoped-custom-field-definitions.md` (definitions become store-owned — the joins here validate same-store). Coordinates with: `6.0-replace-taxons-with-categories.md` (this plan ships **before** the Taxon→Category table rename; the `class_name` flip happens in that plan's wave). Consumed by: `6.0-fulfillment-and-delivery.md` (`fulfillment_types` replaces ShippingCategory — that plan cannot ship before this one).**Author:** Damian + Claude@@ -14,6 +14,14 @@ ProductType acts as an **authoritative template** for option types: changes to aThis closes Spree's biggest functional gap in catalog modeling, while building on existing infrastructure rather than starting from scratch.+## Implementation status (verified 2026-08-05)++**Shipped:** Phase 1 (the `Spree::ProductType` model, both join models, `fulfillment_types` with registry-backed validation, `Product#product_type` + `#fulfillment_types` + `#digital?`), Phase 3 (admin API controller, Store + Admin serializers), and most of Phase 4 (dashboard settings page, product-types table, `product_type_id` on the product form).++**Pending:** Phase 2 — the `ProductTypeCustomFieldDefinition` join and everything resting on it, which is the schema-enforcement half of the plan: locked type-defined option types, the type-driven custom-field form, and required-field validation on activation.++**ShippingCategory is fully retired from behavior (2026-08-05).** `ProductType#fulfillment_types` is the sole delivery-eligibility input — `Stock::Package#eligible_delivery_methods` reads it and nothing consults the category for routing. The CSV `shipping_category` column was cut outright rather than bridged (see `6.0-fulfillment-and-delivery.md`); `Product#shipping_category` survives only as a deprecated association, dropping with the table in 6.1.+## Problem1. **No product schema enforcement.** All Spree products share the same shape. A merchant selling T-shirts and laptops has no way to say "T-shirts must have Size and Color; laptops must have RAM and Storage" without custom code.diff --git a/spree/api/app/serializers/spree/api/v3/shipping_category_serializer.rb b/spree/api/app/serializers/spree/api/v3/shipping_category_serializer.rbdeleted file mode 100644index f4437d8e7e..0000000000--- a/spree/api/app/serializers/spree/api/v3/shipping_category_serializer.rb+++ /dev/null@@ -1,11 +0,0 @@-module Spree- module Api- module V3- class ShippingCategorySerializer < BaseSerializer- typelize name: :string-- attributes :id, :name- end- end- end-enddiff --git a/spree/api/lib/spree/api/dependencies.rb b/spree/api/lib/spree/api/dependencies.rbindex d38ada6142..ede1738212 100644--- a/spree/api/lib/spree/api/dependencies.rb+++ b/spree/api/lib/spree/api/dependencies.rb@@ -55,7 +55,6 @@ module Spreelocale_serializer: 'Spree::Api::V3::LocaleSerializer',policy_serializer: 'Spree::Api::V3::PolicySerializer',custom_field_serializer: 'Spree::Api::V3::CustomFieldSerializer',- shipping_category_serializer: 'Spree::Api::V3::ShippingCategorySerializer',tax_category_serializer: 'Spree::Api::V3::TaxCategorySerializer',product_filters_serializer: 'Spree::Api::V3::ProductFiltersSerializer',product_filter_price_range_serializer: 'Spree::Api::V3::ProductFilterPriceRangeSerializer',@@ -137,7 +136,6 @@ module Spreeadmin_exchange_line_item_serializer: 'Spree::Api::V3::Admin::ExchangeLineItemSerializer',admin_claim_serializer: 'Spree::Api::V3::Admin::ClaimSerializer',admin_claim_line_item_serializer: 'Spree::Api::V3::Admin::ClaimLineItemSerializer',- admin_shipping_category_serializer: 'Spree::Api::V3::Admin::ShippingCategorySerializer',admin_tax_category_serializer: 'Spree::Api::V3::Admin::TaxCategorySerializer',admin_return_authorization_serializer: 'Spree::Api::V3::Admin::ReturnAuthorizationSerializer',admin_reimbursement_serializer: 'Spree::Api::V3::Admin::ReimbursementSerializer',diff --git a/spree/core/app/models/spree/cart.rb b/spree/core/app/models/spree/cart.rbindex 57c32e1789..3026ed66c2 100644--- a/spree/core/app/models/spree/cart.rb+++ b/spree/core/app/models/spree/cart.rb@@ -149,7 +149,7 @@ module Spreefulfillments.delete_allfulfillment_items.reset- self.fulfillments = Spree::Stock::Coordinator.new(self).shipments.map do |fulfillment|+ self.fulfillments = Spree::Stock::Coordinator.new(self).fulfillments.map do |fulfillment|fulfillment.address_id = ship_address_idfulfillment.order = nilfulfillment.cart = self@@ -161,7 +161,7 @@ module Spree# Drops proposals that found no delivery rates and surfaces a# delivery_unavailable warning per affected line item (parity with the- # order-side ensure_available_shipping_rates).+ # order-side ensure_available_delivery_rates).def prune_undeliverable_fulfillments!undeliverable = fulfillments.reload.select { |fulfillment| fulfillment.delivery_rates.empty? }return if undeliverable.empty?@@ -177,7 +177,7 @@ module Spreeendend- def ensure_available_shipping_rates+ def ensure_available_delivery_ratesif fulfillments.empty? || fulfillments.any? { |fulfillment| fulfillment.delivery_rates.blank? }errors.add(:base, Spree.t(:items_cannot_be_shipped))return falsediff --git a/spree/core/app/models/spree/delivery_method.rb b/spree/core/app/models/spree/delivery_method.rbindex 25333da12c..ad7fce8f5d 100644--- a/spree/core/app/models/spree/delivery_method.rb+++ b/spree/core/app/models/spree/delivery_method.rb@@ -7,7 +7,6 @@ module Spreeinclude Spree::CalculatedAdjustmentsinclude Spree::Metafieldsinclude Spree::Metadata- include Spree::DisplayOnif defined?(Spree::VendorConcern)include Spree::VendorConcernend@@ -17,14 +16,18 @@ module SpreeMEMOIZED_METHODS = %w[display_estimated_price]- # Used for #refresh_rates+ # Audience a rate refresh is quoting for: the storefront sees only+ # customer-facing methods, the backoffice sees every method.+ STOREFRONT = :storefront+ BACKOFFICE = :backoffice++ # @deprecated Use {STOREFRONT}/{BACKOFFICE}; removed in 6.1.DISPLAY_ON_FRONT_END = 1+ # @deprecated Use {STOREFRONT}/{BACKOFFICE}; removed in 6.1.DISPLAY_ON_BACK_END = 2default_scope { where(deleted_at: nil) }- has_many :shipping_method_categories, foreign_key: :shipping_method_id, dependent: :destroy- has_many :shipping_categories, through: :shipping_method_categorieshas_many :delivery_rates, class_name: 'Spree::DeliveryRate', inverse_of: :delivery_methodhas_many :fulfillments, through: :delivery_rates, class_name: 'Spree::Fulfillment'@@ -40,7 +43,7 @@ module Spreebelongs_to :tax_category, -> { with_deleted }, class_name: 'Spree::TaxCategory', optional: true- attribute :display_on, :string, default: 'both'+ attribute :storefront_visible, :boolean, default: trueattribute :fulfillment_type, :string, default: 'shipping'# Every method rates through a calculator; pickup/digital methods default@@ -50,12 +53,27 @@ module Spreescope :by_fulfillment_type, ->(type) { where(fulfillment_type: type) }+ # Customer-facing methods vs backoffice-only ones (manual courier entry,+ # internal freight). The backoffice always sees every method.+ scope :storefront_visible, -> { where(storefront_visible: true) }+ scope :admin_only, -> { where(storefront_visible: false) }+# Legacy association names — removed in 6.1.has_many :shipping_rates, class_name: 'Spree::DeliveryRate', foreign_key: :delivery_method_id, deprecated: truehas_many :shipments, through: :delivery_rates, source: :fulfillment, deprecated: truehas_many :zones, through: :delivery_method_zones, source: :delivery_zone, deprecated: true- validates :name, :display_on, :fulfillment_type, presence: true+ # ShippingCategory eligibility is superseded by fulfillment types+ # (ProductType#fulfillment_types); both tables drop in 6.1.+ has_many :shipping_method_categories, foreign_key: :shipping_method_id, dependent: :destroy, deprecated: true+ has_many :shipping_categories, through: :shipping_method_categories, deprecated: true++ # Real column, so no ransacker is needed — only the allowlist entry the+ # Spree::DisplayOn concern used to contribute.+ self.whitelisted_ransackable_attributes = %w[storefront_visible fulfillment_type]++ validates :name, :fulfillment_type, presence: true+ validates :storefront_visible, inclusion: { in: [true, false] }# Strict vocabulary: an unregistered type silently matches no product# (empty intersection — no error, just missing rates), so typos must# fail loudly. Validated on change only: rows migrated with tokens not@@ -172,9 +190,26 @@ module Spreeselect { |c| c.to_s.constantize < Spree::ShippingCalculator }end+ # Whether this method may be quoted for the given audience. The+ # backoffice sees every method; the storefront only customer-facing ones.+ # An unrecognized audience raises rather than silently quoting storefront+ # rates — a typo must not narrow the offer set unnoticed.+ #+ # @param audience [Symbol] {STOREFRONT} or {BACKOFFICE}+ # @return [Boolean]+ def available_to?(audience)+ case audience+ when BACKOFFICE then true+ when STOREFRONT then storefront_visible?+ else raise ArgumentError, "unknown delivery audience #{audience.inspect} (expected #{STOREFRONT.inspect} or #{BACKOFFICE.inspect})"+ end+ end++ # @deprecated Use {#available_to?} with {STOREFRONT}/{BACKOFFICE};+ # removed in 6.1.def available_to_display?(display_filter)- (frontend? && display_filter == DISPLAY_ON_FRONT_END) ||- (backend? && display_filter == DISPLAY_ON_BACK_END)+ Spree::Deprecation.warn('Spree::DeliveryMethod#available_to_display? is deprecated and will be removed in Spree 6.1. Use #available_to?(Spree::DeliveryMethod::STOREFRONT / BACKOFFICE) instead.')+ available_to?(display_filter == DISPLAY_ON_BACK_END ? BACKOFFICE : STOREFRONT)enddef delivery_range@@ -216,15 +251,16 @@ module Spreefulfillment_type == 'digital'end- private-- # Some shipping methods are only meant to be set via backend- def frontend?- display_on.in?(['both', 'front_end'])+ # @deprecated Use {#storefront_visible}; removed in 6.1.+ def display_on+ Spree::Deprecation.warn('Spree::DeliveryMethod#display_on is deprecated and will be removed in Spree 6.1. Use #storefront_visible instead.')+ storefront_visible? ? 'both' : 'back_end'end- def backend?- display_on.in?(['both', 'back_end'])+ # @deprecated Use {#storefront_visible=}; removed in 6.1.+ def display_on=(value)+ Spree::Deprecation.warn('Spree::DeliveryMethod#display_on= is deprecated and will be removed in Spree 6.1. Use #storefront_visible= instead.')+ self.storefront_visible = value.to_s != 'back_end'endendenddiff --git a/spree/core/app/models/spree/fulfillment.rb b/spree/core/app/models/spree/fulfillment.rbindex 343a685df4..6ca58d4259 100644--- a/spree/core/app/models/spree/fulfillment.rb+++ b/spree/core/app/models/spree/fulfillment.rb@@ -418,7 +418,10 @@ module Spreeready? || pending?end- def refresh_rates(shipping_method_filter = DeliveryMethod::DISPLAY_ON_FRONT_END)+ # @param audience [Symbol] {Spree::DeliveryMethod::STOREFRONT} (default)+ # or {Spree::DeliveryMethod::BACKOFFICE}+ # @return [Array<Spree::DeliveryRate>]+ def refresh_rates(audience = DeliveryMethod::STOREFRONT)return delivery_rates if fulfilled?return [] unless can_get_rates?@@ -426,7 +429,7 @@ module Spreeoriginal_shipping_method_id = delivery_method.try(:id)self.delivery_rates = Stock::Estimator.new(owner).- shipping_rates(to_package, shipping_method_filter)+ delivery_rates(to_package, audience)if delivery_methodselected_rate = delivery_rates.detect do |rate|diff --git a/spree/core/app/models/spree/import_schemas/products.rb b/spree/core/app/models/spree/import_schemas/products.rbindex a52cf210f4..51c7550aa4 100644--- a/spree/core/app/models/spree/import_schemas/products.rb+++ b/spree/core/app/models/spree/import_schemas/products.rb@@ -27,7 +27,6 @@ module Spree{ name: 'inventory_backorderable', label: 'Inventory Backorderable' },{ name: 'tax_category', label: 'Tax Category' },{ name: 'product_type', label: 'Product Type' },- { name: 'shipping_category', label: 'Shipping Category (deprecated — use Product Type)' },{ name: 'image1_src', label: 'Image 1 URL' },{ name: 'image2_src', label: 'Image 2 URL' },{ name: 'image3_src', label: 'Image 3 URL' },diff --git a/spree/core/app/models/spree/line_item.rb b/spree/core/app/models/spree/line_item.rbindex f953facc83..0272b41a68 100644--- a/spree/core/app/models/spree/line_item.rb+++ b/spree/core/app/models/spree/line_item.rb@@ -141,7 +141,7 @@ module Spreeextend DisplayMoneymoney_methods :amount, :subtotal, :discounted_amount, :final_amount, :total, :price, :discounted_price,:adjustment_total, :additional_tax_total, :promo_total, :included_tax_total,- :pre_tax_amount, :shipping_cost, :tax_total, :compare_at_amount+ :pre_tax_amount, :delivery_cost, :tax_total, :compare_at_amountalias single_money display_pricealias single_display_amount display_price@@ -247,33 +247,37 @@ module Spreefulfillment_items.all?(&:shipped?)end- # Returns the shipping cost for the line item+ # This line item's share of its fulfillments' delivery cost, split+ # proportionally by unit count.## @return [BigDecimal]- def shipping_cost- fulfillments.sum do |shipment|- # Skip cancelled shipments- return BigDecimal('0') if shipment.canceled?-- # Skip shipments with no cost/zero cost- return BigDecimal('0') if shipment.cost.zero?-- # Get total inventory units in this shipment- total_units = shipment.fulfillment_items+ def delivery_cost+ fulfillments.sum do |fulfillment|+ return BigDecimal('0') if fulfillment.canceled?+ return BigDecimal('0') if fulfillment.cost.zero?- # Calculate proportional shipping cost+ total_units = fulfillment.fulfillment_itemsreturn BigDecimal('0') if total_units.empty?- # Get all inventory units in this shipment for this line item- line_item_units = shipment.fulfillment_items.find_all { |unit| unit.line_item_id == id }.count-- # Calculate proportional shipping cost+ line_item_units = fulfillment.fulfillment_items.find_all { |unit| unit.line_item_id == id }.countreturn BigDecimal('0') if line_item_units.zero?- shipment.cost * (line_item_units.to_d / total_units.count)+ fulfillment.cost * (line_item_units.to_d / total_units.count)endend+ # @deprecated Use {#delivery_cost}; removed in 6.1.+ def shipping_cost+ Spree::Deprecation.warn('Spree::LineItem#shipping_cost is deprecated and will be removed in Spree 6.1. Use #delivery_cost instead.')+ delivery_cost+ end++ # @deprecated Use {#display_delivery_cost}; removed in 6.1.+ def display_shipping_cost+ Spree::Deprecation.warn('Spree::LineItem#display_shipping_cost is deprecated and will be removed in Spree 6.1. Use #display_delivery_cost instead.')+ display_delivery_cost+ end+def options=(options = {})return unless options.present?diff --git a/spree/core/app/models/spree/metafield_definition.rb b/spree/core/app/models/spree/metafield_definition.rbindex 71b761ecb2..111925263c 100644--- a/spree/core/app/models/spree/metafield_definition.rb+++ b/spree/core/app/models/spree/metafield_definition.rb@@ -55,8 +55,8 @@ module Spree# API naming bridge — internal columns rename in 6.0. `label` matches# OptionType/OptionValue conventions. (`storefront_visible` lives on- # the `Spree::DisplayOn` concern, shared with PaymentMethod + ShippingMethod —- # see docs/plans/5.5-6.0-display-on-to-boolean.md.)+ # the `Spree::DisplayOn` concern, shared with PaymentMethod; DeliveryMethod+ # already owns a real column — see docs/plans/5.5-6.0-display-on-to-boolean.md.)alias_attribute :label, :name# API-facing token for the STI subclass name stored in `metafield_type`.diff --git a/spree/core/app/models/spree/order.rb b/spree/core/app/models/spree/order.rbindex e1e76a4634..4016ebe2e7 100644--- a/spree/core/app/models/spree/order.rb+++ b/spree/core/app/models/spree/order.rb@@ -63,7 +63,7 @@ module Spreealias display_ship_total display_delivery_totalalias_attribute :ship_total, :delivery_total- # Transient warnings populated by remove_out_of_stock_items! and ensure_available_shipping_rates+ # Transient warnings populated by remove_out_of_stock_items! and ensure_available_delivery_ratesattribute :warnings, default: -> { [] }# Removes out-of-stock/discontinued items and populates warnings.@@ -704,7 +704,7 @@ module Spreefulfillment_items.on_hand_or_backordered.delete_allself.fulfillments = order_routing_strategy.for_allocation.map do |package|- package.to_shipment.tap { |s| s.address_id = ship_address_id }+ package.to_fulfillment.tap { |fulfillment| fulfillment.address_id = ship_address_id }endend@@ -765,20 +765,26 @@ module Spree@total_weight ||= line_items.joins(:variant).includes(:variant).map(&:item_weight).sumend- # Returns line items that have no shipping rates+ # Returns line items that have no delivery rates## @return [Array<Spree::LineItem>]- def line_items_without_shipping_rates- @line_items_without_shipping_rates ||= fulfillments.map do |shipment|- shipment.manifest.map(&:line_item) if shipment.shipping_rates.blank?+ def line_items_without_delivery_rates+ @line_items_without_delivery_rates ||= fulfillments.map do |fulfillment|+ fulfillment.manifest.map(&:line_item) if fulfillment.delivery_rates.blank?end.flatten.compactend+ # @deprecated Use {#line_items_without_delivery_rates}; removed in 6.1.+ def line_items_without_shipping_rates+ Spree::Deprecation.warn('Spree::Order#line_items_without_shipping_rates is deprecated and will be removed in Spree 6.1. Use #line_items_without_delivery_rates instead.')+ line_items_without_delivery_rates+ end+# Checks if all line items cannot be shipped## @returns Booleandef all_line_items_invalid?- line_items_without_shipping_rates.size == line_items.count+ line_items_without_delivery_rates.size == line_items.countenddef apply_free_shipping_promotions@@ -808,8 +814,8 @@ module Spreeensure_updated_fulfillmentsend- def refresh_shipment_rates(shipping_method_filter = DeliveryMethod::DISPLAY_ON_FRONT_END)- fulfillments.map { |s| s.refresh_rates(shipping_method_filter) }+ def refresh_shipment_rates(audience = DeliveryMethod::STOREFRONT)+ fulfillments.map { |s| s.refresh_rates(audience) }enddef set_shipments_cost@@ -1015,15 +1021,15 @@ module Spreeendend- def ensure_available_shipping_rates- if fulfillments.empty? || line_items_without_shipping_rates.present?+ def ensure_available_delivery_rates+ if fulfillments.empty? || line_items_without_delivery_rates.present?# After this point, order redirects back to 'address' state and asks user to pick a proper address# Therefore, shipments are not necessary at this point.fulfillments.destroy_all- if line_items_without_shipping_rates.present?- errors.add(:base, Spree.t(:products_cannot_be_shipped, product_names: line_items_without_shipping_rates.map(&:name).to_sentence))- self.warnings |= line_items_without_shipping_rates.map do |line_item|+ if line_items_without_delivery_rates.present?+ errors.add(:base, Spree.t(:products_cannot_be_shipped, product_names: line_items_without_delivery_rates.map(&:name).to_sentence))+ self.warnings |= line_items_without_delivery_rates.map do |line_item|{code: 'delivery_unavailable',message: Spree.t('cart_line_item.delivery_unavailable', li_name: line_item.name),diff --git a/spree/core/app/models/spree/order_routing/strategy/rules.rb b/spree/core/app/models/spree/order_routing/strategy/rules.rbindex 4ba887fee5..3b1d70d2a4 100644--- a/spree/core/app/models/spree/order_routing/strategy/rules.rb+++ b/spree/core/app/models/spree/order_routing/strategy/rules.rb@@ -74,7 +74,7 @@ module Spreedef estimate_rates(packages)estimator = Spree::Stock::Estimator.new(order)- packages.each { |pkg| pkg.shipping_rates = estimator.shipping_rates(pkg) }+ packages.each { |pkg| pkg.delivery_rates = estimator.delivery_rates(pkg) }packagesendenddiff --git a/spree/core/app/models/spree/order_updater.rb b/spree/core/app/models/spree/order_updater.rbindex d1696af8db..2f0ed73a9e 100644--- a/spree/core/app/models/spree/order_updater.rb+++ b/spree/core/app/models/spree/order_updater.rb@@ -115,7 +115,7 @@ module Spreedef update_shipmentsSpree::Deprecation.warn('Spree::OrderUpdater#update_shipments is deprecated and will be removed in Spree 6.1. Use Spree::Orders::UpdateStatuses (fulfillment states) and Spree::Carts::Recalculate (delivery proposals) instead.')- shipping_method_filter = order.completed? ? DeliveryMethod::DISPLAY_ON_BACK_END : DeliveryMethod::DISPLAY_ON_FRONT_END+ audience = order.completed? ? DeliveryMethod::BACKOFFICE : DeliveryMethod::STOREFRONTfulfillments.each do |fulfillment|next unless fulfillment.persisted?@@ -123,7 +123,7 @@ module Spreefulfillment.update!(order)next if order.completed? && fulfillment.fulfilled?- fulfillment.refresh_rates(shipping_method_filter)+ fulfillment.refresh_rates(audience)fulfillment.update_amountsendenddiff --git a/spree/core/app/models/spree/product.rb b/spree/core/app/models/spree/product.rbindex a70d45ce8f..310dadb212 100644--- a/spree/core/app/models/spree/product.rb+++ b/spree/core/app/models/spree/product.rb@@ -121,9 +121,12 @@ module Spreesource: :promotionbelongs_to :tax_category, class_name: 'Spree::TaxCategory'- belongs_to :shipping_category, class_name: 'Spree::ShippingCategory', inverse_of: :products, optional: truebelongs_to :product_type, class_name: 'Spree::ProductType', optional: true, counter_cache: :products_count- has_many :shipping_methods, through: :shipping_category, class_name: 'Spree::DeliveryMethod'++ # Delivery eligibility moved to ProductType#fulfillment_types in 6.0;+ # both of these die with spree_shipping_categories in 6.1.+ belongs_to :shipping_category, class_name: 'Spree::ShippingCategory', inverse_of: :products, optional: true, deprecated: true+ has_many :shipping_methods, through: :shipping_category, class_name: 'Spree::DeliveryMethod', deprecated: true# Every product has at least one variant. `default_variant` is the "face" of# the product (price display, default add-to-cart, property delegation).@@ -327,7 +330,7 @@ module Spreeself.whitelisted_ransackable_attributes = %w[description name slug discontinue_on status available_on created_at updated_at]self.whitelisted_ransackable_associations = %w[categories collections store channels variants default_variant tags labels- shipping_category product_categories option_types]+ product_type product_categories option_types]self.whitelisted_ransackable_scopes = %w[not_discontinued search_by_name in_taxon in_category in_categories in_collection price_betweenprice_lte price_gtesearch multi_search in_stock out_of_stock with_option_value_idsdiff --git a/spree/core/app/models/spree/reimbursement_type/exchange_processor.rb b/spree/core/app/models/spree/reimbursement_type/exchange_processor.rbindex 7fcb1e08b6..1ceede4833 100644--- a/spree/core/app/models/spree/reimbursement_type/exchange_processor.rb+++ b/spree/core/app/models/spree/reimbursement_type/exchange_processor.rb@@ -24,7 +24,7 @@ module Spreedef perform!new_exchange_inventory_units = @reimbursement_objects.map(&:build_default_exchange_inventory_unit)- shipments = Spree::Stock::Coordinator.new(@order, new_exchange_inventory_units).shipments+ shipments = Spree::Stock::Coordinator.new(@order, new_exchange_inventory_units).fulfillmentsshipments_units = shipments.flat_map(&:fulfillment_items)if shipments_units.sum(&:quantity) != new_exchange_inventory_units.sum(&:quantity)diff --git a/spree/core/app/models/spree/report_line_items/sales_total.rb b/spree/core/app/models/spree/report_line_items/sales_total.rbindex 2c8819a52a..cae77beeb4 100644--- a/spree/core/app/models/spree/report_line_items/sales_total.rb+++ b/spree/core/app/models/spree/report_line_items/sales_total.rb@@ -26,7 +26,7 @@ module Spreeenddef total- Spree::Money.new(record.final_amount + record.shipping_cost, currency: record.currency)+ Spree::Money.new(record.final_amount + record.delivery_cost, currency: record.currency)enddef promo_total@@ -38,7 +38,7 @@ module Spreeenddef shipment_total- record.display_shipping_cost+ record.display_delivery_costenddef tax_totaldiff --git a/spree/core/app/models/spree/stock/coordinator.rb b/spree/core/app/models/spree/stock/coordinator.rbindex 575965147f..2e07a51d81 100644--- a/spree/core/app/models/spree/stock/coordinator.rb+++ b/spree/core/app/models/spree/stock/coordinator.rb@@ -9,12 +9,18 @@ module Spree@inventory_units = inventory_units || InventoryUnitBuilder.new(order).unitsend- def shipments+ def fulfillmentspackages.map do |package|- package.to_shipment.tap { |s| s.address_id = order.ship_address_id }+ package.to_fulfillment.tap { |fulfillment| fulfillment.address_id = order.ship_address_id }endend+ # @deprecated Use {#fulfillments}; removed in 6.1.+ def shipments+ Spree::Deprecation.warn('Spree::Stock::Coordinator#shipments is deprecated and will be removed in Spree 6.1. Use #fulfillments instead.')+ fulfillments+ end+def packagespackages = build_packagespackages = prioritize_packages(packages)@@ -49,7 +55,7 @@ module Spreedef estimate_packages(packages)estimator = Estimator.new(order)packages.each do |package|- package.shipping_rates = estimator.shipping_rates(package)+ package.delivery_rates = estimator.delivery_rates(package)endpackagesenddiff --git a/spree/core/app/models/spree/stock/estimator.rb b/spree/core/app/models/spree/stock/estimator.rbindex 89ae49e6be..7a1a8fb2b0 100644--- a/spree/core/app/models/spree/stock/estimator.rb+++ b/spree/core/app/models/spree/stock/estimator.rb@@ -10,43 +10,53 @@ module Spree@currency = order.currencyend- def shipping_rates(package, shipping_method_filter = ShippingMethod::DISPLAY_ON_FRONT_END)- rates = calculate_shipping_rates(package, shipping_method_filter)- choose_default_shipping_rate(rates)- sort_shipping_rates(rates)+ # @param package [Spree::Stock::Package]+ # @param audience [Symbol] {Spree::DeliveryMethod::STOREFRONT} (default)+ # or {Spree::DeliveryMethod::BACKOFFICE}+ # @return [Array<Spree::DeliveryRate>]+ def delivery_rates(package, audience = DeliveryMethod::STOREFRONT)+ rates = calculate_delivery_rates(package, audience)+ choose_default_delivery_rate(rates)+ sort_delivery_rates(rates)+ end++ # @deprecated Use {#delivery_rates}; removed in 6.1.+ def shipping_rates(package, audience = DeliveryMethod::STOREFRONT)+ Spree::Deprecation.warn('Spree::Stock::Estimator#shipping_rates is deprecated and will be removed in Spree 6.1. Use #delivery_rates instead.')+ delivery_rates(package, audience)endprivate- def choose_default_shipping_rate(shipping_rates)- unless shipping_rates.empty?- shipping_rates.min_by(&:cost).selected = true+ def choose_default_delivery_rate(delivery_rates)+ unless delivery_rates.empty?+ delivery_rates.min_by(&:cost).selected = trueendend- def sort_shipping_rates(shipping_rates)- shipping_rates.sort_by!(&:cost)+ def sort_delivery_rates(delivery_rates)+ delivery_rates.sort_by!(&:cost)end- def calculate_shipping_rates(package, ui_filter)- shipping_methods(package, ui_filter).map do |shipping_method|- cost = shipping_method.calculator.compute(package)+ def calculate_delivery_rates(package, audience)+ delivery_methods(package, audience).map do |delivery_method|+ cost = delivery_method.calculator.compute(package)next unless cost- shipping_method.shipping_rates.new(- cost: gross_amount(cost, taxation_options_for(shipping_method)),- tax_rate: first_tax_rate_for(shipping_method.tax_category)+ delivery_method.delivery_rates.new(+ cost: gross_amount(cost, taxation_options_for(delivery_method)),+ tax_rate: first_tax_rate_for(delivery_method.tax_category))end.compactend- # Override this if you need the prices for shipping methods to be handled just like the+ # Override this if you need the prices for delivery methods to be handled just like the# prices for products in terms of included tax manipulation.#- def taxation_options_for(shipping_method)+ def taxation_options_for(delivery_method){- tax_category: shipping_method.tax_category,+ tax_category: delivery_method.tax_category,tax_zone: @order.tax_zone}end@@ -58,23 +68,31 @@ module Spreepotential_rates_for_zone(@order.tax_zone).firstend- def shipping_methods(package, display_filter)+ # The eligibility seam: every rate consumer (checkout, routing, cart+ # estimates) filters through here.+ def delivery_methods(package, audience)methods = package.eligible_delivery_methods# Storeless orders exist only in specs; real orders always carry one.methods = methods.merge(order.store.delivery_methods) if order.store- methods.select do |ship_method|- calculator = ship_method.calculator+ methods.select do |delivery_method|+ calculator = delivery_method.calculator- ship_method.available_to_display?(display_filter) &&- ship_method.include?(order.ship_address) &&- ship_method.serves_location?(package.stock_location) &&- ship_method.eligible_for_package?(package) &&+ delivery_method.available_to?(audience) &&+ delivery_method.include?(order.ship_address) &&+ delivery_method.serves_location?(package.stock_location) &&+ delivery_method.eligible_for_package?(package) &&calculator.available?(package) &&(calculator.preferences[:currency].blank? ||calculator.preferences[:currency] == currency)endend++ # @deprecated Use {#delivery_methods}; removed in 6.1.+ def shipping_methods(package, audience)+ Spree::Deprecation.warn('Spree::Stock::Estimator#shipping_methods is deprecated and will be removed in Spree 6.1. Use #delivery_methods instead.')+ delivery_methods(package, audience)+ endendendenddiff --git a/spree/core/app/models/spree/stock/package.rb b/spree/core/app/models/spree/stock/package.rbindex 006776eb20..ab3cd855c7 100644--- a/spree/core/app/models/spree/stock/package.rb+++ b/spree/core/app/models/spree/stock/package.rb@@ -2,12 +2,24 @@ module Spreemodule Stockclass Packageattr_reader :stock_location, :contents- attr_accessor :shipping_rates+ attr_accessor :delivery_ratesdef initialize(stock_location, contents = [])@stock_location = stock_location@contents = contents- @shipping_rates = []+ @delivery_rates = []+ end++ # @deprecated Use {#delivery_rates}; removed in 6.1.+ def shipping_rates+ Spree::Deprecation.warn('Spree::Stock::Package#shipping_rates is deprecated and will be removed in Spree 6.1. Use #delivery_rates instead.')+ delivery_rates+ end++ # @deprecated Use {#delivery_rates=}; removed in 6.1.+ def shipping_rates=(rates)+ Spree::Deprecation.warn('Spree::Stock::Package#shipping_rates= is deprecated and will be removed in Spree 6.1. Use #delivery_rates= instead.')+ self.delivery_rates = ratesenddef add(inventory_unit, state = :on_hand)@@ -106,7 +118,7 @@ module Spreeend.join(' / ')end- def to_shipment+ def to_fulfillment# At this point we should only have one content item per inventory unit# across the entire set of inventory units to be shipped, which has been# taken care of by the Prioritizer@@ -114,11 +126,17 @@ module SpreeSpree::Fulfillment.new(stock_location: stock_location,- delivery_rates: shipping_rates,+ delivery_rates: delivery_rates,fulfillment_items: contents.map(&:inventory_unit))end+ # @deprecated Use {#to_fulfillment}; removed in 6.1.+ def to_shipment+ Spree::Deprecation.warn('Spree::Stock::Package#to_shipment is deprecated and will be removed in Spree 6.1. Use #to_fulfillment instead.')+ to_fulfillment+ end+def volumecontents.sum(&:volume)enddiff --git a/spree/core/app/models/spree/store.rb b/spree/core/app/models/spree/store.rbindex 6dc85312b3..90ea4a4243 100644--- a/spree/core/app/models/spree/store.rb+++ b/spree/core/app/models/spree/store.rb@@ -362,14 +362,6 @@ module Spreepreferred_unit_system == 'metric'end- def default_shipping_category- @default_shipping_category ||= ShippingCategory.find_or_create_by(name: 'Default')- end-- def digital_shipping_category- @digital_shipping_category ||= ShippingCategory.find_or_create_by(name: 'Digital')- end-privatedef create_default_policiesdiff --git a/spree/core/app/models/spree/variant.rb b/spree/core/app/models/spree/variant.rbindex 2b844eae08..66b3910064 100644--- a/spree/core/app/models/spree/variant.rb+++ b/spree/core/app/models/spree/variant.rb@@ -20,8 +20,8 @@ module Spreebelongs_to :product, -> { with_deleted }, touch: true, class_name: 'Spree::Product', inverse_of: :variantsbelongs_to :tax_category, class_name: 'Spree::TaxCategory', optional: true- delegate :name, :name=, :description, :slug, :available_on, :make_active_at, :shipping_category_id,- :meta_description, :meta_keywords, :shipping_category, to: :product+ delegate :name, :name=, :description, :slug, :available_on, :make_active_at, :product_type_id,+ :meta_description, :meta_keywords, :product_type, to: :productnormalizes :sku, with: ->(value) { value&.to_s&.strip }@@ -685,6 +685,18 @@ module Spreedigitals.any?end+ # @deprecated Delivery eligibility comes from {#product_type}; removed in 6.1.+ def shipping_category+ Spree::Deprecation.warn('Spree::Variant#shipping_category is deprecated and will be removed in Spree 6.1. Use #product_type instead.')+ product.shipping_category+ end++ # @deprecated Delivery eligibility comes from {#product_type_id}; removed in 6.1.+ def shipping_category_id+ Spree::Deprecation.warn('Spree::Variant#shipping_category_id is deprecated and will be removed in Spree 6.1. Use #product_type_id instead.')+ product.shipping_category_id+ end+privatedef pending_options?diff --git a/spree/core/app/presenters/spree/csv/product_variant_presenter.rb b/spree/core/app/presenters/spree/csv/product_variant_presenter.rbindex b7b5c119a9..af0bb706c6 100644--- a/spree/core/app/presenters/spree/csv/product_variant_presenter.rb+++ b/spree/core/app/presenters/spree/csv/product_variant_presenter.rb@@ -31,7 +31,7 @@ module Spree'inventory_count','inventory_backorderable','tax_category',- 'shipping_category',+ 'product_type','image1_src','image2_src','image3_src',@@ -104,7 +104,7 @@ module Spreetotal_on_hand == BigDecimal::INFINITY ? '∞' : total_on_hand,variant.backorderable?,variant.tax_category&.name,- product.shipping_category&.name,+ product.product_type&.name,spree_image_url(variant.images[0], image_url_options),spree_image_url(variant.images[1], image_url_options),spree_image_url(variant.images[2], image_url_options),diff --git a/spree/core/app/services/spree/imports/row_processors/product_variant.rb b/spree/core/app/services/spree/imports/row_processors/product_variant.rbindex 75fefbdef9..d69746e219 100644--- a/spree/core/app/services/spree/imports/row_processors/product_variant.rb+++ b/spree/core/app/services/spree/imports/row_processors/product_variant.rb@@ -132,14 +132,6 @@ module Spreeproduct_type = prepare_product_typeproduct.product_type = product_type if product_type.present?end-- # Deprecated column — accepted through 6.0 (removal with the- # ShippingCategory drop in 6.1); importers should move to- # product_type.- if attributes['shipping_category'].present?- shipping_category = prepare_shipping_category- product.shipping_category = shipping_category if shipping_category.present?- endendproduct@@ -153,13 +145,6 @@ module Spreeendend- def prepare_shipping_category- shipping_category_name = attributes['shipping_category'].strip- cached_lookup(:shipping_category, shipping_category_name) do- Spree::ShippingCategory.find_by(name: shipping_category_name)- end- end-def prepare_tax_categorytax_category_name = attributes['tax_category'].stripcached_lookup(:tax_category, tax_category_name) dodiff --git a/spree/core/app/services/spree/seeds/digital_delivery.rb b/spree/core/app/services/spree/seeds/digital_delivery.rbindex c0ede60871..2ec3bcc077 100644--- a/spree/core/app/services/spree/seeds/digital_delivery.rb+++ b/spree/core/app/services/spree/seeds/digital_delivery.rb@@ -14,7 +14,7 @@ module Spreedef create_for(store)digital_delivery_method = Spree::DeliveryMethod.find_or_initialize_by(name: Spree.t('digital.digital_delivery'), store: store)- digital_delivery_method.display_on = 'both'+ digital_delivery_method.storefront_visible = truedigital_delivery_method.fulfillment_type = 'digital'digital_delivery_method.fulfillment_provider = 'Spree::FulfillmentProvider::Digital'digital_delivery_method.calculator ||= Spree::Calculator::Shipping::DigitalDelivery.create!diff --git a/spree/core/app/workflows/spree/claims/resolve.rb b/spree/core/app/workflows/spree/claims/resolve.rbindex a06a74ecd5..9e6625ae48 100644--- a/spree/core/app/workflows/spree/claims/resolve.rb+++ b/spree/core/app/workflows/spree/claims/resolve.rb@@ -98,7 +98,7 @@ module Spreefailure(claim, :nothing_to_replace) if units.empty?- @fulfillments = Spree::Stock::Coordinator.new(claim.order, units).shipments+ @fulfillments = Spree::Stock::Coordinator.new(claim.order, units).fulfillmentsif @fulfillments.flat_map(&:fulfillment_items).sum(&:quantity) != units.sum(&:quantity)failure(claim, :replacement_out_of_stock)enddiff --git a/spree/core/app/workflows/spree/exchanges/fulfill.rb b/spree/core/app/workflows/spree/exchanges/fulfill.rbindex 9ce5c14f31..3405a1e1cb 100644--- a/spree/core/app/workflows/spree/exchanges/fulfill.rb+++ b/spree/core/app/workflows/spree/exchanges/fulfill.rb@@ -77,7 +77,7 @@ module Spreefailure(exchange, :nothing_to_fulfill) if units.empty?- @fulfillments = Spree::Stock::Coordinator.new(exchange.order, units).shipments+ @fulfillments = Spree::Stock::Coordinator.new(exchange.order, units).fulfillmentsif @fulfillments.flat_map(&:fulfillment_items).sum(&:quantity) != units.sum(&:quantity)failure(exchange, :replacement_out_of_stock)enddiff --git a/spree/core/app/workflows/spree/fulfillments/create.rb b/spree/core/app/workflows/spree/fulfillments/create.rbindex 7314c371b8..467f2e24ae 100644--- a/spree/core/app/workflows/spree/fulfillments/create.rb+++ b/spree/core/app/workflows/spree/fulfillments/create.rb@@ -137,7 +137,7 @@ module Spreenext unless fulfillment.persisted?next if fulfillment.fulfilled?- fulfillment.refresh_rates(Spree::DeliveryMethod::DISPLAY_ON_BACK_END)+ fulfillment.refresh_rates(Spree::DeliveryMethod::BACKOFFICE)fulfillment.update_amountsendenddiff --git a/spree/core/db/migrate/20260728000004_rename_shipping_to_fulfillment_and_delivery.rb b/spree/core/db/migrate/20260728000004_rename_shipping_to_fulfillment_and_delivery.rbindex c737bcec61..fbdab973ec 100644--- a/spree/core/db/migrate/20260728000004_rename_shipping_to_fulfillment_and_delivery.rb+++ b/spree/core/db/migrate/20260728000004_rename_shipping_to_fulfillment_and_delivery.rb@@ -48,9 +48,10 @@ class RenameShippingToFulfillmentAndDelivery < ActiveRecord::Migration[7.2]rename_column :spree_orders, :shipment_state, :fulfillment_statusrename_column :spree_orders, :shipment_total, :delivery_total- # display_on stays until the Wave 7 data task converts its values; the- # column drop rides the 6.1 cleanup.- add_column :spree_delivery_methods, :storefront_visible, :boolean+ # Authoritative from 6.0; display_on stays readable until the 6.1 drop.+ # Existing rows get their real value from the spree:migrate_shipping_to_delivery+ # data task, which runs after this migration.+ add_column :spree_delivery_methods, :storefront_visible, :boolean, null: false, default: trueadd_index :spree_fulfillments, :address_idadd_index :spree_fulfillments, :number, unique: truediff --git a/spree/core/db/sample_data/shipping_methods.rb b/spree/core/db/sample_data/shipping_methods.rbindex 21b2c81c81..df2ecb2778 100644--- a/spree/core/db/sample_data/shipping_methods.rb+++ b/spree/core/db/sample_data/shipping_methods.rb@@ -27,17 +27,17 @@ asia = delivery_zone_from(Spree::Zone.find_by(name: 'Asia'))australia_and_oceania = delivery_zone_from(Spree::Zone.find_by(name: 'Australia and Oceania'))delivery_methods = [- { name: 'UPS Ground (USD)', delivery_zones: [north_america], display_on: 'both' },- { name: 'UPS Two Day (USD)', delivery_zones: [north_america], display_on: 'both' },- { name: 'UPS One Day (USD)', delivery_zones: [north_america], display_on: 'both' },- { name: 'UPS Ground (EU)', delivery_zones: [europe_vat], display_on: 'both' },- { name: 'UPS Ground (EUR)', delivery_zones: [europe_vat], display_on: 'both' },- { name: 'DHL Standard (Central America and Caribbean)', delivery_zones: [central_america_and_caribbean].compact, display_on: 'both' },- { name: 'DHL Standard (South America)', delivery_zones: [south_america].compact, display_on: 'both' },- { name: 'DHL Standard (Middle East)', delivery_zones: [middle_east].compact, display_on: 'both' },- { name: 'DHL Standard (Africa)', delivery_zones: [africa].compact, display_on: 'both' },- { name: 'DHL Standard (Asia)', delivery_zones: [asia].compact, display_on: 'both' },- { name: 'DHL Standard (Australia and Oceania)', delivery_zones: [australia_and_oceania].compact, display_on: 'both' }+ { name: 'UPS Ground (USD)', delivery_zones: [north_america], storefront_visible: true },+ { name: 'UPS Two Day (USD)', delivery_zones: [north_america], storefront_visible: true },+ { name: 'UPS One Day (USD)', delivery_zones: [north_america], storefront_visible: true },+ { name: 'UPS Ground (EU)', delivery_zones: [europe_vat], storefront_visible: true },+ { name: 'UPS Ground (EUR)', delivery_zones: [europe_vat], storefront_visible: true },+ { name: 'DHL Standard (Central America and Caribbean)', delivery_zones: [central_america_and_caribbean].compact, storefront_visible: true },+ { name: 'DHL Standard (South America)', delivery_zones: [south_america].compact, storefront_visible: true },+ { name: 'DHL Standard (Middle East)', delivery_zones: [middle_east].compact, storefront_visible: true },+ { name: 'DHL Standard (Africa)', delivery_zones: [africa].compact, storefront_visible: true },+ { name: 'DHL Standard (Asia)', delivery_zones: [asia].compact, storefront_visible: true },+ { name: 'DHL Standard (Australia and Oceania)', delivery_zones: [australia_and_oceania].compact, storefront_visible: true }]delivery_methods.each do |attributes|@@ -46,7 +46,7 @@ delivery_methods.each do |attributes|Spree::DeliveryMethod.where(name: attributes[:name], store: Spree::Store.default).first_or_create! do |delivery_method|delivery_method.calculator = Spree::Calculator::Shipping::FlatRate.create!delivery_method.delivery_zones = attributes[:delivery_zones]- delivery_method.display_on = attributes[:display_on]+ delivery_method.storefront_visible = attributes[:storefront_visible]endenddiff --git a/spree/core/lib/spree/permitted_attributes.rb b/spree/core/lib/spree/permitted_attributes.rbindex b9738f642a..26f45839f5 100644--- a/spree/core/lib/spree/permitted_attributes.rb+++ b/spree/core/lib/spree/permitted_attributes.rb@@ -55,7 +55,6 @@ module Spree:role_attributes,:shipment_attributes,:shipping_method_attributes,- :shipping_category_attributes,:channel_attributes,:source_attributes,:stock_item_attributes,@@ -187,7 +186,7 @@ module Spree:name, :description, :available_on, :make_active_at, :discontinue_on, :permalink, :meta_description,:meta_keywords, :meta_title, :sku, :deleted_at,:weight, :height, :width, :depth,- :shipping_category_id, :tax_category_id,+ :product_type_id, :tax_category_id,:cost_currency, :cost_price,:slug, :track_inventory, :backorderable, :barcode, :status,:weight_unit, :dimensions_unit,@@ -242,14 +241,13 @@ module Spree:tracking, :address, :inventory_units, :selected_shipping_rate_id]- @@shipping_category_attributes = [:name]-@@channel_attributes = [:name, :code, :active, :default, :preferred_order_routing_strategy,:preferred_storefront_access, :preferred_guest_checkout]- @@shipping_method_attributes = [:name, :admin_name, :code, :tracking_url, :tax_category_id, :display_on,+ @@shipping_method_attributes = [:name, :admin_name, :code, :tracking_url, :tax_category_id, :storefront_visible,+ :fulfillment_type, :fulfillment_provider,:estimated_transit_business_days_min, :estimated_transit_business_days_max,- :calculator_type, :preferences, zone_ids: [], shipping_category_ids: [], calculator_attributes: {}]+ :calculator_type, :preferences, delivery_zone_ids: [], calculator_attributes: {}]# month / year may be provided by some sources, or others may elect to use one field@@source_attributes = [diff --git a/spree/core/lib/spree/testing_support/factories/delivery_method_factory.rb b/spree/core/lib/spree/testing_support/factories/delivery_method_factory.rbindex 26b583f7fb..f673998735 100644--- a/spree/core/lib/spree/testing_support/factories/delivery_method_factory.rb+++ b/spree/core/lib/spree/testing_support/factories/delivery_method_factory.rb@@ -2,10 +2,9 @@ FactoryBot.define do# Delivery methods are worldwide by default — geographic restriction is# opt-in via an explicit :delivery_zone (empty zone list = no restriction).factory :base_delivery_method, aliases: [:base_shipping_method], class: Spree::DeliveryMethod do- name { 'UPS Ground' }- code { 'UPS_GROUND' }- display_on { 'both' }- store { Spree::Store.find_by(default: true) || association(:store) }+ name { 'UPS Ground' }+ code { 'UPS_GROUND' }+ store { Spree::Store.find_by(default: true) || association(:store) }factory :delivery_method, aliases: [:shipping_method], class: Spree::DeliveryMethod doassociation(:calculator, factory: :shipping_calculator, strategy: :build)diff --git a/spree/core/lib/spree/testing_support/factories/order_factory.rb b/spree/core/lib/spree/testing_support/factories/order_factory.rbindex bd96b18e55..74f44854d3 100644--- a/spree/core/lib/spree/testing_support/factories/order_factory.rb+++ b/spree/core/lib/spree/testing_support/factories/order_factory.rb@@ -62,7 +62,7 @@ FactoryBot.define doline_items_count { 1 }without_line_items { false }shipment_cost { 100 }- shipping_method_filter { Spree::ShippingMethod::DISPLAY_ON_FRONT_END }+ shipping_method_filter { Spree::DeliveryMethod::STOREFRONT }variants { [] }enddiff --git a/spree/core/lib/spree/testing_support/factories/product_factory.rb b/spree/core/lib/spree/testing_support/factories/product_factory.rbindex ed0e83458b..db9e966390 100644--- a/spree/core/lib/spree/testing_support/factories/product_factory.rb+++ b/spree/core/lib/spree/testing_support/factories/product_factory.rb@@ -7,7 +7,6 @@ FactoryBot.define do# convenience attributes.factory :empty_product, class: Spree::Product dosequence(:name) { |n| "Empty Product #{n}#{Kernel.rand(9999)}" }- shipping_category { |r| Spree::ShippingCategory.first || r.association(:shipping_category) }status { 'active' }store { Spree::Store.default || association(:store) }@@ -32,7 +31,6 @@ FactoryBot.define docost_price { 17.00 }sku { generate(:sku) }deleted_at { nil }- shipping_category { |r| Spree::ShippingCategory.first || r.association(:shipping_category) }status { 'active' }store { Spree::Store.default || association(:store) }diff --git a/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml b/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.ymlindex 985d7fb318..73e1d743d0 100644--- a/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml+++ b/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml@@ -94,6 +94,13 @@ steps:digital-only shipping categories, and converts display_on into thestorefront_visible boolean. Idempotent.+ BREAKING — product CSV: the 'shipping_category' column is gone from both+ import and export, replaced by 'product_type'. Update saved import+ templates and any integration reading the export. A stale file is+ ignored rather than rejected, so it imports without delivery+ eligibility. This task assigns types to existing digital products;+ new imports must carry 'product_type' themselves.+- id: migrate_zones_to_delivery_zonesname: "Convert delivery zones"task: "spree:migrate_zones_to_delivery_zones"diff --git a/spree/core/lib/tasks/delivery_migration.rake b/spree/core/lib/tasks/delivery_migration.rakeindex 9a8e49fba3..9bcd85c025 100644--- a/spree/core/lib/tasks/delivery_migration.rake+++ b/spree/core/lib/tasks/delivery_migration.rake@@ -86,9 +86,24 @@ namespace :spree doendend- # 5. display_on → storefront_visible boolean.- Spree::DeliveryMethod.unscoped.where(storefront_visible: nil).where(display_on: 'back_end').update_all(storefront_visible: false)- Spree::DeliveryMethod.unscoped.where(storefront_visible: nil).update_all(storefront_visible: true)+ # 5. display_on → storefront_visible boolean. The new column defaults to+ # true, so only back_end rows need flipping. Narrowing on the legacy+ # display_on column keeps re-runs safe: nothing writes display_on after+ # the upgrade, so a later admin change to storefront_visible stands.+ if Spree::DeliveryMethod.column_names.include?('display_on')+ count = Spree::DeliveryMethod.unscoped.+ where(display_on: 'back_end', storefront_visible: true).+ update_all(storefront_visible: false)+ say.call "spree_delivery_methods.storefront_visible: #{count} back_end rows set to false"++ # front_end-only had no real workflow and folds into visible — but it+ # also means staff can now see those methods, so name them explicitly.+ front_end_only = Spree::DeliveryMethod.unscoped.where(display_on: 'front_end').pluck(:id, :name)+ if front_end_only.any?+ say.call "spree_delivery_methods: #{front_end_only.size} front_end-only rows are now visible to staff as well as customers:"+ front_end_only.each { |id, name| say.call " - ##{id} #{name}" }+ end+ endsay.call 'migrate_shipping_to_delivery done.'enddiff --git a/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rb b/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rbindex 3e9fa6fd43..932abe7707 100644--- a/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rb+++ b/spree/core/spec/lib/tasks/six_zero_data_migrations_spec.rb@@ -51,7 +51,9 @@ describe '6.0 data migration tasks' dodigital_method = create(:shipping_method)digital_method.calculator.destroy!Spree::Calculator::Shipping::DigitalDelivery.create!(calculable: digital_method)- digital_method.update_columns(fulfillment_type: nil, fulfillment_provider: nil, storefront_visible: nil, display_on: 'back_end')+ # A 5.x row as it arrives post-migration: storefront_visible at the+ # column default, display_on still holding the real value.+ digital_method.update_columns(fulfillment_type: nil, fulfillment_provider: nil, storefront_visible: true, display_on: 'back_end')run_task('spree:migrate_shipping_to_delivery')diff --git a/spree/core/spec/models/spree/cart_spec.rb b/spree/core/spec/models/spree/cart_spec.rbindex bd8bf15b2e..fa55beb959 100644--- a/spree/core/spec/models/spree/cart_spec.rb+++ b/spree/core/spec/models/spree/cart_spec.rb@@ -360,14 +360,14 @@ describe Spree::Cart, type: :model doendend- describe '#ensure_available_shipping_rates' do+ describe '#ensure_available_delivery_rates' doit 'errors when there are no deliverable proposals' do- expect(cart.ensure_available_shipping_rates).to be(false)+ expect(cart.ensure_available_delivery_rates).to be(false)expect(cart.errors[:base]).to be_presentcart.errors.clearcart.rebuild_fulfillments!- expect(cart.ensure_available_shipping_rates).to be(true)+ expect(cart.ensure_available_delivery_rates).to be(true)endenddiff --git a/spree/core/spec/models/spree/concerns/display_on_spec.rb b/spree/core/spec/models/spree/concerns/display_on_spec.rbindex 250c9cfbae..bc9c506992 100644--- a/spree/core/spec/models/spree/concerns/display_on_spec.rb+++ b/spree/core/spec/models/spree/concerns/display_on_spec.rb@@ -3,9 +3,9 @@require 'spec_helper'RSpec.describe Spree::DisplayOn do- # PaymentMethod is the simplest factory-backed host; ShippingMethod- # and MetafieldDefinition include the concern identically and inherit- # this behaviour.+ # PaymentMethod and MetafieldDefinition are the remaining hosts and+ # include the concern identically. DeliveryMethod moved off it in 6.0 —+ # it owns a real storefront_visible column.let(:payment_method) { build(:check_payment_method) }describe '#storefront_visible' dodiff --git a/spree/core/spec/models/spree/delivery_method_spec.rb b/spree/core/spec/models/spree/delivery_method_spec.rbindex 3f0e919fc9..acd131dcbb 100644--- a/spree/core/spec/models/spree/delivery_method_spec.rb+++ b/spree/core/spec/models/spree/delivery_method_spec.rb@@ -5,33 +5,25 @@ enddescribe Spree::DeliveryMethod, type: :model dolet(:delivery_method) { create(:delivery_method) }- let(:frontend_delivery_method) { create :delivery_method, display_on: 'front_end' }- let(:backend_delivery_method) { create :delivery_method, display_on: 'back_end' }- let(:front_and_back_end_delivery_method) { create :delivery_method, display_on: 'both' }+ let(:visible_delivery_method) { create :delivery_method, storefront_visible: true }+ let(:admin_only_delivery_method) { create :delivery_method, storefront_visible: false }it_behaves_like 'metadata'describe 'scopes' do- let!(:delivery_methods) { create_list(:delivery_method, 2, display_on: 'both') }- let!(:frontend_delivery_methods) { create_list(:delivery_method, 2, display_on: 'front_end') }- let!(:backend_delivery_methods) { create_list(:delivery_method, 2, display_on: 'back_end') }+ let!(:visible_delivery_methods) { create_list(:delivery_method, 2, storefront_visible: true) }+ let!(:admin_only_delivery_methods) { create_list(:delivery_method, 2, storefront_visible: false) }- describe '.available' do- subject { described_class.available }+ describe '.storefront_visible' do+ subject { described_class.storefront_visible }- it { is_expected.to match_array(delivery_methods) }+ it { is_expected.to match_array(visible_delivery_methods) }end- describe '.available_on_front_end' do- subject { described_class.available_on_front_end }+ describe '.admin_only' do+ subject { described_class.admin_only }- it { is_expected.to match_array(delivery_methods + frontend_delivery_methods) }- end-- describe '.available_on_back_end' do- subject { described_class.available_on_back_end }-- it { is_expected.to match_array(delivery_methods + backend_delivery_methods) }+ it { is_expected.to match_array(admin_only_delivery_methods) }endend@@ -164,12 +156,12 @@ describe Spree::DeliveryMethod, type: :model doexpect(method.save).to be trueend- it 'defaults display_on and rejects explicit blank' do- expect(subject.display_on).to eq('both')+ it 'defaults to storefront visible and rejects a blank value' do+ expect(subject.storefront_visible).to be true- subject.display_on = nil+ subject.storefront_visible = nilsubject.valid?- expect(subject.errors.messages[:display_on].size).not_to be_zero+ expect(subject.errors.messages[:storefront_visible].size).not_to be_zeroendcontext 'shipping method does not have a tracking URL mask on file' do@@ -193,30 +185,43 @@ describe Spree::DeliveryMethod, type: :model doendend- describe '#available_to_display?' do- context 'when available on frontend' do- it { expect(frontend_delivery_method.available_to_display?(described_class::DISPLAY_ON_FRONT_END)).to be true }- it { expect(backend_delivery_method.available_to_display?(described_class::DISPLAY_ON_FRONT_END)).to be false }- it { expect(front_and_back_end_delivery_method.available_to_display?(described_class::DISPLAY_ON_FRONT_END)).to be true }+ describe '#available_to?' do+ context 'for the storefront' do+ it { expect(visible_delivery_method.available_to?(described_class::STOREFRONT)).to be true }+ it { expect(admin_only_delivery_method.available_to?(described_class::STOREFRONT)).to be false }end- context 'when available on backend' do- it { expect(frontend_delivery_method.available_to_display?(described_class::DISPLAY_ON_BACK_END)).to be false }- it { expect(backend_delivery_method.available_to_display?(described_class::DISPLAY_ON_BACK_END)).to be true }- it { expect(front_and_back_end_delivery_method.available_to_display?(described_class::DISPLAY_ON_BACK_END)).to be true }+ context 'for the backoffice' do+ it 'sees every method, visible or not' do+ expect(visible_delivery_method.available_to?(described_class::BACKOFFICE)).to be true+ expect(admin_only_delivery_method.available_to?(described_class::BACKOFFICE)).to be true+ endend- end- describe '#frontend?' do- it { expect(frontend_delivery_method.send(:frontend?)).to be true }- it { expect(backend_delivery_method.send(:frontend?)).to be false }- it { expect(front_and_back_end_delivery_method.send(:frontend?)).to be true }+ it 'raises on an unknown audience rather than silently narrowing the offer' do+ expect { delivery_method.available_to?(:back_office) }.to raise_error(ArgumentError, /unknown delivery audience/)+ endend- describe '#backend?' do- it { expect(frontend_delivery_method.send(:backend?)).to be false }- it { expect(backend_delivery_method.send(:backend?)).to be true }- it { expect(front_and_back_end_delivery_method.send(:backend?)).to be true }+ describe 'legacy display_on bridge' do+ before { allow(Spree::Deprecation).to receive(:warn) }++ it 'bridges the old tri-state API onto the boolean' do+ expect(visible_delivery_method.display_on).to eq('both')+ expect(admin_only_delivery_method.display_on).to eq('back_end')++ method = build(:delivery_method, display_on: 'back_end')+ expect(method.storefront_visible).to be false++ # front_end-only had no real workflow and folds into visible.+ method.display_on = 'front_end'+ expect(method.storefront_visible).to be true+ end++ it 'accepts the legacy integer filters in #available_to_display?' do+ expect(admin_only_delivery_method.available_to_display?(described_class::DISPLAY_ON_FRONT_END)).to be false+ expect(admin_only_delivery_method.available_to_display?(described_class::DISPLAY_ON_BACK_END)).to be true+ endenddescribe '#delivery_range' dodiff --git a/spree/core/spec/models/spree/exports/products_spec.rb b/spree/core/spec/models/spree/exports/products_spec.rbindex f134a63b8b..0e174c6234 100644--- a/spree/core/spec/models/spree/exports/products_spec.rb+++ b/spree/core/spec/models/spree/exports/products_spec.rb@@ -56,7 +56,7 @@ RSpec.describe Spree::Exports::Products, type: :model do'inventory_count','inventory_backorderable','tax_category',- 'shipping_category',+ 'product_type','image1_src','image2_src','image3_src',@@ -106,7 +106,7 @@ RSpec.describe Spree::Exports::Products, type: :model do'inventory_count','inventory_backorderable','tax_category',- 'shipping_category',+ 'product_type','image1_src','image2_src','image3_src',diff --git a/spree/core/spec/models/spree/line_item_spec.rb b/spree/core/spec/models/spree/line_item_spec.rbindex 84b63b56f8..da130bbdca 100644--- a/spree/core/spec/models/spree/line_item_spec.rb+++ b/spree/core/spec/models/spree/line_item_spec.rb@@ -586,33 +586,33 @@ describe Spree::LineItem, type: :model doendend- describe '#shipping_cost' do+ describe '#delivery_cost' dolet(:line_item) { create(:line_item) }let(:inventory_unit) { create(:inventory_unit, line_item: line_item) }let(:shipment) { create(:shipment, inventory_units: [inventory_unit], cost: 10) }it 'returns the shipping cost for the line item' doshipment- expect(line_item.shipping_cost).to eq(10)+ expect(line_item.delivery_cost).to eq(10)endcontext 'when the shipment is canceled' doit 'returns 0' doshipment.cancel!- expect(line_item.shipping_cost).to eq(0)+ expect(line_item.delivery_cost).to eq(0)endendcontext 'when the shipment is not present' doit 'returns 0' do- expect(line_item.shipping_cost).to eq(0)+ expect(line_item.delivery_cost).to eq(0)endendcontext 'when the shipment cost is 0' doit 'returns 0' doshipment.update(cost: 0)- expect(line_item.shipping_cost).to eq(0)+ expect(line_item.delivery_cost).to eq(0)endendenddiff --git a/spree/core/spec/models/spree/order/adjustments_spec.rb b/spree/core/spec/models/spree/order/adjustments_spec.rbindex c16cbcaa27..a04ac3974d 100644--- a/spree/core/spec/models/spree/order/adjustments_spec.rb+++ b/spree/core/spec/models/spree/order/adjustments_spec.rb@@ -58,7 +58,7 @@ describe Spree::Order doorder.line_items << line_itemorder.ship_address = addressorder.rebuild_fulfillments!- order.send :ensure_available_shipping_rates+ order.send :ensure_available_delivery_ratesorder.set_fulfillments_costorder.create_shipment_tax_charge!enddiff --git a/spree/core/spec/models/spree/order_spec.rb b/spree/core/spec/models/spree/order_spec.rbindex dc20954861..117b48cc77 100644--- a/spree/core/spec/models/spree/order_spec.rb+++ b/spree/core/spec/models/spree/order_spec.rb@@ -1141,7 +1141,7 @@ describe Spree::Order, type: :model doit 'assigns the routing strategy returned packages, mapped to shipments' dopackage = instance_double(Spree::Stock::Package)shipment = build(:shipment)- allow(package).to receive(:to_shipment).and_return(shipment)+ allow(package).to receive(:to_fulfillment).and_return(shipment)strategy = instance_double(Spree::OrderRouting::Strategy::Rules)allow(strategy).to receive(:for_allocation).and_return([package])@@ -2138,8 +2138,8 @@ describe Spree::Order, type: :model doendend- describe '#ensure_available_shipping_rates' do- subject { order.send(:ensure_available_shipping_rates) }+ describe '#ensure_available_delivery_rates' do+ subject { order.send(:ensure_available_delivery_rates) }let(:order) { create(:order_with_line_items) }let(:line_item) { order.line_items.first }diff --git a/spree/core/spec/models/spree/order_updater_spec.rb b/spree/core/spec/models/spree/order_updater_spec.rbindex 999e43b48c..58a584c1b6 100644--- a/spree/core/spec/models/spree/order_updater_spec.rb+++ b/spree/core/spec/models/spree/order_updater_spec.rb@@ -214,8 +214,8 @@ module Spreeshared_context 'with original shipping method gone backend only' dobefore do- order.fulfillments.first.delivery_method.update(display_on: :back_end)- create(:shipping_method) # create frontend available shipping method+ order.fulfillments.first.delivery_method.update(storefront_visible: false)+ create(:shipping_method) # create a storefront-visible shipping methodendend@@ -300,9 +300,9 @@ module Spreeinclude_context 'with original shipping method gone backend only'let(:order) { create(:cart_ready_for_delivery, store: @default_store) }- it 'resets shipping method to frontend-available' do+ it 'resets shipping method to a storefront-visible one' doSpree::OrderUpdater.new(order).update_shipments- expect(order.fulfillments.first.delivery_method).to eq Spree::ShippingMethod.find_by(display_on: 'both')+ expect(order.fulfillments.first.delivery_method).to eq Spree::DeliveryMethod.find_by(storefront_visible: true)endendenddiff --git a/spree/core/spec/models/spree/product_spec.rb b/spree/core/spec/models/spree/product_spec.rbindex d857e53eb4..ed6e280971 100644--- a/spree/core/spec/models/spree/product_spec.rb+++ b/spree/core/spec/models/spree/product_spec.rb@@ -35,15 +35,15 @@ describe Spree::Product, type: :model doendend- describe 'shipping category' do- # ShippingCategory is retired from behavior in 6.0 (delivery eligibility- # comes from ProductType#fulfillment_types); the association is optional- # until the 6.1 column drop.- it 'is not required' do- product = build(:product, shipping_category: nil)+ describe 'delivery eligibility' do+ # ShippingCategory is retired from behavior in 6.0 — eligibility comes+ # from ProductType#fulfillment_types, and a typeless product still ships.+ it 'comes from the product type, defaulting to physical shipping' do+ expect(build(:product, product_type: nil).fulfillment_types).to eq ['shipping']- expect(product).to be_valid- expect(product.shipping_category).to be_nil+ digital = build(:product, product_type: build(:product_type, fulfillment_types: ['digital']))+ expect(digital.fulfillment_types).to eq ['digital']+ expect(digital).to be_digitalendend@@ -409,7 +409,7 @@ describe Spree::Product, type: :model dodescribe '#create' dolet!(:product_type) { create(:product_type) }let!(:product) do- build(:product, name: 'Foo', price: 1.99, shipping_category: create(:shipping_category), product_type: product_type)+ build(:product, name: 'Foo', price: 1.99, product_type: product_type)endcontext 'when a product type with option types is supplied' do@@ -1893,7 +1893,6 @@ describe Spree::Product, type: :model dodescribe '#variants=' dolet(:product) { create(:product) }- let(:shipping_category) { product.shipping_category }context 'with hash params' doit 'creates new variants' do@@ -1926,7 +1925,6 @@ describe Spree::Product, type: :model doit 'defers creation on new records' donew_product = Spree::Product.new(name: 'Deferred',- shipping_category: shipping_category,store: store,variants: [{ sku: 'DEF-1', options: [{ name: 'Color', value: 'Red' }] }])@@ -1942,7 +1940,6 @@ describe Spree::Product, type: :model do# with options:[] and the backend creates exactly that one variant.new_product = Spree::Product.new(name: 'Simple SKU',- shipping_category: shipping_category,store: store,variants: [{ sku: 'SIMPLE-1', weight: 2, options: [] }])@@ -1970,7 +1967,6 @@ describe Spree::Product, type: :model doit 'reflects new option-bearing variants in variant_count and default_variant' donew_product = Spree::Product.new(name: 'Fresh Variants',- shipping_category: shipping_category,store: store,variants: [{ sku: 'FV-1', prices: [{ amount: 10, currency: 'USD' }], options: [{ name: 'Size', value: 'S' }] },@@ -1987,7 +1983,6 @@ describe Spree::Product, type: :model doit 'reflects an options-less default variant in default_variant and price' donew_product = Spree::Product.new(name: 'Fresh Simple',- shipping_category: shipping_category,store: store,variants: [{ sku: 'FS-1', prices: [{ amount: 15, currency: 'USD' }], options: [] }])@@ -2083,7 +2078,6 @@ describe Spree::Product, type: :model doit 'defers attachment until after the product is saved' donew_product = Spree::Product.new(name: 'Deferred Media',- shipping_category: create(:shipping_category),store: store,media: [{ signed_id: blob.signed_id, alt: 'Pending', position: 1 }])@@ -2124,7 +2118,6 @@ describe Spree::Product, type: :model doit 'does not overwrite explicit tax_category_id' doproduct = Spree::Product.new(name: 'Test',- shipping_category: create(:shipping_category),store: store,tax_category_id: custom_tc.id)@@ -2136,7 +2129,6 @@ describe Spree::Product, type: :model doit 'assigns default when tax_category_id is not provided' doproduct = Spree::Product.new(name: 'Test',- shipping_category: create(:shipping_category),store: store)diff --git a/spree/core/spec/models/spree/report_line_items/sales_total_spec.rb b/spree/core/spec/models/spree/report_line_items/sales_total_spec.rbindex 0a95f4a4f4..940ecd8b94 100644--- a/spree/core/spec/models/spree/report_line_items/sales_total_spec.rb+++ b/spree/core/spec/models/spree/report_line_items/sales_total_spec.rb@@ -31,7 +31,7 @@ RSpec.describe Spree::ReportLineItems::SalesTotal dodescribe '#total' doit 'returns money object with final amount plus shipping' do- total = Spree::Money.new(line_item.final_amount + line_item.shipping_cost, currency: line_item.currency)+ total = Spree::Money.new(line_item.final_amount + line_item.delivery_cost, currency: line_item.currency)expect(sales_total.total).to eq(total)endend@@ -50,7 +50,7 @@ RSpec.describe Spree::ReportLineItems::SalesTotal dodescribe '#shipment_total' doit 'returns display shipping cost' do- expect(sales_total.shipment_total).to eq(line_item.display_shipping_cost)+ expect(sales_total.shipment_total).to eq(line_item.display_delivery_cost)endenddiff --git a/spree/core/spec/models/spree/reports/sales_total_spec.rb b/spree/core/spec/models/spree/reports/sales_total_spec.rbindex a4fb7adc73..ed25ffce60 100644--- a/spree/core/spec/models/spree/reports/sales_total_spec.rb+++ b/spree/core/spec/models/spree/reports/sales_total_spec.rb@@ -97,7 +97,7 @@ RSpec.describe Spree::Reports::SalesTotal doexpect(return_line_item.tax_total).to eq(line_item.display_tax_total)expect(return_line_item.promo_total).to eq(line_item.display_promo_total)expect(return_line_item.pre_tax_amount).to eq(line_item.display_pre_tax_amount)- expect(return_line_item.shipment_total).to eq(line_item.display_shipping_cost)+ expect(return_line_item.shipment_total).to eq(line_item.display_delivery_cost)endendenddiff --git a/spree/core/spec/models/spree/shipment_spec.rb b/spree/core/spec/models/spree/shipment_spec.rbindex a92924c99e..b696470adc 100644--- a/spree/core/spec/models/spree/shipment_spec.rb+++ b/spree/core/spec/models/spree/shipment_spec.rb@@ -482,7 +482,7 @@ describe Spree::Shipment, type: :model doendcontext 'refresh_rates' do- let(:mock_estimator) { double('estimator', shipping_rates: shipping_rates) }+ let(:mock_estimator) { double('estimator', delivery_rates: shipping_rates) }before { allow(shipment).to receive(:can_get_rates?).and_return(true) }diff --git a/spree/core/spec/models/spree/stock/estimator_spec.rb b/spree/core/spec/models/spree/stock/estimator_spec.rbindex cd5e30db8c..529fc164d7 100644--- a/spree/core/spec/models/spree/stock/estimator_spec.rb+++ b/spree/core/spec/models/spree/stock/estimator_spec.rb@@ -25,15 +25,15 @@ module Spreeshared_examples_for 'shipping rate matches' doit 'returns shipping rates' do- shipping_rates = subject.shipping_rates(package)- expect(shipping_rates.first.cost).to eq 4.00+ delivery_rates = subject.delivery_rates(package)+ expect(delivery_rates.first.cost).to eq 4.00endendshared_examples_for "shipping rate doesn't match" doit 'does not return shipping rates' do- shipping_rates = subject.shipping_rates(package)- expect(shipping_rates).to eq([])+ delivery_rates = subject.delivery_rates(package)+ expect(delivery_rates).to eq([])endend@@ -110,9 +110,9 @@ module Spreeallow(shipping_methods[1]).to receive_message_chain(:calculator, :compute).and_return(3.00)allow(shipping_methods[2]).to receive_message_chain(:calculator, :compute).and_return(4.00)- allow(subject).to receive(:shipping_methods).and_return(shipping_methods)+ allow(subject).to receive(:delivery_methods).and_return(shipping_methods)- expect(subject.shipping_rates(package).map(&:cost)).to eq [3.00, 4.00, 5.00]+ expect(subject.delivery_rates(package).map(&:cost)).to eq [3.00, 4.00, 5.00]endcontext 'general shipping methods' do@@ -122,23 +122,23 @@ module Spreeallow(shipping_methods[0]).to receive_message_chain(:calculator, :compute).and_return(5.00)allow(shipping_methods[1]).to receive_message_chain(:calculator, :compute).and_return(3.00)- allow(subject).to receive(:shipping_methods).and_return(shipping_methods)+ allow(subject).to receive(:delivery_methods).and_return(shipping_methods)- expect(subject.shipping_rates(package).sort_by(&:cost).map(&:selected)).to eq [true, false]+ expect(subject.delivery_rates(package).sort_by(&:cost).map(&:selected)).to eq [true, false]endit "selects the most affordable shipping rate and doesn't raise exception over nil cost" doallow(shipping_methods[0]).to receive_message_chain(:calculator, :compute).and_return(1.00)allow(shipping_methods[1]).to receive_message_chain(:calculator, :compute).and_return(nil)- allow(subject).to receive(:shipping_methods).and_return(shipping_methods)+ allow(subject).to receive(:delivery_methods).and_return(shipping_methods)- subject.shipping_rates(package)+ subject.delivery_rates(package)endendcontext 'involves backend only shipping methods' do- let(:backend_method) { create(:shipping_method, display_on: 'back_end') }+ let(:backend_method) { create(:shipping_method, storefront_visible: false) }let(:generic_method) { create(:shipping_method) }before do@@ -148,12 +148,12 @@ module Spreeendit 'does not return backend rates at all' do- expect(subject.shipping_rates(package).map(&:shipping_method_id)).to eq([generic_method.id])+ expect(subject.delivery_rates(package).map(&:shipping_method_id)).to eq([generic_method.id])end# regression for #3287it "doesn't select backend rates even if they're more affordable" do- expect(subject.shipping_rates(package).map(&:selected)).to eq [true]+ expect(subject.delivery_rates(package).map(&:selected)).to eq [true]endend@@ -174,8 +174,8 @@ module Spreeendit 'links the shipping rate and the tax rate' do- shipping_rates = subject.shipping_rates(package)- expect(shipping_rates.first.tax_rate).to eq(tax_rate)+ delivery_rates = subject.delivery_rates(package)+ expect(delivery_rates.first.tax_rate).to eq(tax_rate)endend@@ -210,9 +210,9 @@ module Spreebefore { allow(order).to receive(:tax_zone).and_return(zone_without_vat) }it 'deducts the default VAT from the cost' do- shipping_rates = subject.shipping_rates(package)+ delivery_rates = subject.delivery_rates(package)# deduct default vat: 4.00 / 1.2 = 3.33 (rounded)- expect(shipping_rates.first.cost).to eq(3.33)+ expect(delivery_rates.first.cost).to eq(3.33)endend@@ -229,11 +229,11 @@ module Spreebefore { allow(order).to receive(:tax_zone).and_return(other_vat_zone) }it 'deducts the default vat and applies the foreign vat to calculate the price' do- shipping_rates = subject.shipping_rates(package)+ delivery_rates = subject.delivery_rates(package)## deduct default vat: 4.00 / 1.2 = 3.33 (rounded)# apply foreign vat: 3.33 * 1.3 = 4.33 (rounded)- expect(shipping_rates.first.cost).to eq(4.33)+ expect(delivery_rates.first.cost).to eq(4.33)endendenddiff --git a/spree/core/spec/models/spree/stock/package_spec.rb b/spree/core/spec/models/spree/stock/package_spec.rbindex 0f73d17122..82e6c070df 100644--- a/spree/core/spec/models/spree/stock/package_spec.rb+++ b/spree/core/spec/models/spree/stock/package_spec.rb@@ -98,9 +98,9 @@ module Spreesubject.add build_inventory_unit, :backorderedshipping_method = build(:shipping_method)- subject.shipping_rates = [Spree::DeliveryRate.new(delivery_method: shipping_method, cost: 10.00, selected: true)]+ subject.delivery_rates = [Spree::DeliveryRate.new(delivery_method: shipping_method, cost: 10.00, selected: true)]- shipment = subject.to_shipment+ shipment = subject.to_fulfillmentexpect(shipment.stock_location).to eq subject.stock_locationexpect(shipment.fulfillment_items.size).to eq 3diff --git a/spree/core/spec/models/spree/variant_spec.rb b/spree/core/spec/models/spree/variant_spec.rbindex cd27c3d8a1..c2aed7d452 100644--- a/spree/core/spec/models/spree/variant_spec.rb+++ b/spree/core/spec/models/spree/variant_spec.rb@@ -1553,4 +1553,24 @@ describe Spree::Variant, type: :model doexpect(v.instance_variable_get(:@pending_options)).to eq([{ name: 'Color', value: 'Blue' }])endend++ describe 'legacy shipping category bridge' do+ let(:shipping_category) { create(:shipping_category, name: 'Legacy') }+ let(:variant) { create(:variant) }++ before do+ variant.product.update_column(:shipping_category_id, shipping_category.id)+ variant.product.reload+ end++ it 'still reads through to the product, with a deprecation warning' do+ expect(Spree::Deprecation).to receive(:warn).at_least(:once)+ expect(variant.shipping_category).to eq shipping_category+ end++ it 'still reads the id through to the product, with a deprecation warning' do+ expect(Spree::Deprecation).to receive(:warn).at_least(:once)+ expect(variant.shipping_category_id).to eq shipping_category.id+ end+ endenddiff --git a/spree/core/spec/presenters/spree/csv/product_variant_presenter_spec.rb b/spree/core/spec/presenters/spree/csv/product_variant_presenter_spec.rbindex 5a012aa498..c08db703e6 100644--- a/spree/core/spec/presenters/spree/csv/product_variant_presenter_spec.rb+++ b/spree/core/spec/presenters/spree/csv/product_variant_presenter_spec.rb@@ -45,7 +45,7 @@ RSpec.describe Spree::CSV::ProductVariantPresenter doexpect(subject[24]).to eq(variant.total_on_hand == BigDecimal::INFINITY ? '∞' : variant.total_on_hand)expect(subject[25]).to eq variant.backorderable?expect(subject[26]).to eq variant.tax_category&.name- expect(subject[27]).to eq product.shipping_category&.name+ expect(subject[27]).to eq product.product_type&.nameexpect(subject[28]).to end_with(variant.images[0].filename.to_s)expect(subject[29]).to end_with(variant.images[1].filename.to_s)expect(subject[30]).to end_with(variant.images[2].filename.to_s)@@ -205,24 +205,23 @@ RSpec.describe Spree::CSV::ProductVariantPresenter doendend- describe 'shipping_category' do- context 'when product has shipping category' do- let(:shipping_category) { create(:shipping_category, name: 'Digital') }- let(:product) { create(:product, shipping_category: shipping_category) }+ describe 'product_type' do+ context 'when the product has a product type' do+ let(:product_type) { create(:product_type, name: 'Digital', fulfillment_types: ['digital']) }+ let(:product) { create(:product, product_type: product_type) }- it 'exports shipping category name' do+ it 'exports the product type name' doresult = presenter.callexpect(result[27]).to eq 'Digital'endend- context 'when product has no shipping category explicitly set' do+ context 'when the product has no product type' dolet(:product) { create(:product) }- it 'exports the assigned shipping category' do+ it 'exports a blank column' doresult = presenter.call- expect(result[27]).to be_present- expect(result[27]).to eq product.shipping_category.name+ expect(result[27]).to be_nilendendenddiff --git a/spree/core/spec/services/spree/imports/row_processors/product_variant_spec.rb b/spree/core/spec/services/spree/imports/row_processors/product_variant_spec.rbindex 1113c9afe4..8db3f5bd1e 100644--- a/spree/core/spec/services/spree/imports/row_processors/product_variant_spec.rb+++ b/spree/core/spec/services/spree/imports/row_processors/product_variant_spec.rb@@ -12,8 +12,8 @@ RSpec.describe Spree::Imports::RowProcessors::ProductVariant, type: :service dobefore doimport.create_mappings# Manually map fields since there's no CSV file attached- import.mappings.find_by(schema_field: 'shipping_category')&.update(file_column: 'shipping_category')import.mappings.find_by(schema_field: 'tax_category')&.update(file_column: 'tax_category')+ import.mappings.find_by(schema_field: 'product_type')&.update(file_column: 'product_type')end# Matches how our production import will pass attributes@@ -797,11 +797,11 @@ RSpec.describe Spree::Imports::RowProcessors::ProductVariant, type: :service doendend- context 'when importing with shipping_category' do+ context 'when importing with product_type' dolet(:product) { subject.process! }- context 'when shipping_category exists' do- let!(:digital_category) { create(:shipping_category, name: 'Digital') }+ context 'when the product type exists' do+ let!(:digital_type) { create(:product_type, name: 'Digital', store: store, fulfillment_types: ['digital']) }let(:row_data) docsv_row_hash(@@ -810,37 +810,40 @@ RSpec.describe Spree::Imports::RowProcessors::ProductVariant, type: :service do'status' => 'active','price' => '29.99','currency' => 'USD',- 'shipping_category' => 'Digital'+ 'product_type' => 'Digital')end- it 'assigns the shipping category to the product' do- expect(product.shipping_category).to eq digital_category+ it 'assigns it and inherits its fulfillment types' do+ expect(product.product_type).to eq digital_type+ expect(product.fulfillment_types).to eq ['digital']endend- context 'when shipping_category does not exist' do+ context 'when the product type does not exist' dolet(:row_data) docsv_row_hash(- 'slug' => 'digital-product',- 'name' => 'Digital Product',+ 'slug' => 'new-type-product',+ 'name' => 'New Type Product','status' => 'active','price' => '29.99','currency' => 'USD',- 'shipping_category' => 'NonExistent'+ 'product_type' => 'Apparel')end- it 'leaves the shipping category unset' do- expect(product.shipping_category).to be_nil+ it 'creates it in the store, defaulting to physical shipping' do+ expect(product.product_type.name).to eq 'Apparel'+ expect(product.product_type.store).to eq store+ expect(product.fulfillment_types).to eq ['shipping']endend- context 'when updating product with different shipping_category' do- let!(:standard_category) { create(:shipping_category, name: 'Standard') }- let!(:digital_category) { create(:shipping_category, name: 'Digital') }+ context 'when updating a product with a different product_type' do+ let!(:apparel_type) { create(:product_type, name: 'Apparel', store: store) }+ let!(:digital_type) { create(:product_type, name: 'Digital', store: store, fulfillment_types: ['digital']) }let!(:existing_product) do- create(:product, slug: 'product-to-update', name: 'Product', store: store, shipping_category: standard_category)+ create(:product, slug: 'product-to-update', name: 'Product', store: store, product_type: apparel_type)endlet(:row_data) do@@ -850,20 +853,20 @@ RSpec.describe Spree::Imports::RowProcessors::ProductVariant, type: :service do'status' => 'active','price' => '29.99','currency' => 'USD',- 'shipping_category' => 'Digital'+ 'product_type' => 'Digital')end- it 'updates the shipping category' do+ it 'updates the product type' doexpect(product.id).to eq existing_product.id- expect(product.shipping_category).to eq digital_category+ expect(product.product_type).to eq digital_typeendend- context 'when shipping_category is not provided' do+ context 'when product_type is not provided' dolet(:row_data) docsv_row_hash(- 'slug' => 'product-no-category',+ 'slug' => 'product-no-type','name' => 'Product','status' => 'active','price' => '29.99',@@ -871,8 +874,9 @@ RSpec.describe Spree::Imports::RowProcessors::ProductVariant, type: :service do)end- it 'leaves the shipping category unset' do- expect(product.shipping_category).to be_nil+ it 'leaves it unset and rides the physical shipping default' do+ expect(product.product_type).to be_nil+ expect(product.fulfillment_types).to eq ['shipping']endendenddiff --git a/spree/core/spec/services/spree/seeds/digital_delivery_spec.rb b/spree/core/spec/services/spree/seeds/digital_delivery_spec.rbindex b80548ca02..7ae9429d8c 100644--- a/spree/core/spec/services/spree/seeds/digital_delivery_spec.rb+++ b/spree/core/spec/services/spree/seeds/digital_delivery_spec.rb@@ -9,7 +9,7 @@ RSpec.describe Spree::Seeds::DigitalDelivery dodelivery_method = Spree::DeliveryMethod.find_by(name: Spree.t('digital.digital_delivery'))expect(delivery_method).to be_present- expect(delivery_method.display_on).to eq('both')+ expect(delivery_method.storefront_visible).to be trueexpect(delivery_method.fulfillment_type).to eq('digital')expect(delivery_method).to be_digitalexpect(delivery_method.calculator).to be_a(Spree::Calculator::Shipping::DigitalDelivery)@@ -19,7 +19,7 @@ RSpec.describe Spree::Seeds::DigitalDelivery dobefore doSpree::DeliveryMethod.create!(name: Spree.t('digital.digital_delivery'),- display_on: 'both',+ storefront_visible: true,fulfillment_type: 'digital',calculator: Spree::Calculator::Shipping::DigitalDelivery.create!)