Manual

marketcart.class.php

marketcart class

Usage:

{{lang:php}}
## COOKIE STORAGE
// ADD / UPDATE
$array = unserialize($_COOKIE['cart']);
$cart =  new marketcart($array);
$cart->add(12,2); // ($iid,$quantity)
$cart->update(1,2); // ($index,$quantity)
$array = serialize($cart->store());
setcookie("cart", $array, time()+3600*24*30, "/", MP::$MP['host']);

// LIST
$array = unserialize($_COOKIE['cart']);
$cart =  new marketcart($array);
$list = $cart->cart(); // return array

// REMOVE
$array = unserialize($_COOKIE['cart']);
$cart =  new marketcart($array);
$cart->remove(0); // ($index)
$array = serialize($cart->store());
setcookie("cart", $array, time()+3600*24*30, "/", MP::$MP['host']);

// EMPTY
$array = unserialize($_COOKIE['cart']);
$cart =  new marketcart($array);
$cart->clear();
$array = serialize($cart->store());
setcookie("cart", $array, time()+3600*24*30, "/", MP::$MP['host']);

## SESSION STORAGE
// ADD / UPDATE
$array = unserialize($_SESSION['cart']);
$cart =  new marketcart($array);
$cart->add(12,2); // ($iid,$quantity)
$cart->update(1,2); // ($index,$quantity)
$_SESSION['cart'] = serialize($cart->store());
Try myPortal 2: