Ejemplo n.º 1
0
 public function deleteAction()
 {
     parent::deleteAction();
     if ($this->getRequest()->getParam('ajaxcartpopup')) {
         $result = 'success';
         foreach (Mage::getSingleton('checkout/session')->getMessages()->getItems() as $message) {
             if ($message->getType() == 'error') {
                 $result = Mage::helper('checkout/cart')->getCartUrl();
             }
             break;
         }
         $this->getResponse()->clearHeaders()->clearBody();
         $this->getResponse()->setHeader("Content-Type", "text/html; charset=UTF-8")->setHttpResponseCode(200)->isRedirect(0);
         if ($this->getRequest()->getParam('iscartpage')) {
             $totals = '';
             if ($result == 'success') {
                 $totals = $this->getLayout()->createBlock('checkout/cart_totals')->setTemplate('checkout/cart/totals.phtml')->toHtml();
             }
             $this->getResponse()->setBody(Zend_Json::encode(array('result' => $result, 'totals' => $totals)));
         } else {
             $linktext = '';
             $popuphtml = '';
             $emptycart = '';
             if ($result == 'success') {
                 $this->loadLayout()->_initLayoutMessages('checkout/session');
                 $linktext = $this->_getLinkText();
                 $popuphtml = $this->getLayout()->getBlock('ajaxcartpopup')->toHtml();
                 $emptycart = Mage::helper('ajaxcartpopup')->getCartCount() ? false : true;
             }
             $this->getResponse()->setBody(Zend_Json::encode(array('result' => $result, 'linktext' => $linktext, 'popuphtml' => $popuphtml, 'emptycart' => $emptycart)));
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Delete shoping cart item action
  */
 public function deleteAction()
 {
     $session = Mage::getSingleton('core/session', array('name' => 'frontend'));
     Mage::log($session->getData('catid'));
     if ($session->getData('catid') && $session->getData('catid') != 0) {
         $catId = $session->getData('catid');
         $url = Mage::getModel('catalog/category')->load($catId)->getUrl();
         $rout = explode(Mage::getBaseUrl(), $url);
         $id = (int) $this->getRequest()->getParam('id');
         if ($id) {
             try {
                 $this->_getCart()->removeItem($id)->save();
             } catch (Exception $e) {
                 $this->_getSession()->addError($this->__('Cannot remove the item.'));
                 Mage::logException($e);
             }
         }
         $this->_redirect($rout[1]);
     } else {
         parent::deleteAction();
     }
 }
Ejemplo n.º 3
0
 public function deleteAction()
 {
     $params = $this->getRequest()->getParams();
     if (isset($params['isAjax']) && $params['isAjax'] == 1) {
         $id = (int) $this->getRequest()->getParam('id');
         $response = array();
         if ($id) {
             try {
                 $this->_getCart()->removeItem($id)->save();
                 $response['status'] = 'SUCCESS';
                 $response['message'] = '';
             } catch (Exception $e) {
                 $this->_getSession()->addError($this->__('Cannot remove the item.'));
                 $response['status'] = 'ERROR';
                 $response['message'] = $this->__('Cannot remove the item.');
                 Mage::logException($e);
             }
         }
         $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));
     } else {
         parent::deleteAction();
     }
 }