neccoys / ezcart
A easy cart for Laravel
dev-main
2022-12-23 10:21 UTC
Requires
- php: ~7.3 || ~7.4 || ~8.0
- ext-intl: *
- illuminate/events: ~5.5.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0
- illuminate/session: ~5.5.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0
- illuminate/support: ~5.5.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: ^6.25
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-04-23 13:00:20 UTC
README
Introduction
A easy cart for Laravel
Installation
// composer
composer require neccoys/ezcart
// publish
php artisan vendor:publish --provider="Neccoys\EzCart\EzCartServiceProvider"
Quick Usage Example
// Add item EzCart::add( $itemID, $name = null, $qty = 1, $price = '0.00', $options = [], $lineItem = false ) $item = EzCart::add(2, 'T-shirt', 200, 15, [ 'size' => 'L' ]); $itemHash = $item->getHash(); // Update item EzCart::updateItem($item->getHash(), 'size', 'M'); // Remove item EzCart::removeItem($item->getHash()); // Find items (array) $items = EzCart::find(['name' => 'product001']); // Empty cart EzCart::emptyCart(); // Destroy cart EzCart::destroyCart();
Coupons & Fee
// Fixed amount // you can set 'minAmount' $couponFixed = new Fixed("coupon002", 35, [ 'description' => "test fixed coupon", 'minAmount' => 45, ]); EzCart::addCoupons($couponFixed); // Percentage // you can set 'minAmount', 'maxDiscount' $couponPercentage = new Percentage("coupon001", .8, [ 'description' => "test percent", 'minAmount' => 0, 'maxDiscount' => 0 ]); EzCart::addCoupons($couponPercentage);
Total
// Items totals EzCart::itemTotals(); // Totals (tax) EzCart::total(); // SubTotal (coupons + tax) EzCart::subTotal();