2017 © Pedro Peláez
 

library cart

Simplest 'cart' class ever written.

image

metator/cart

Simplest 'cart' class ever written.

  • Monday, July 8, 2013
  • by joshribakoff
  • Repository
  • 2 Watchers
  • 0 Stars
  • 189 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Coverage Status Build Status, (*1)

Metator Cart

The simplest shopping cart class ever to exist. For a full stack shopping cart system, check out metator/application., (*2)

The cart class class is hopefully very intuitive. It depends on nothing, and assumes nothing except that your items have a unique identifier., (*3)

use Metator\Cart\Cart;

$cart = new Cart;
$cart->add(5);
$cart->add(5);
$cart->add(5);

echo $cart->quantity(5); // 3
print_r($cart->items()); // array(5)

$cart->remove(5);
echo $cart->quantity(5); // 0
print_r($cart->items()); // array()

$cart->add(5);
$cart->setQuantity(5,500);

echo $cart->quantity(5); // 500

$cart->setQuantity(5,0);
print_r($cart->items()); // array()

Understanding Identifiers

The value for the ID could be the auto_increment from your database, a product SKU, or any kind of unique identifier like a hash. For example if a T-Shirt comes in multiple colors but always has the same SKU & ID regardless of color, you could use a hash representing the configured state of that product for the id here., (*4)

The Versions

08/07 2013

1.0.1

1.0.1.0

Simplest 'cart' class ever written.

  Sources   Download

OSL-3.0

The Development Requires

by Josh Ribakoff

07/07 2013

dev-master

9999999-dev

Simplest 'cart' class ever written.

  Sources   Download

OSL-3.0

The Development Requires

by Josh Ribakoff

06/07 2013

1.0.0

1.0.0.0

Simplest 'cart' class ever written.

  Sources   Download

OSL-3.0

The Development Requires

by Josh Ribakoff