Skip to content

Powerful tool for managing shopping carts, invoicing, and product administration.

License

Notifications You must be signed in to change notification settings

vaened/swift-cart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Cart

Build Status Software License

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

About

Powerful tool for managing shopping carts, invoicing, and product administration.

Resources

License

Stars

Watchers

Forks

Packages

No packages published