public function viewBasketAction()
 {
     if ($this->getParam('do-return')) {
         return $this->_redirect('cart');
     }
     $d = (array) $this->getParam('d', array());
     $qty = (array) $this->getParam('qty', array());
     foreach ($qty as $item_id => $newQty) {
         if ($item = $this->cart->getInvoice()->findItem('product', intval($item_id))) {
             if ($item->is_countable) {
                 $item->qty = (int) $newQty;
             }
         }
     }
     foreach ($d as $item_id => $val) {
         if ($item = $this->cart->getInvoice()->findItem('product', intval($item_id))) {
             $this->cart->getInvoice()->deleteItem($item);
         }
     }
     if (($code = $this->getFiltered('coupon')) !== null) {
         $this->view->coupon_error = $this->cart->setCouponCode($code);
     }
     $this->cart->calculate();
     if (!$this->view->coupon_error && $this->getParam('do-checkout')) {
         return $this->checkoutAction();
     }
     $this->view->display('cart/basket.phtml');
 }
Esempio n. 2
0
 public function viewBasketAction()
 {
     if ($this->getParam('do-return')) {
         if ($this->getParam('b')) {
             return $this->redirectLocation($this->getParam('b'));
         }
         return $this->_redirect('cart');
     }
     $d = (array) $this->getParam('d', array());
     $qty = (array) $this->getParam('qty', array());
     foreach ($qty as $item_id => $newQty) {
         if ($item = $this->cart->getInvoice()->findItem('product', intval($item_id))) {
             if ($item->is_countable && $item->variable_qty) {
                 if ($newQty == 0) {
                     $this->cart->getInvoice()->deleteItem($item);
                 } else {
                     $item->qty = 0;
                     $item->add($newQty);
                 }
             }
         }
     }
     foreach ($d as $item_id => $val) {
         if ($item = $this->cart->getInvoice()->findItem('product', intval($item_id))) {
             $this->cart->getInvoice()->deleteItem($item);
         }
     }
     if (($code = $this->getFiltered('coupon')) !== null) {
         $this->view->coupon_error = $this->cart->setCouponCode($code);
     }
     if ($this->getDi()->auth->getUserId()) {
         $this->cart->setUser($this->getDi()->user);
     }
     $this->cart->calculate();
     if (!$this->view->coupon_error && $this->getParam('do-checkout')) {
         return $this->checkoutAction();
     }
     $this->getDi()->blocks->remove('cart-basket');
     $this->view->b = $this->getParam('b', '');
     $this->view->display('cart/basket.phtml');
 }