- How do I install hardevine/shoppingcart in Laravel?
- Install it with Composer using composer require hardevine/shoppingcart. The package supports Laravel auto-discovery, so you typically only need to publish the config file if you want to customize tax, number formatting, or conditions. It does not require migrations or external services, so a working cart can be set up in a single development session.
- What is hardevine/shoppingcart used for?
- It provides a session-backed shopping cart primitive for Laravel applications, with methods for adding, updating, and removing line items and reading subtotal, tax, and total values. You can use it for a conventional server-rendered checkout flow and add cart-level or item-level conditions for discounts and vouchers. It is not a full commerce engine: it does not provide products, stock, orders, payment, or checkout state management.
- Does hardevine/shoppingcart support Laravel 11 and Laravel 12?
- The provided context does not list the exact Laravel and PHP versions in the package's supported CI matrix, so verify composer.json and the repository's test matrix before committing. Test it against your target versions, such as Laravel 11 or 12 with PHP 8.3 or 8.4, in a short spike. If your versions are not covered, pin the package and add integration tests or maintain a fork.
- How do I configure tax and price formatting in hardevine/shoppingcart?
- Publish config/shoppingcart.php to adjust the package's tax rate, number formatting, and condition settings. The package uses a single tax rate in configuration, so multi-currency and tax-jurisdiction logic remain your responsibility. Store prices in a consistent representation and format them at the edge rather than relying on the package for locale-aware money handling.
- How do cart conditions and discounts work in hardevine/shoppingcart?
- Conditions can be attached at item level or cart level and are commonly used for discounts and vouchers. Before relying on them, test the order of application and whether a condition is evaluated before or after tax and per line versus per cart. Keep complex pricing and promotion rules in your own service layer so they remain testable and independent of the package internals.
- Can I use hardevine/shoppingcart with an API or SPA?
- It is a weak fit for headless or token-authenticated APIs because the cart is stored in the Laravel session. Sanctum or SPA clients can work only with custom session handling, and merging carts across devices requires your own store and restore logic. For API-first commerce, a database-backed cart service is usually a better foundation.
- Is hardevine/shoppingcart safe to use for production checkout?
- It can be suitable for a simple Laravel monolith, but you must treat the cart as temporary state rather than a system of record. Session expiry, cookie clearing, or a session driver change can orphan or lose cart data, and line-item prices are snapshotted when added. Revalidate prices, tax, stock, and discounts at checkout before charging the customer.
- How does hardevine/shoppingcart handle money and rounding?
- The package stores prices and totals as floats, so it does not impose a documented rounding or money strategy. Use integer minor units in your own domain and convert only for display, or define a strict rounding policy around the package. Always recalculate and reconcile totals at checkout to avoid drift.
- How should I test hardevine/shoppingcart in a Laravel app?
- Check the repository's test coverage and CI matrix before adopting it, because the evaluation flags the quality signal as medium. Add your own feature tests for add, update, remove, totals, tax, conditions, and session persistence behavior. Also test edge cases such as stale prices, quantity changes across tabs, and cart restore or merge flows.
- Is hardevine/shoppingcart maintained, and what are the alternatives?
- It is a community-maintained fork of Crinsane/LaravelShoppingcart, so review release history, open issues, maintainer responsiveness, and how far it has diverged from upstream. Alternatives include the upstream package, other Laravel cart packages, or a custom database-backed cart service if you need persistence or API support. Choose based on your checkout model, maintenance expectations, and tolerance for session-backed state.