2 – Laravel Shopping Basket Package
Laravel Facade and Service Provider for Lenius\Basket
Installation
To use, simply install the package via Composer and then add the following to your app/config/app.php to the service providers array:
'Lenius\Basket\BasketServiceProvider',
You should then be good to go and be able to access the basket using the following static interface:
//Format array of required info for item to be added to basket...
$items = array(
'id' => 1,
'name' => 'Dog',
'price' => 120.00,
'quantity' => 1,
'weight' => 200
);
//Make the insert...
Basket::insert($items);
//Let's see what we have got in their...
dd(Basket::totalItems());
Setting the tax rate for an item
Another key you can pass to your insert method is ‘tax’. This is a percentage which you would like to be added onto the price of the item.
In the below example we will use 25% for the tax rate.
Basket::insert(array(
'id' => 'mouseid',
'name' => 'Mouse',
'price' => 100,
'quantity' => 1,
'tax' => 25,
'weight' => 200
));