Example #1
0
 private function updateAddress(AddressForm $form)
 {
     $values = $form->getValues();
     $this->currentCartService->getCurrentCart()->setAddress($values->address->name, $values->address->street, $values->address->city, $values->address->zip);
     if (!$form->hasErrors()) {
         $this->currentCartService->saveCurrentCart();
         $this->redirect(':Front:Order:Payment:');
     }
 }
Example #2
0
 private function updateShipment(ShipmentForm $form)
 {
     $values = $form->getValues();
     $shipmentOption = $form->getChosenShipment();
     if (isset($values->address)) {
         $this->cartService->createShipmentForCart($this->currentCartService->getCurrentCart(), $shipmentOption, $values->address->name, $values->address->street, $values->address->city, $values->address->zip);
     } else {
         $this->cartService->createShipmentForCart($this->currentCartService->getCurrentCart(), $shipmentOption);
     }
     $this->currentCartService->saveCurrentCart();
     $this->redirect(':Front:Order:Payment:');
 }
Example #3
0
 private function addProductToCart(BuyForm $form)
 {
     $values = $form->getValues();
     $item = new CartItem($this->product, $values->amount);
     $this->currentCartService->getCurrentCart()->addItem($item);
     if (!$form->hasErrors()) {
         $this->currentCartService->saveCurrentCart();
         if ($item->getAmount() > 1) {
             $this->flashMessage(sprintf('%dx %s was added to cart.', $item->getAmount(), $this->product->getName()));
         } else {
             $this->flashMessage(sprintf('%s was added to cart.', $this->product->getName()));
         }
         $this->redirect('this');
     }
 }
Example #4
0
 private function recalculateCart(CartForm $form)
 {
     $removeItemId = $form->getRemoveItemId();
     if ($removeItemId !== null) {
         $this->cartService->removeItemFromCart($this->cartService->getItemById($removeItemId));
     } else {
         $values = $form->getValues();
         foreach ($values->amount as $itemId => $amount) {
             $item = $this->cartService->getItemById($itemId);
             $item->setAmount($amount);
             $this->currentCartService->saveCurrentCart();
         }
     }
     $this->flashMessage('Cart has been recalculated.');
     $this->redirect('this');
 }