/** * 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); } }
/** * remove item from cart */ public function removeAction() { // init $status = array('title' => 'Cart', 'text' => 'error', 'success' => false, 'snippet' => array()); // remove item from cart if ($id = $this->getParam('item')) { $product = Object_Product::getById($id); /* @var Website_DefaultProduct $product */ if ($product) { $this->cart->removeItem($id); $this->cart->save(); $status['title'] = 'Removed'; $status['success'] = true; $status['text'] = $product->getOSName(); $image = $product->getFirstImage(array('width' => 48, 'height' => 48, 'aspectratio' => true)); if ($image) { $status['image'] = $image->__toString(); } } } // 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); } }