Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Cart

Laravel Cart Laravel Package

joelwmale/laravel-cart

A simple shopping cart package for Laravel with support for multiple cart instances, quantities, prices, taxes, discounts, and persistent storage. Offers an easy API for adding, updating, and removing items, calculating totals, and managing carts across sessions.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Laravel Cart
How do I install joelwmale/laravel-cart in a Laravel 11 application?
Install it with Composer using composer require joelwmale/laravel-cart, then publish any config or migration files the package ships if you need to customise defaults. On Laravel 11 and 12 the service provider is discovered automatically, so no manual registration is required. Confirm your PHP version is 8.3 or higher before running the install, because Composer will block it otherwise.
Does laravel-cart support multiple separate carts in one application?
Yes. The package is built around multiple named cart instances, so you can keep a buyer's cart, a wishlist, or per-vendor carts separate instead of overloading a single session key. Each instance tracks its own items, quantities, prices, taxes, and discounts, and totals are calculated per instance. Use a stable naming convention so you can retrieve the same instance on later requests.
What Laravel and PHP versions does laravel-cart v2 require?
Version 2 requires PHP 8.3 or newer and Laravel 11, 12, or 13, with CI covering PHP 8.3 through 8.5. Laravel 13 and PHP 8.5 support is currently CI-declared forward compatibility, so validate it in your own application before treating it as production-proven. Applications on Laravel 10 or PHP 8.2 must stay on v1.x or upgrade their platform first.
What does removeInvalidItems() do in laravel-cart v2?
It runs when a cart is loaded from the session and strips any item missing an id, a name, or a quantity, so malformed entries never reach your totals or checkout logic. The release notes do not state that the behaviour is configurable, logged, or event-emitting, so treat it as an implicit, silent cleanup inside a normal user flow. If you need observability, wrap cart loading in your own code and compare item counts before and after.
Will upgrading from v1 to v2 delete items from existing customer carts?
It can. Carts persisted under v1.x may contain items that v2 classifies as invalid, and because cleanup happens on session load those entries disappear the first time a shopper returns after deployment. Treat this as a platform upgrade rather than a routine package bump: branch the change, test with real legacy session payloads, and deploy with a rollback plan. Communicate any expected cart cleanup to stakeholders before release.
Can I use laravel-cart on Laravel 10 or PHP 8.2?
No. v2's Composer constraints require PHP 8.3+ and Laravel 11+, and they will also conflict with any other dependency that pins Laravel 10. If a platform upgrade is blocked, pin to v1.x and confirm its maintenance and security-fix status with the maintainer. Budget for the runtime upgrade as its own project before adopting v2.
How are taxes and discounts applied to cart totals?
The package supports prices, taxes, and discounts at the item level and calculates cart totals from those values. Order of operations and rounding matter, so verify how your tax and discount rules combine for multi-item carts before relying on the numbers at checkout. Keep money as integers or use a consistent decimal strategy, and write tests for edge cases such as zero-priced items and fully discounted carts.
How do carts persist across sessions in laravel-cart?
Cart state is stored in the Laravel session, so persistence follows whatever session driver you configure, including file, database, Redis, or cookie-backed drivers. That means old cart payloads created on another driver or app version can survive a deployment and be re-read later. Test the load path against every driver you run in production, especially persistent ones holding pre-upgrade data.
Is joelwmale/laravel-cart safe to use in production?
It is a reasonable fit for greenfield or actively maintained Laravel 11 and 12 applications on PHP 8.3+, where the API is small and the cart logic is straightforward. The main risks are the hard platform requirements, silent removal of malformed items on load, and unproven forward-compatibility claims for Laravel 13 and PHP 8.5. Add logging around cart loading if you need visibility into removals, and keep a rollback path for releases.
How should I test a laravel-cart upgrade before deploying?
Write regression tests that cover adding, updating, and removing items, recalculating totals, applying taxes and discounts, and completing checkout. Then replay real legacy session payloads, including carts with missing ids, names, or quantities, to see exactly what removeInvalidItems() strips and how totals change. Run the suite against each session driver and Laravel version you support, and deploy only once the difference in cart contents is understood.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource