inventory = unserialize($_COOKIE['CART']); } } public function save() { $cart = serialize($this->inventory); setcookie('CART', $cart, time() + 60 * 60 * 24 * 10); } public function add_new($_inv_id) { if (!is_numeric($_inv_id) || $_inv_id <= 0) return; if (!array_search($_inv_id, $this->inventory)) $this->inventory[] = $_inv_id; } public function add($_inv_id, $_qty = 1) { if (!is_numeric($_inv_id) || $_inv_id <= 0) return; $quantity = (isset($this->inventory[$_inv_id])) ? $this->inventory[$_inv_id] : 0; $quantity += $_qty; $this->inventory[$_inv_id] = $quantity; } public function delete($_inv_id) { if (isset($this->inventory[$_inv_id])) { unset($this->inventory[$_inv_id]); } } public function clear() { $this->inventory = array(); $this->save(); } public function change($_id, $_value) { $_value = intval($_value); if (!$_value) { $this->delete($_id); return false; } if (isset($this->inventory[$_id])) { $test = true; $this->inventory[$_id] = $_value; } } } ?>