/** * remove item from wishlist */ public function removeAction() { // remove item from wishlist if ($id = $this->getParam('item')) { $this->wishlist->removeItem($id); $this->wishlist->save(); } // its a ajax request? if ($this->getRequest()->isXmlHttpRequest()) { $this->_helper->json(array()); } else { $url = $this->view->url(array('action' => 'list'), 'wishlist'); $this->redirect($url); } }
/** * update cart item */ public function updateAction() { // init $status = array('title' => 'Cart', 'text' => 'error', 'success' => false, 'snippet' => array()); if ($this->getParam("qty")) { foreach ($this->getParam("qty") as $key => $qty) { $product = Object_Product::getById($key); if ($product) { $this->cart->updateItem($key, $product, intval($qty), true); $this->cart->save(); $status['text'] = 'Quantity changed'; $status['success'] = true; } } } // change quantity // foreach($this->getAllParams() as $name => $value) // { // if(preg_match('#^(?<action>qty|comment)_(?<itemKey>\w+)#', $name, $match)) // { // $item = $this->cart->getItem($match['itemKey']); // if($item) // { // if($match['action'] == 'qty') // { // $item->setCount( (int)$value ); // $status['text'] = 'Quantity changed'; // } // // if($match['action'] == 'comment') // { // $item->setComment( $value ); // $status['text'] = 'Comment saved'; // } // // $item->save(); // $status['success'] = true; // } // } // } // its a ajax request? if ($this->getRequest()->isXmlHttpRequest()) { // add header cart snippet $this->snippetHeaderAction(); $status['snippet']['snippetHeader'] = $this->view->render('cart/snippet-header.php'); $this->_helper->viewRenderer->setNoRender(true); $this->getResponse()->setHeader('Content-Type', 'application/json'); echo Zend_Json::encode($status); } else { $url = $this->view->url(array('action' => 'list'), 'cart'); $this->redirect($url); } }