/** * Update an item. * * @param Array $product * @return \Anam\Phpcart\Collection */ public function update(array $product) { $this->collection->setItems($this->session->get($this->getCart(), [])); if (!isset($product['id'])) { throw new Exception('id is required'); } if (!$this->has($product['id'])) { throw new Exception('There is no item in shopping cart with id: ' . $product['id']); } $item = array_merge((array) $this->get($product['id']), $product); $items = $this->collection->insert($item); $this->session->set($this->getCart(), $items); return $this->collection->make($items); }