コード例 #1
0
ファイル: PaymentPresenter.php プロジェクト: shophp/shophp
 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:');
 }
コード例 #2
0
ファイル: CartPresenter.php プロジェクト: shophp/shophp
 public function createComponentCartForm()
 {
     $form = $this->cartFormFactory->create($this->currentCartService->getCurrentCart());
     $form->onSuccess[] = function (CartForm $form) {
         $this->recalculateCart($form);
     };
     return $form;
 }
コード例 #3
0
ファイル: BasePresenter.php プロジェクト: shophp/shophp
 protected function startup()
 {
     parent::startup();
     if (!$this->currentCartService->getCurrentCart()->hasItems()) {
         $this->flashMessage('Yout cart is empty.');
         $this->redirect(':Front:Home:Homepage:');
     }
 }
コード例 #4
0
ファイル: BasePresenter.php プロジェクト: shophp/shophp
 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;
 }
コード例 #5
0
ファイル: AddressPresenter.php プロジェクト: shophp/shophp
 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:');
     }
 }
コード例 #6
0
ファイル: ShipmentPresenter.php プロジェクト: shophp/shophp
 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:');
 }
コード例 #7
0
ファイル: ProductPresenter.php プロジェクト: shophp/shophp
 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');
     }
 }