Пример #1
0
 public function checkout()
 {
     // set template and params
     if (!($this->template = $this->application->getTemplate())) {
         return $this->app->error->raiseError(500, JText::_('No template selected'));
     }
     $this->app->document->addScript('assets:js/formhandler.js');
     $step = $this->app->request->get('step', 'string', 'customer');
     $layout = 'checkout';
     $this->params = $this->application->getParams('site');
     // Initialize the Cash Register
     $CR = $this->app->cashregister->start();
     // Import Transfer Data
     if ($step != 'receipt') {
         $CR->import();
     }
     //Setup Page Variables
     $page = $CR->page;
     // $customer = $this->app->request->get('customer','array');
     // $CR->order->billing = $this->app->data->create($customer['billing']);
     // $CR->order->shipping = $this->app->data->create($customer['shipping']);
     switch ($step) {
         case 'customer':
             $page->title = 'Customer Information';
             $page->subtitle = 'Please enter your information below.';
             $page->id = $step;
             $page->inProgress = array($step);
             $page->addButton('print', '', 'Print', false)->addButton('back', '', 'Back', false)->addButton('proceed', 'payment', 'Proceed');
             break;
         case 'payment':
             $page->title = 'Payment Information';
             $page->subtitle = 'Please enter your payment information below.';
             $page->id = $step;
             $page->complete = array('customer');
             $page->inProgress = array($step);
             $page->addButton('print', '', '', false)->addButton('back', 'customer', 'Back')->addButton('proceed', 'confirm', 'Proceed');
             break;
         case 'confirm':
             $page->title = 'Order Confirmation';
             $page->subtitle = '<span class="uk-text-danger">Please make sure that your order is correct.</span>';
             $page->id = $step;
             $page->complete = array('customer', 'payment');
             $page->inProgress = array($step);
             $page->addButton('print', '', '', false)->addButton('back', 'payment', 'Back')->addButton('proceed', 'processPayment', 'Pay Now');
             break;
         case 'receipt':
             $page->title = 'Order Receipt';
             $page->subtitle = 'Thank you for your purchase.';
             $page->id = $step;
             $page->complete = array('customer', 'payment', 'confirm');
             $page->inProgress = array($step);
             $page->addButton('print', 'Print Receipt')->addButton('back', '', 'Back', false)->addButton('proceed', 'home', 'Return to Home Page');
             $this->app->document->addStyleSheet('assets:css/receipt.css');
             break;
         case 'home':
             JControllerLegacy::setRedirect('/');
             JControllerLegacy::Redirect();
             break;
         default:
             $page->title = 'Customer Information';
             $page->subtitle = 'Please enter your information below.';
             $page->id = 'customer';
             $page->inProgress = array('customer');
             $page->addButton('print', '', 'Print', false)->addButton('back', '', 'Back', false)->addButton('proceed', 'payment', 'Proceed');
     }
     $this->CashRegister = $CR;
     // display view
     $this->getView()->addTemplatePath($this->template->getPath())->setLayout($layout)->display();
 }