2017 © Pedro Peláez
 

library laravel-cart

Simple Laravel shopping cart

image

matthewbdaly/laravel-cart

Simple Laravel shopping cart

  • Monday, July 16, 2018
  • by matthewbdaly
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 17 % Grown

The README.md

laravel-cart

Build Status Coverage Status, (*1)

Simple shopping cart implementation for Laravel. Loosely inspired by CodeIgniter's cart class., (*2)

Installation

composer require matthewbdaly/laravel-cart

Usage

The cart implements the interface Matthewbdaly\LaravelCart\Contracts\Services\Cart, so you can use that to type-hint it. Alternatively you can use the Cart facade., (*3)

Add item

To add an item, call $cart->insert($data). In this case $data must be an array with the following fields:, (*4)

  • qty
  • price
  • name
  • options

OR an array of items, each with the same fields. You can also add any additional data you wish., (*5)

Get all items

Call $cart->all() to retrieve the contents., (*6)

Get single item

Call $cart->get($rowId) to retrieve an item by its row ID., (*7)

Update single item

Call $cart->update($rowId, $data) to update an item with the provided data., (*8)

Remove item

Call $cart->remove($rowId) to remove an item., (*9)

Get total price

Call $cart->total() to get the total price., (*10)

Get total items

Call $cart->totalItems() to get a count of the items. Note that this does not allow for the quantity - if you have item X with a quantity of 2, that will be 1 item in the count., (*11)

Destroy cart

Call $cart->destroy() to destroy the cart., (*12)

The Versions