Esempio n. 1
0
 /**
  * Updates info in the cart. Adds a notice if trying to increase
  * the amount of giveaway product over the allowed limit
  */
 public function updatePostAction()
 {
     $aParams = $this->getRequest()->getParams();
     /** @var Sitewards_Giveaway_Helper_Data $oHelper */
     $oHelper = Mage::helper('sitewards_giveaway');
     $aProductInformation = $oHelper->getUpdateCartProductInfo($this->getRequest());
     $bIsCartActionUpdate = $aParams[self::S_CART_ACTION_KEY] == self::S_CART_ACTION_UPDATE;
     if ($bIsCartActionUpdate && $oHelper->canAddProducts($aProductInformation) == false) {
         $this->_goBack();
     } else {
         parent::updatePostAction();
     }
 }
Esempio n. 2
0
 public function updatePostAction()
 {
     parent::updatePostAction();
     if ($this->getRequest()->getParam('ajaxcartpopup') && $this->getRequest()->getParam('ajaxupdatequantity')) {
         $result = 'success';
         $this->loadLayout()->_initLayoutMessages('checkout/session');
         foreach (Mage::getSingleton('checkout/session')->getMessages()->getItems() as $message) {
             if ($message->getType() == 'error' || $message->getType() == 'exception') {
                 $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)));
         }
     }
 }