public function index() { if (!$this->cart->contents()) { // checks if cart contents is empty $this->alert->set('alert', $this->lang->line('alert_no_menu_to_order')); redirect(restaurant_url()); // redirect to menus page and display error } if ($this->config->item('location_order') === '1' and !$this->location->hasSearchQuery()) { // else if local restaurant is not selected $this->alert->set('alert', $this->lang->line('alert_no_selected_local')); redirect(restaurant_url()); // redirect to menus page and display error } if (!$this->location->isOpened() and $this->config->item('future_orders') !== '1') { // else if local restaurant is not open $this->alert->set('alert', $this->lang->line('alert_location_closed')); redirect(restaurant_url()); // redirect to previous page and display error } if (!$this->location->hasDelivery() and !$this->location->hasCollection() and $this->config->item('location_order') === '1') { // else if local restaurant is not open $this->alert->set('alert', $this->lang->line('alert_order_unavailable')); redirect(restaurant_url()); // redirect to previous page and display error } if ($this->location->orderType() === '1' and !$this->location->checkMinimumOrder($this->cart->total())) { // checks if cart contents is empty redirect(restaurant_url()); // redirect to previous page and display error } if (!$this->customer->islogged() and $this->config->item('guest_order') !== '1') { // else if customer is not logged in $this->alert->set('alert', $this->lang->line('alert_customer_not_logged')); redirect('account/login'); // redirect to account register page and display error } if ($this->input->post() and $this->_validateCheckout() === TRUE) { // check if post data and validate checkout is successful redirect('checkout'); } $this->template->setBreadcrumb('<i class="fa fa-home"></i>', '/'); $this->template->setBreadcrumb($this->lang->line('text_heading'), 'checkout'); $this->template->setTitle($this->lang->line('text_heading')); $data['text_login_register'] = $this->customer->isLogged() ? sprintf($this->lang->line('text_logout'), $this->customer->getFirstName(), site_url('account/logout')) : sprintf($this->lang->line('text_registered'), site_url('account/login')); $order_data = $this->session->userdata('order_data'); $data['_action'] = site_url('checkout'); if (isset($order_data['order_id']) and isset($order_data['customer_id'])) { $this->load->model('Statuses_model'); $order_status_exists = $this->Statuses_model->statusExists('order', $order_data['order_id']); if ($order_data['customer_id'] !== $this->customer->getId() or $order_status_exists === TRUE) { $order_data = array(); $this->session->unset_userdata('order_data'); } } $data = $this->getFormData($order_data, $data); $this->template->render('checkout', $data); }
<?php echo get_header(); echo get_partial('content_top'); ?> <div class="wrap-all"> <div class="cart-buttons wrap-bottom"> <div class="center-block"> <a class="btn btn-default btn-block btn-md" href="<?php echo restaurant_url() . '/#local-menus'; ?> "><?php echo lang('button_go_back'); ?> </a> </div> <div class="clearfix"></div> </div> <?php echo $cart; ?> </div> <?php echo get_partial('content_bottom'); echo get_footer();
public function index() { if (!$this->cart->contents()) { // checks if cart contents is empty $this->alert->set('alert', $this->lang->line('alert_no_menu_to_order')); redirect(restaurant_url()); // redirect to menus page and display error } if ($this->config->item('location_order') === '1' and !$this->location->hasSearchQuery()) { // else if local restaurant is not selected $this->alert->set('alert', $this->lang->line('alert_no_selected_local')); redirect(restaurant_url()); // redirect to menus page and display error } if ($this->location->isClosed()) { // else if local restaurant is not open redirect(restaurant_url()); // redirect to previous page and display error } if (!$this->location->checkOrderType()) { redirect(restaurant_url()); // redirect to previous page and display error } if ($this->location->orderType() === '1' and !$this->location->checkMinimumOrder($this->cart->total())) { // checks if cart contents is empty redirect(restaurant_url()); // redirect to previous page and display error } $prepend = '?redirect=' . current_url(); if (!$this->customer->islogged() and $this->config->item('guest_order') !== '1') { // else if customer is not logged in $this->alert->set('alert', $this->lang->line('alert_customer_not_logged')); redirect('account/login' . $prepend); // redirect to account register page and display error } if ($this->input->post() and $this->_validateCheckout() === TRUE) { // check if post data and validate checkout is successful redirect('checkout'); } $this->template->setBreadcrumb('<i class="fa fa-home"></i>', '/'); $this->template->setBreadcrumb($this->lang->line('text_heading'), 'checkout'); $this->template->setTitle($this->lang->line('text_heading')); $this->template->setStyleTag(assets_url('js/datepicker/datepicker.css'), 'datepicker-css'); $this->template->setScriptTag(assets_url("js/datepicker/bootstrap-datepicker.js"), 'bootstrap-datepicker-js'); $this->template->setStyleTag(assets_url('js/datepicker/bootstrap-timepicker.css'), 'bootstrap-timepicker-css'); $this->template->setScriptTag(assets_url("js/datepicker/bootstrap-timepicker.js"), 'bootstrap-timepicker-js'); $data['text_login_register'] = $this->customer->isLogged() ? sprintf($this->lang->line('text_logout'), $this->customer->getFirstName(), site_url('account/logout' . $prepend)) : sprintf($this->lang->line('text_registered'), site_url('account/login' . $prepend)); $order_data = $this->session->userdata('order_data'); $data['_action'] = site_url('checkout'); if (isset($order_data['customer_id']) and isset($order_data['order_id'])) { $is_order_placed = $this->Orders_model->isOrderPlaced($order_data['order_id']); if ($is_order_placed === TRUE or !empty($order_data['customer_id']) and $order_data['customer_id'] !== $this->customer->getId()) { $order_data = array(); $this->session->unset_userdata('order_data'); } } if (isset($order_data['location_id']) and $order_data['location_id'] !== $this->location->getId()) { $order_data['checkout_step'] = 'one'; } if (isset($order_data['order_type']) and $order_data['order_type'] !== $this->location->orderType()) { $order_data['checkout_step'] = 'one'; } $data = $this->getFormData($order_data, $data); $this->template->render('checkout', $data); }