vaened / swift-cart
The SwiftCart library is a powerful tool for managing shopping carts, invoicing, and product administration.
Installs: 8 080
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- brick/money: ^0.8.0
- lambdish/phunctional: ^2.1
- vaened/php-price-engine: ^1.0
- vaened/support: ^4.0
Requires (Dev)
- phpunit/phpunit: ^10.2
- symfony/var-dumper: ^6.3
This package is auto-updated.
Last update: 2024-10-30 20:00:31 UTC
README
This library is a powerful tool that allows you to efficiently manage purchases, quotes, accounts, and more. With this library, you can effortlessly handle various aspects of a shopping cart, including adding products, taxes, fees, and discounts, and obtaining a detailed summary of the total amount to pay.
This library is based on vaened/php-price-engine for price management
// initialize cart $taxes = Taxes::from([ Inclusive::proporcional(18, 'IGV') ]); $cart = new ShoppingCart($taxes); // add products $mouse = $cart->push(Product::findOrFail(1), quantity: 2); // assign individual charges and discounts $mouse->add( Charge::proporcional(percentage: 5)->named('Delivery'), Charge::fixed(amount: 2)->named('Random'), ); $mouse->apply( Discount::proporcional(percentage: 10)->named('NewUser') ); // update quantity $mouse->update(quantity: 3); // assign global charges and discounts $cart->addAsGlobal( Charge::fixed(amount: 2)->named('Express') ); $cart->applyAsGlobal( Discount::proporcional(percentage: 1) ); // get summary $cart->summary();
Installation
You can install the library using composer
.
composer require vaened/swift-cart