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
Laravelshoppingcart

Laravelshoppingcart Laravel Package

olimortimer/laravelshoppingcart

A Laravel shopping cart package for managing cart items with quantities, prices, and custom conditions. Easily add, update, and remove products, calculate totals, taxes, and discounts, and persist carts across sessions.

View on GitHub
Deep Wiki
Context7

Laravel Shoppingcart

Frequently asked questions about Laravelshoppingcart
How do I install olimortimer/laravelshoppingcart with Composer?
Install it with composer require olimortimer/laravelshoppingcart, which will pull the 6.x line if your application meets the requirements. Version 6.0.1 targets Laravel 9, so your project must run PHP 8.0 or higher. After installing, publish the package configuration if you need to customise storage, and register the Cart facade in your aliases. On Laravel versions with package auto-discovery the service provider is registered for you.
Which Laravel and PHP versions does version 6.0.1 support?
The 6.0.1 release is a major-version line whose headline change is Laravel 9 support, which implies a PHP 8.0 or higher floor. Treat Laravel 9 as the supported target unless you can confirm dual support for Laravel 8 in the repository. If your application is still on Laravel 8 or earlier, this release is out of scope until you upgrade the framework. Validate the PHP requirement against your CI and production images before planning adoption.
Is olimortimer/laravelshoppingcart a fork of gloudemans/shoppingcart?
Yes, the package follows the well-known LaravelShoppingcart API popularised by gloudemans/shoppingcart, which is why the add, update, remove and conditions methods look familiar. This fork's practical differentiator is the Laravel 9 compatible 6.x release line. If you are migrating from the original package, expect the same facade and cart model surface but read the changelog for the major bump. Confirm the exact breaking changes between 5.x and 6.0.x before switching a production integration.
How do I add, update and remove products in the cart?
You interact with the cart through the Cart facade, calling add with a product ID, name, quantity and unit price to insert or increment an item. Calling update with an existing row ID and a new quantity changes the line, and remove deletes it by row ID. Totals such as total, subtotal and count are then available as properties on the returned cart content. Always check the return value so you can surface validation errors such as an invalid quantity to the user.
How does the cart persist across sessions?
By default the cart contents are written to the Laravel session, so a user's basket survives page requests without extra work. For logged-in users you can switch the storage to a database connection and associate carts with a user identifier so baskets survive session expiry. Configure the storage driver in the published package config and make sure the schema or migration for the carts table exists. If you support guest carts, plan how you will merge or reassign the cart on login.
Can I apply taxes, discounts and custom conditions to cart totals?
Yes, the package ships with a conditions API that lets you attach value-based or percentage-based rules to individual items or to the whole cart. Typical uses are tax rates, voucher codes, shipping surcharges and promotional discounts, and they are recalculated whenever the cart is updated. Global conditions apply to the cart subtotal while per-item conditions affect only that line. Keep money handling consistent by choosing an integer-cents or decimal strategy and applying it to both prices and condition values.
What breaking changes come with the 5.x to 6.0.1 upgrade?
The release note is thin and only mentions Laravel 9 support, but a major version bump almost always carries API and dependency changes beyond the framework requirement. Review the repository changelog and diff the source against your integration points, including the facade, service provider, config keys and any classes you extend. Expect the PHP 8.0 floor and updated Symfony and Flysystem dependencies to affect your lockfile. Budget this as a planned upgrade window rather than an opportunistic composer update.
Can the cart be stored in the database instead of the session?
Yes, the package supports database-backed storage in addition to the default session driver, which is the usual choice when carts must survive logout or be visible across devices. You switch the storage driver in configuration and provide the identifier used to look up a cart, typically the authenticated user ID. You will also need the carts table in place, either from the package migration or your own. Test the transition between guest and authenticated carts carefully, since that is where most persistence bugs appear.
How do I test shopping cart logic in my Laravel test suite?
Because the API is exposed through a facade, you can drive real cart behaviour in feature tests by calling add, update and remove and asserting on totals, counts and conditions. Use the array or session driver in tests so each test case starts from a clean basket, and flush the cart in setUp. Assert monetary values with the same rounding strategy your application uses to avoid brittle assertions. Also cover edge cases such as zero quantities, duplicate adds and condition removal.
Is this package actively maintained and will it support newer Laravel versions?
The 6.0.1 patch inside a new major suggests a 6.0.0 release was followed by a fix, but the single-line release notes indicate limited documentation and upgrade guidance. Check the repository commit history and issue tracker activity before committing to it for a long-lived project, and confirm the 6.x line plans to track future Laravel releases. If you are running Laravel 9 on PHP 8.0 or higher, the current release is the version to take. If you need Laravel 10 or later support, verify it explicitly rather than assuming forward compatibility.
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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections