pajaeu / carton
The missing cart package for Laravel.
Fund package maintenance!
pajaeu
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/pajaeu/carton
Requires
- php: ^8.4
- illuminate/contracts: ^12.24
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.8
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/phpstan: ^2.1
README
Carton is the missing cart package for Laravel.
📦 Installation
Install package via composer
composer require pajaeu/carton
Then publish configuration and migrations
php artisan carton:install
🚀 How to use Carton
// create cart using custom currency code Carton::createCart('CZK'); // if we do not pass currency code, it uses default one specified in config Carton::createCart(); // then we need to create new data $data = new CartLineData( 'Product 1', 300, 21, [ 'size' => [ 'XS', ], ] ); // so we can pass it to the addLine method also with the quantity parameter Carton::addLine($data, 2); // we can recalculate cart's totals so we have everything right (it is being made automatically when calling adding new line) Carton::recalculate(); // then we can get the cart model and its properties $cart = Carton::getCart(); echo 'Total items in cart: '.$cart->count; echo 'Totals to pay: '.$cart->grand_total_with_vat.' '.$cart->currency_code; // we can also get some current cart's properties using the facade echo 'Totals to pay: '.Carton::getCartTotal().' '.Carton::getCartCurrencyCode(); // we can access lines on the cart model $lines = $cart->lines; // or you can get lines using the facade (returns empty collection if cart is not created yet) $lines = Carton::getCartLines();
License
The MIT License (MIT). Please see License File for more information.
