Example #1
0
 public function actionDefault()
 {
     $this->lastOrder = $this->orderService->getLastOrder();
     if ($this->lastOrder === null) {
         $this->redirect(':Front:Home:Homepage:');
     }
 }
Example #2
0
 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:');
 }
Example #3
0
 private function addTypeControl()
 {
     $paymentItems = [];
     foreach (PaymentType::getValues() as $paymentType) {
         $paymentType = PaymentType::createFromValue($paymentType);
         if ($this->orderService->isPaymentTypeAvailable($paymentType)) {
             $paymentItems[$paymentType->getValue()] = $paymentType->getLabel();
         }
     }
     if (count($paymentItems) === 0) {
         throw new \Exception('No payment type available');
     }
     $this->addRadioList('paymentType', 'Payment', $paymentItems)->setRequired('Please choose payment type.')->setDefaultValue(PaymentType::CASH);
 }
Example #4
0
 public function actionDefault($page = 1)
 {
     if ($page < 1) {
         $this->redirect('this', ['page' => 1]);
     }
     $this->paginator = new Paginator();
     $this->paginator->setItemsPerPage(self::ORDERS_PER_PAGE);
     $this->paginator->setPage($page);
     $orders = $this->orderService->getAll($this->paginator->getItemsPerPage(), $this->paginator->getOffset());
     $this->paginator->setItemCount(count($orders));
     $orders = iterator_to_array($orders);
     if (count($orders) === 0 && $page > 1) {
         $this->redirect('this', ['page' => 1]);
     }
     $this->orders = $orders;
 }