Download the PHP package andreilungeanu/simple-cart without Composer
On this page you can find all versions of the php package andreilungeanu/simple-cart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andreilungeanu/simple-cart
More information about andreilungeanu/simple-cart
Files in andreilungeanu/simple-cart
Package simple-cart
Short Description A simple cart package for Laravel applications
License MIT
Homepage https://github.com/andreilungeanu/simple-cart
Informations about the package simple-cart
A simple cart for Laravel
A flexible shopping cart implementation for Laravel with support for multiple discounts, tax calculations, shipping, and extra costs.
Features
- Core logic managed by
CartManager
(bound toCartManagerInterface
). - Stateless API accessed via
SimpleCart
Facade (delegates toCartManager
). - Fluent interface (
FluentCart
) for easy cart modification after creating or finding a cart. - Manages cart state via
CartInstance
objects (primarily data containers). - Flexible tax calculation supporting multiple zones, categories, and VAT exemption.
- Configurable shipping methods and costs, including free shipping thresholds.
- Support for various discount types (e.g., fixed amount, percentage).
- Ability to add extra costs (e.g., gift wrapping, handling fees).
- Database persistence driver.
- Calculation of cart totals via dedicated manager methods.
- Event-driven architecture (
CartCreated
,CartUpdated
,CartCleared
). - Comprehensive test suite.
Installation
Install the package via composer:
Publish the configuration file (optional):
This will create config/simple-cart.php
.
Publish and run the migration file:
Usage Examples
Use the SimpleCart
facade to create
or find
a cart. These methods return a cart object that allows you to chain modification methods fluently. Calculation methods (total
, subtotal
, etc.) are called on the main SimpleCart
Facade, passing the specific cart ID.
Basic Operations
Tax Handling
Shipping
Discounts
Extra Costs
Configuration (config/simple-cart.php
)
Events
The package fires the following events, allowing you to hook into the cart lifecycle:
AndreiLungeanu\SimpleCart\Cart\Events\CartCreated
: Fired when a new cart is created. Contains theCartInstance
.AndreiLungeanu\SimpleCart\Cart\Events\CartUpdated
: Fired when items, discounts, shipping, etc., are modified. Contains the updatedCartInstance
.AndreiLungeanu\SimpleCart\Cart\Events\CartCleared
: Fired when the cart is cleared. Contains thecartId
.
You can create listeners for these events as per standard Laravel event handling.
Testing
Run the test suite using Pest:
Credits
- Andrei Lungeanu
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of simple-cart with dependencies
spatie/laravel-package-tools Version ^1.0
illuminate/contracts Version ^12.0