2.2 KiB
Upgrade Guide
v2.x to v3.0
Breaking changes
Constructor signature
Cart no longer accepts a raw session/database storage object as its first constructor argument. It now requires a CartDriver instance. If you were resolving Cart directly (not via the service container), update your instantiation:
Before:
new Cart($sessionStorage, $events, 'cart', $sessionKey, $config);
After:
use Wearepixel\Cart\Drivers\SessionDriver;
new Cart(new SessionDriver($session, $sessionKey), $events, 'cart', $config);
Applications that use the service container (the normal case) are unaffected - CartServiceProvider handles this automatically.
Publish tag renamed
The config publish tag changed from config to cart-config to avoid conflicts with other packages:
Before:
php artisan vendor:publish --provider="Wearepixel\Cart\CartServiceProvider" --tag=config
After:
php artisan vendor:publish --provider="Wearepixel\Cart\CartServiceProvider" --tag=cart-config
# or simply:
php artisan cart:install
CartSession removed
Wearepixel\Cart\CartSession has been removed. It is replaced by the driver system. If you extended or referenced CartSession directly, switch to the appropriate driver (SessionDriver, DatabaseDriver, etc.).
Non-breaking additions
The following are additive and require no changes to existing code:
- Storage drivers:
SessionDriver,DatabaseDriver,RedisDriver,NullDriver,MultiDriver- configure viaconfig/cart.php - CartManager: resolves drivers by name, accessible via
app('cart.manager') - First-class objects:
Coupon,TaxRule,ShippingRateabstract base classes - optional, existing rawCartConditionusage continues to work - Cart::fake(): returns a
CartFactorybacked by an in-memoryNullDriverfor testing - Assertion methods:
Cart::assertContains(),assertCount(),assertTotal(), etc. - HasCart trait: Livewire reactive cart state
- ShareCartWithInertia: static class for Inertia middleware integration
- Artisan generators:
cart:install,cart:make:coupon,cart:make:tax,cart:make:shipping,cart:make:driver,cart:debug