Back to Spree

Cart/Order Split

docs/plans/6.0-cart-order-split.md

5.4.21017 B
Original Source

Cart/Order Split

Status: Design finalized, implementation not started
Target: Spree 6.0
Depends on: API v3 conventions

Key Decisions (do not deviate without discussion)

  • Cart and Order become separate models
  • LineItem uses polymorphic owner (Cart or Order)
  • Copy-on-completion semantics: completing checkout copies cart items to order via cart.complete! (which calls Spree::Carts::Complete service object)
  • Order-level state machine removed; status is derived
  • No Spree::Order state column in new model

Migration Path

  • Remove legacy services in Spree::Cart namespace, they are blocking us from creating a Spree::Cart model, also they are mostly legacy and unused in API v3
  • Cart < ApplicationRecord (new)
  • Order keeps existing table, state column deprecated

Constraints on Current Work

  • Any new code touching line items should use the line_item.owner interface, not line_item.order directly
  • Don't add new order states — they won't survive the migration