public function Delete() { $result = null; try { // Remove // $r = $this->getRequest(); $d = $this->data(); $id = isset($d['id']) ? $d['id'] : null; //$r->getParam('id'); $totalDeleted = 0; if (isset($id)) { // Could be a zero, so we use isset() instead. if (count(self::$_cart) > 0) { foreach (self::$_cart as $i => $item) { if ($item['item_id'] == $id) { array_splice(self::$_cart, $i, 1); // unset(self::$_cart[$i]); ++$totalDeleted; } } } if ($totalDeleted > 0) { // Save the changes. \Zrecommerce\Storefront\Session::setNs('cart', self::$_cart); } } $result = array('result' => 'ok', 'data' => (int) $totalDeleted); } catch (\Exception $e) { error_log((string) $e); $result = array('result' => 'error', 'message' => $e->getMessage()); } return $result; }