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

Cart Laravel Package

realrashid/cart

A flexible shopping cart package for Laravel with session and database storage, multiple cart instances, item conditions, quantities, and total calculations. Add products, update items, apply conditions, and persist carts for logged-in users through a simple API.

View on GitHub
Deep Wiki
Context7

Meet Cart — your seamless solution for efficient shopping cart management in Laravel. Simplifying everything from product additions to total calculations, Cart ensures a frictionless user experience for e-commerce applications.

Frequently asked questions about Cart
How do I install realrashid/cart in a Laravel application?
Install it with Composer using composer require realrashid/cart; Laravel package auto-discovery registers the service provider. Publish the package configuration and, if you plan to use database storage, the migrations. For v2, confirm your app runs Laravel 13 and PHP 8.3+ before requiring the package.
Does realrashid/cart support session and database cart storage?
Yes. The package supports session-based carts for guest users and database-backed carts for persistence, including carts for logged-in users. If you use the database driver, publish and run the migrations and configure the storage option in the package config. Session storage is simpler but does not persist across sessions the way database storage can.
Can I use multiple cart instances in one Laravel app?
Yes, multiple cart instances are a supported feature. You can keep separate carts, such as a default cart, a wishlist-style cart, or vendor-specific carts, by selecting an instance before calling cart operations. This helps when one application needs isolated baskets for different flows or user contexts.
How do I add, update, and remove items with realrashid/cart?
Use the package's cart API to add products with an ID, name, price, and quantity, then update quantities or remove items as the user changes their basket. Each item is tracked by an identifier so updates and removals target the correct row. Totals recalculate when quantities or items change, which keeps your checkout summary consistent.
What are item conditions in realrashid/cart and when should I use them?
Conditions let you attach adjustments such as discounts, taxes, fees, or shipping-like charges to individual cart items or to the whole cart. They are useful when a promotion or surcharge needs to affect totals without changing the underlying product price. Apply them before reading totals so the calculated cart reflects the adjustment.
Which Laravel and PHP versions are required by realrashid/cart v2?
Version 2.0.0 targets Laravel 13 and requires PHP 8.3 or newer. Its development tooling references Testbench v11 and Pest v4, which mainly affect package testing and CI. If your application is on Laravel 10, 11, or 12, plan the PHP and Laravel upgrades before adopting v2, or stay on a compatible earlier package version.
How do I persist a cart for a logged-in user in Laravel?
Use the database storage driver and run the package migrations so cart contents can be saved. Associate the stored cart with the authenticated user according to the package configuration, then restore it when the user returns. This avoids losing basket contents when the session ends and supports cross-device continuity if your implementation links carts to users.
Is realrashid/cart production-ready for a new Laravel 13 application?
It can be a fit for greenfield Laravel 13 services on PHP 8.3+, but v2.0.0 is a major release, so treat it as early-adopter until you verify the changelog and upgrade notes. Pin an exact version, run the package tests and your application regression suite, and pilot it outside production first. Also confirm the maintainer's support cadence for Laravel 13.x updates.
How are cart subtotal, total, and discounts calculated?
The package calculates item totals from price and quantity, then produces a cart subtotal and final total. Conditions such as discounts or fees are applied as part of that calculation so the total reflects adjustments. Read the subtotal for the unadjusted item sum and the total for the final amount after conditions.
What should I check before upgrading realrashid/cart from v1 to v2?
Assume breaking changes because v2.0.0 is a major release, even if the release notes mainly mention Laravel 13 support and dependency alignment. Upgrade PHP to 8.3+ and Laravel to 13 first, then adopt package v2 in a branch. Review the full changelog or upgrade guide, run Composer dependency diagnostics, and regression-test cart flows before pinning the new version in production.
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.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core