wearepixel/laravel-cart
A Laravel shopping cart package for managing cart items, quantities, prices, and totals with flexible storage options. It provides a simple API for adding, updating, and removing items, making it easy to integrate into ecommerce checkout flows.
Architecture fit
CartDriver + CartManager with Session/Database/Redis/Null/Multi implementations). This is the right architectural move: cart state stops being an implicit session concern and becomes an explicit, swappable dependency. For anything beyond a single-node monolith this is the difference between "can't scale" and "can scale".Coupon / TaxRule / ShippingRate abstract classes are a meaningful domain-modelling upgrade. They formalise concepts that were previously ad-hoc CartCondition construction scattered across application code, and they convert down to CartCondition so the existing condition engine is preserved. Low architectural risk, high readability payoff.MultiDriver is the most strategically interesting addition — it implies read/write composition (e.g. Redis hot path + Database durability). The release notes do not describe its consistency semantics, which is a gap.Cart::fake() + CartFactory + assertion methods harness is genuinely valuable for a TPM: it means downstream teams write less bespoke test scaffolding against a package they don't own. It also raises coverage of the package's own contract.Integration feasibility
CartSession is removed and replaced by the driver system. Any direct instantiation, type-hint, extension, or container binding of CartSession breaks.Cart constructor signature changed (now takes a CartDriver). Container-resolved usage is fine; new Cart(...), factory overrides, or test doubles that construct it directly will break.config → cart-config. Deploy scripts using vendor:publish --tag=config will silently stop publishing the cart config — a silent failure mode, not a loud one.Technical risk
@mixin/@method PHPDoc is arguably more valuable day-to-day for IDE and static analysis in consuming apps.cart:debug is stated as non-production only; confirm the guard is environment-based and not something an operator can trivially flip.Key questions
CartSession removal, constructor injection, and the publish-tag rename?DatabaseDriver ship publishable migrations? What is the schema, and how are schema changes versioned going forward?MultiDriver read/write and fallback semantics — consistency model, failure behaviour when the primary is unavailable?Stack fit
SessionDriver preserves current behaviour with a config change; low-effort adoption.RedisDriver or DatabaseDriver removes the sticky-session constraint on carts. This is the primary reason to take the upgrade.HasCart and ShareCartWithInertia remove hand-rolled glue that most teams currently maintain themselves.HasCart trait is Livewire-aware with reactive properties, which is convenient but couples components to the package's reactivity model. Acceptable; flag it in code review.Migration path
CartSession references, direct Cart construction, custom container bindings, and vendor:publish --tag=config usage across repos and CI.config/.SessionDriver on day one to isolate the upgrade from the storage change.cart:install command scaffolds app/Cart/; use it as a reference rather than running it blind into an existing codebase with established conventions.Compatibility
Cart or mocks CartSession needs a coordinated change.CartDriver. That is the single largest unknown-effort item. Size it before committing to the upgrade.Sequencing recommendation
SessionDriver. Ship and observe.RedisDriver or DatabaseDriver behind config, with cart:debug verification in staging.Coupon/TaxRule/ShippingRate classes to replace bespoke condition construction, one concept at a time.Maintenance
Support
cart:install and the cart:make:* generators reduce onboarding friction and standardise structure — good for support load.cart:debug is a genuine operational aid for staging triage. Confirm its production guard.Scaling
RedisDriver gives low-latency shared state; DatabaseDriver gives durability and queryability at higher latency. MultiDriver potentially gives both, but its semantics are undocumented — do not design against it until clarified.applies_to on item conditions (limit a condition to the first N units) is a small feature with real correctness value for tiered promotions and per-unit tax.Failure modes
RedisDriver is the sole driver, cart operations fail hard. Decide the degradation story (fallback driver, graceful 503, or read-only cart) before switching.CartSession removal can break active carts. Mitigate with drain or an accepted one-time reset.MultiDriver divergence → unreachable or stale secondary producing inconsistent cart reads. Unknown risk until semantics are documented.Ramp-up
CartDriver.cart:debug. Without that, the knowledge sits with whoever did the migration.How can I help you explore Laravel packages today?