示例#1
0
 /**
  * Action Update Cart
  *
  * @return void
  */
 public function updateCartAction()
 {
     if ($this->request->hasArgument('quantities')) {
         $this->cart = $this->cartUtility->getCartFromSession($this->settings['cart'], $this->pluginSettings);
         $updateQuantities = $this->request->getArgument('quantities');
         if (is_array($updateQuantities)) {
             foreach ($updateQuantities as $productId => $quantity) {
                 $product = $this->cart->getProductById($productId);
                 if ($product) {
                     if (ctype_digit($quantity)) {
                         $quantity = intval($quantity);
                         $product->changeQuantity(intval($quantity));
                     } elseif (is_array($quantity)) {
                         $product->changeVariantsQuantity($quantity);
                     }
                 }
             }
             $this->cart->reCalc();
         }
         $this->updateService();
         $this->sessionHandler->writeToSession($this->cart, $this->settings['cart']['pid']);
     }
     $this->redirect('showCart');
 }