Example #1
0
 public function deleteAction()
 {
     //        if (!$this->_validateFormKey()) {
     //            Mage::throwException('Invalid form key');
     //        }
     $id = (int) $this->getRequest()->getParam('id');
     $response = new Varien_Object();
     $response->setError(0);
     if ($id) {
         try {
             $this->_getCart()->removeItem($id)->save();
             $response->setQty($this->_getCart()->getSummaryQty());
             $this->loadLayout();
             $content = $this->getLayout()->getBlock('cart_sidebar')->toHtml();
             $response->setContent($content);
             $response->setSuccessMessage($this->__('<div class="removed-successfully">This item was removed from the cart</div>'));
         } catch (Exception $e) {
             $response->setError(1);
             $response->setErrorMessage($this->__('<div class="removed-failed">Can not remove the item.</div>'));
         }
     }
     $this->getResponse()->setBody($response->toJson());
 }