2017 © Pedro Peláez
 

library laravel-cart

Laravel cart package

image

haska/laravel-cart

Laravel cart package

  • Sunday, May 25, 2014
  • by haska
  • Repository
  • 2 Watchers
  • 3 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel cart package

Informations

Provider:, (*1)

'Haska\Cart\CartServiceProvider',

Alias:, (*2)

'Cart' => 'Haska\Cart\Facade',

Config:, (*3)

php artisan config:publish haska:laravel-cart

Examples:, (*4)

Insert

// Format array of required info for item to be added to cart...
$items = array(
    'id' => 1,
    'name' => 'Product name',
    'price' => 120.00,
    'quantity' => 1
);

// Make the insert...
Cart::insert($items);

Insert with tax rate (in this example 20%)

Cart::insert(array(
    'id'       => 'foo',
    'name'     => 'bar',
    'price'    => 100,
    'quantity' => 1,
    'tax'      => 20
));

Updating items in the cart

foreach (Cart::contents() as $item) {
    $item->name = 'Foo';
    $item->quantity = 1;
}

Removing items in the cart

foreach (Cart::contents() as $item) {
    $item->remove();
}

Destroying/emptying the cart

Cart::destroy()

Retrieve the cart contents

Cart::contents();

Content passed like an array, (*5)

Cart::contents(true);

Retrieving the total items in the cart

Cart::totalItems();

Get only unique items, (*6)

Cart::totalItems(true);

Retrieving the cart total

Cart::total();

Passed without tax rates, (*7)

Cart::total(false);

Check if the cart has an item

Cart::has($id);

Retreive an item object by identifier

$item = Cart::item($id);

Cart items (item objects)

Retrieving the total value of an item

$item->total();

Without tax rates, (*8)

$item->total(false);

Check if an item has options

if ($item->hasOptions()) {
    // We have options
}

Remove an item from the cart

$item->remove();

Output the item data as an array

$item->toArray();

The Versions

25/05 2014

dev-master

9999999-dev

Laravel cart package

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Haska