private function createOrder(PaymentForm $form) { $values = $form->getValues(); $this->orderService->createFromCart($this->currentCartService->getCurrentCart(), PaymentType::createFromValue($values->paymentType)); $this->currentCartService->resetCurrentCart(); $this->redirect(':Front:Order:Order:'); }
public function createComponentCartForm() { $form = $this->cartFormFactory->create($this->currentCartService->getCurrentCart()); $form->onSuccess[] = function (CartForm $form) { $this->recalculateCart($form); }; return $form; }
protected function startup() { parent::startup(); if (!$this->currentCartService->getCurrentCart()->hasItems()) { $this->flashMessage('Yout cart is empty.'); $this->redirect(':Front:Home:Homepage:'); } }
public function beforeRender() { parent::beforeRender(); $this->template->categories = $this->categoryService->getRoot(); $this->template->currentCategory = $this->currentCategory; $this->template->cart = $this->currentCartService->getCurrentCart(); $this->template->user = $this->user; }
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:'); } }
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:'); }
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'); } }