- 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.