unodepiera / simplecart
There is no license information available for the latest version (dev-master) of this package.
Simplecart for Laravel 4
dev-master
2014-02-13 20:10 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.0.*
This package is not auto-updated.
Last update: 2024-11-19 07:58:19 UTC
README
Installation
Open your composer.json and add the next code
```json { "require": { "laravel/framework": "4.0.*", "unodepiera/simplecart": "dev-master" }, "minimum-stability": "dev" } ```Update your packages with composer update or install with composer install.
Usage
Find the providers key in app/config/app.php and register the Simplecart Service Provider.
```json 'providers' => array( //... 'Unodepiera\Simplecart\SimplecartServiceProvider' ) ```Find the aliases key in app/config/app.php.
```json 'aliases' => array( //... 'Simplecart' => 'Unodepiera\Simplecart\Facades\Simplecart', ) ```Example Usage Simplecart
Insert simple row
```php $id = 19; $qty = 20; $price = 550; $item = array( 'id' => 5, 'qty' => $qty, 'price' => $price, 'name' => "hair", 'medida' => "xl" );//add options to row
$item["options"] = array("color" => "blue", "avaliable" => "si");
//add row to cart
Simplecart::insert($item);
<h2>Update a product</h2>
```php
$update = array(
'id' => 5,
'rowid' => "e4da3b7fbbce2345d7772b0674a318d5",
'qty' => 25,
'price' => $price,
'name' => "shirt",
'medida' => "xl"
);
Simplecart::update($update);
Remove a product by rowid
You just need to pass a rowid that there
```php Simplecart::remove_item("8e296a067a37563370ded05f5a3bf3ec"); ```Get cart content
```php Simplecart::get_content(); ```Get total cost
```php Simplecart::total_cart(); ```Get total items
```php Simplecart::total_articles(); ```Destroy simplecart
```php Simplecart::destroy(); ```Final example usage
First visit route insert
```php Route::get("insert", function(){ $id = 9; $qty = 5; $price = 1500; $item = array( 'id' => $id, 'qty' => $qty, 'price' => $price, 'name' => "shirt", 'medida' => "xxl" );//add options to row
$item["options"] = array("color" => "orange", "avaliable" => "yes");
//add row to cart
Simplecart::insert($item);
});
<h3>Then create the next view and visit the route show</h3>
```php
Route::get("show", function()
{
$cart = Simplecart::get_content();
$totalcart = Simplecart::total_cart();
$totalitems = Simplecart::total_articles();
return View::make("cart", array("cart" => $cart, "total_cart" => $totalcart, "total_items" => $totalitems));
});