public function index()
 {
     //		$this->load->model('design/layout');
     $this->load->model('catalog/category');
     $this->load->model('catalog/product');
     $this->load->model('catalog/information');
     if (isset($this->request->get['route'])) {
         $route = $this->request->get['route'];
     } else {
         $route = 'common/home';
     }
     $layout_id = 0;
     if (substr($route, 0, 16) == 'product/category' && isset($this->request->get['path'])) {
         $path = explode('_', (string) $this->request->get['path']);
         $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));
     }
     if (substr($route, 0, 15) == 'product/product' && isset($this->request->get['product_id'])) {
         $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
     }
     if (substr($route, 0, 23) == 'information/information' && isset($this->request->get['information_id'])) {
         $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
     }
     if (!$layout_id) {
         $layout_id = \model\design\LayoutDAO::getInstance()->getLayout($route);
     }
     if (!$layout_id) {
         $layout_id = $this->config->get('config_layout_id');
     }
     $module_data = array();
     $this->load->model('setting/extension');
     $extensions = \model\setting\ExtensionDAO::getInstance()->getExtensions('module', true, false);
     foreach ($extensions as $extension) {
         $modules = $this->config->get($extension['code'] . '_module');
         if ($modules) {
             foreach ($modules as $module) {
                 if ($module['layout_id'] == $layout_id && $module['position'] == 'column_right' && $module['status']) {
                     $module_data[] = array('code' => $extension['code'], 'setting' => $module, 'sort_order' => $module['sort_order']);
                 }
             }
         }
     }
     $sort_order = array();
     foreach ($module_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $module_data);
     $this->data['modules'] = array();
     foreach ($module_data as $module) {
         $module = $this->getChild('module/' . $module['code'], $module['setting']);
         if ($module) {
             $this->data['modules'][] = $module;
         }
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/column_right.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/common/column_right.tpl';
     } else {
         $this->template = 'default/template/common/column_right.tpl';
     }
     $this->render();
 }
 /**
  * @param array $address
  * @return array
  * @throws \Exception
  */
 public function getShippingOptions($address)
 {
     $logging = new Log('shipping.log');
     $result = array();
     //        $logging->write(print_r($address, true));
     $modelSettingExtension = $this->getLoader()->model('setting/extension');
     /** @var ShippingMethodBase[] $shippingExtensions */
     $shippingExtensions = ExtensionDAO::getInstance()->getExtensions('shipping', true, true);
     foreach ($shippingExtensions as $shippingExtension) {
         $shippingMethods = $shippingExtension->getMethodData($address);
         if (is_array($shippingMethods)) {
             $result = array_merge($result, $shippingMethods);
         }
     }
     usort($result, function ($a, $b) {
         /** @var ShippingMethodBase $a */
         /** @var ShippingMethodBase $b */
         return strcmp($a['title'], $b['title']);
     });
     //        $logging->write(print_r($result, true));
     return $result;
 }
 public function index()
 {
     $this->load->language('total/paymentmethoddiscounts');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('setting/setting');
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->model_setting_setting->editSetting('paymentmethoddiscounts', $this->request->post);
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->url->link('extension/total', 'token=' . $this->session->data['token'], 'SSL'));
     }
     $this->data['heading_title'] = $this->language->get('heading_title');
     $this->data['text_enabled'] = $this->language->get('text_enabled');
     $this->data['text_disabled'] = $this->language->get('text_disabled');
     $this->data['text_none'] = $this->language->get('text_none');
     $this->data['text_ed'] = $this->language->get('text_ed');
     $this->data['text_percent'] = $this->language->get('text_percent');
     $this->data['entry_payment'] = $this->language->get('entry_payment');
     $this->data['entry_skidka'] = $this->language->get('entry_skidka');
     $this->data['entry_tax_class'] = $this->language->get('entry_tax_class');
     $this->data['entry_status'] = $this->language->get('entry_status');
     $this->data['entry_sort_order'] = $this->language->get('entry_sort_order');
     $this->data['entry_donate_me'] = $this->language->get('entry_donate_me');
     $this->data['button_save'] = $this->language->get('button_save');
     $this->data['button_cancel'] = $this->language->get('button_cancel');
     $this->data['button_add_discount'] = $this->language->get('button_add_discount');
     $this->data['button_remove'] = $this->language->get('button_remove');
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_total'), 'href' => $this->url->link('extension/total', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('total/paymentmethoddiscounts', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     $this->data['action'] = $this->url->link('total/paymentmethoddiscounts', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['cancel'] = $this->url->link('extension/total', 'token=' . $this->session->data['token'], 'SSL');
     if (isset($this->request->post['paymentmethoddiscounts_discount'])) {
         $this->data['paymentmethoddiscounts_discount'] = $this->request->post['paymentmethoddiscounts_discount'];
     } else {
         $this->data['paymentmethoddiscounts_discount'] = $this->config->get('paymentmethoddiscounts_discount');
     }
     if (!$this->data['paymentmethoddiscounts_discount']) {
         $this->data['paymentmethoddiscounts_discount'] = array();
     }
     if (isset($this->request->post['paymentmethoddiscounts_sort_order'])) {
         $this->data['paymentmethoddiscounts_sort_order'] = $this->request->post['paymentmethoddiscounts_sort_order'];
     } else {
         $this->data['paymentmethoddiscounts_sort_order'] = $this->config->get('paymentmethoddiscounts_sort_order');
     }
     if (isset($this->request->post['paymentmethoddiscounts_status'])) {
         $this->data['paymentmethoddiscounts_status'] = $this->request->post['paymentmethoddiscounts_status'];
     } else {
         $this->data['paymentmethoddiscounts_status'] = $this->config->get('paymentmethoddiscounts_status');
     }
     $this->load->model('localisation/tax_class');
     $this->data['tax_classes'] = $this->model_localisation_tax_class->getTaxClasses();
     $this->load->model('setting/extension');
     $extensions = \model\setting\ExtensionDAO::getInstance()->getExtensions('payment');
     $this->data['extensions'] = array();
     $files = glob(DIR_APPLICATION . 'controller/payment/*.php');
     if ($files) {
         foreach ($files as $file) {
             $extension = basename($file, '.php');
             $this->load->language('payment/' . $extension);
             $action = array();
             $text_link = $this->language->get('text_' . $extension);
             if ($text_link != 'text_' . $extension) {
                 $link = $this->language->get('text_' . $extension);
             } else {
                 $link = '';
             }
             if ($this->config->get($extension . '_status')) {
                 $this->data['extensions'][] = array('name' => $this->language->get('heading_title'), 'code' => $extension, 'sort_order' => $this->config->get($extension . '_sort_order'));
             }
         }
     }
     $this->template = 'total/paymentmethoddiscounts.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render());
 }
Beispiel #4
0
 /**
  * @param mixed $address
  * @return array
  * @throws Exception
  */
 private function buildPaymentMethodsList($address)
 {
     $json = [];
     if (!isset($this->session->data['payment_methods'])) {
         // Calculate Totals
         $total_data = array();
         $total = 0;
         $taxes = $this->cart->getTaxes();
         $this->load->model('setting/extension');
         $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('total');
         $sort_order = array();
         foreach ($results as $key => $value) {
             $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
         }
         array_multisort($sort_order, SORT_ASC, $results);
         foreach ($results as $result) {
             if ($this->config->get($result['code'] . '_status')) {
                 $this->load->model('total/' . $result['code']);
                 $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
             }
         }
         $paymentAmounts = $this->getPaymentDistribution($total);
         // Payment Methods
         $method_data = array();
         $this->load->model('setting/extension');
         $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('payment');
         foreach ($results as $result) {
             if ($this->config->get($result['code'] . '_status')) {
                 $this->load->model('payment/' . $result['code']);
                 $method = $this->{'model_payment_' . $result['code']}->getMethod($address, $total);
                 if ($method) {
                     $method_data[$result['code']] = $method;
                 }
             }
         }
         $sort_order = array();
         foreach ($method_data as $key => $value) {
             $sort_order[$key] = $value['sort_order'];
         }
         array_multisort($sort_order, SORT_ASC, $method_data);
         $this->session->data['payment_methods'] = $method_data;
     }
     $this->data['text_payment_method'] = $this->language->get('text_payment_method');
     $this->data['text_comments'] = $this->language->get('text_comments');
     $this->data['button_continue'] = $this->language->get('button_continue');
     if (isset($this->session->data['payment_methods']) && !$this->session->data['payment_methods']) {
         $this->data['error_warning'] = sprintf($this->language->get('error_no_payment'), $this->url->link('information/contact'));
     } else {
         $this->data['error_warning'] = '';
     }
     if (isset($this->session->data['payment_methods'])) {
         $this->data['payment_methods'] = $this->session->data['payment_methods'];
     } else {
         $this->data['payment_methods'] = array();
     }
     if (isset($this->session->data['payment_method']['code'])) {
         $this->data['code'] = $this->session->data['payment_method']['code'];
     } else {
         $this->data['code'] = '';
     }
     if (isset($this->session->data['comment'])) {
         $this->data['comment'] = $this->session->data['comment'];
     } else {
         $this->data['comment'] = '';
     }
     if ($this->config->get('config_checkout_id')) {
         $this->load->model('catalog/information');
         $information_info = $this->model_catalog_information->getInformation($this->config->get('config_checkout_id'));
         if ($information_info) {
             $this->data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/info', 'information_id=' . $this->config->get('config_checkout_id'), 'SSL'), $information_info['title'], $information_info['title']);
         } else {
             $this->data['text_agree'] = '';
         }
     } else {
         $this->data['text_agree'] = '';
     }
     if (isset($this->session->data['agree'])) {
         $this->data['agree'] = $this->session->data['agree'];
     } else {
         $this->data['agree'] = '';
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/payment.tpl.php')) {
         $this->template = $this->config->get('config_template') . '/template/checkout/payment.tpl.php';
     } else {
         $this->template = 'default/template/checkout/payment.tpl.php';
     }
     $json['output'] = $this->render();
     return $json;
 }
Beispiel #5
0
 public function getTotals(&$total_data, &$total, &$taxes, $orderId = null, $chosenOnes = false)
 {
     $this->load->model('setting/extension');
     $sort_order = array();
     $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('total');
     foreach ($results as $key => $value) {
         $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
     }
     array_multisort($sort_order, SORT_ASC, $results);
     foreach ($results as $result) {
         if ($this->config->get($result['code'] . '_status')) {
             $this->load->model('total/' . $result['code']);
             if ($orderId) {
                 $this->{'model_total_' . $result['code']}->getOrderTotal($total_data, $total, $taxes, $orderId, $chosenOnes);
             } else {
                 $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes, $chosenOnes);
             }
         }
     }
     $sort_order = array();
     foreach ($total_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $total_data);
 }
Beispiel #6
0
 public function index()
 {
     $this->load_language('module/simple');
     $this->document->setTitle($this->language->get('heading_title'));
     $this->load->model('setting/setting');
     $this->load->model('setting/store');
     $this->data['stores'] = $this->model_setting_store->getStores();
     $this->data['stores'][] = array('store_id' => 0, 'name' => 'default');
     if (isset($this->request->get['store_id'])) {
         $this->data['store_id'] = $this->request->get['store_id'];
     } else {
         $this->data['store_id'] = 0;
     }
     $this->load->model('sale/customer_group');
     $this->data['groups'] = $this->model_sale_customer_group->getCustomerGroups();
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate()) {
         $this->create_tables();
         if (is_uploaded_file($this->request->files['import']['tmp_name'])) {
             $content = file_get_contents($this->request->files['import']['tmp_name']);
             $tmp = unserialize(base64_decode($content));
             if (is_array($tmp)) {
                 $this->request->post = $tmp;
             }
         }
         foreach ($this->data['groups'] as $group) {
             if (isset($this->request->post['simple_set_checkout_customer']['shipping'][$group['customer_group_id']]) && is_array($this->request->post['simple_set_checkout_customer']['shipping'][$group['customer_group_id']])) {
                 $tmp = array();
                 foreach ($this->request->post['simple_set_checkout_customer']['shipping'][$group['customer_group_id']] as $key => $value) {
                     $tmp[str_replace('_101_', '.', $key)] = $value;
                 }
                 $this->request->post['simple_set_checkout_customer']['shipping'][$group['customer_group_id']] = $tmp;
             }
             if (isset($this->request->post['simple_set_checkout_address']['shipping'][$group['customer_group_id']]) && is_array($this->request->post['simple_set_checkout_address']['shipping'][$group['customer_group_id']])) {
                 $tmp = array();
                 foreach ($this->request->post['simple_set_checkout_address']['shipping'][$group['customer_group_id']] as $key => $value) {
                     $tmp[str_replace('_101_', '.', $key)] = $value;
                 }
                 $this->request->post['simple_set_checkout_address']['shipping'][$group['customer_group_id']] = $tmp;
             }
         }
         $simple_common_template = $this->request->post['simple_common_template'];
         $simple_common_template = str_replace(' ', '', $simple_common_template);
         $find = array('{cart}', '{shipping}', '{payment}', '{agreement}', '{help}', '{payment_form}');
         $replace = array('{cart}' => '', '{shipping}' => '', '{payment}' => '', '{agreement}' => '', '{help}' => '', '{payment_form}' => '');
         $simple_common_template = trim(str_replace($find, $replace, $simple_common_template));
         $simple_common_template = preg_replace('/\\[\\[[-_a-zA-Z0-9.]+\\]\\]/si', '', $simple_common_template);
         $find = array('{left_column}{/left_column}', '{right_column}{/right_column}');
         $replace = array('{left_column}{/left_column}' => '', '{right_column}{/right_column}' => '');
         $simple_common_template = trim(str_replace($find, $replace, $simple_common_template));
         if ($simple_common_template == '{customer}') {
             $this->request->post['simple_customer_two_column'] = true;
         } else {
             $this->request->post['simple_customer_two_column'] = false;
         }
         $this->model_setting_setting->editSetting('simple', $this->request->post, $this->data['store_id']);
         $this->session->data['success'] = $this->language->get('text_success');
         $this->redirect($this->url->link('module/simple', 'token=' . $this->session->data['token'] . '&store_id=' . $this->data['store_id'], 'SSL'));
     }
     $this->data['heading_title'] = $this->language->get('heading_title');
     if (isset($this->session->data['success'])) {
         $this->data['success'] = $this->session->data['success'];
         unset($this->session->data['success']);
     } else {
         $this->data['success'] = '';
     }
     $this->data['breadcrumbs'] = array();
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_home'), 'href' => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => false);
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('text_module'), 'href' => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     $this->data['breadcrumbs'][] = array('text' => $this->language->get('heading_title'), 'href' => $this->url->link('module/simple', 'token=' . $this->session->data['token'], 'SSL'), 'separator' => ' :: ');
     $this->data['button_save'] = $this->language->get('button_save');
     $this->data['button_cancel'] = $this->language->get('button_cancel');
     $this->data['button_restore'] = $this->language->get('button_restore');
     $this->data['action_without_store'] = $this->url->link('module/simple', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['action'] = $this->url->link('module/simple', 'token=' . $this->session->data['token'] . '&store_id=' . $this->data['store_id'], 'SSL');
     $this->data['backup_link'] = $this->url->link('module/simple/backup', 'token=' . $this->session->data['token'] . '&store_id=' . $this->data['store_id'], 'SSL');
     $this->data['restore_link'] = $this->url->link('module/simple/restore', 'token=' . $this->session->data['token'] . '&store_id=' . $this->data['store_id'], 'SSL');
     $this->data['header_save_link'] = $this->url->link('module/simple/header', 'token=' . $this->session->data['token'] . '&store_id=' . $this->data['store_id'], 'SSL');
     $this->data['footer_save_link'] = $this->url->link('module/simple/footer', 'token=' . $this->session->data['token'] . '&store_id=' . $this->data['store_id'], 'SSL');
     $this->data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
     $this->data['token'] = $this->session->data['token'];
     $this->data['tab_checkout'] = $this->language->get('tab_checkout');
     $this->data['tab_customer_fields'] = $this->language->get('tab_customer_fields');
     $this->data['tab_registration'] = $this->language->get('tab_registration');
     $this->data['tab_account_pages'] = $this->language->get('tab_account_pages');
     $this->data['tab_backup'] = $this->language->get('tab_backup');
     $this->data['tab_headers'] = $this->language->get('tab_headers');
     $this->data['tab_methods'] = $this->language->get('tab_methods');
     $this->data['tab_template_helper'] = $this->language->get('tab_template_helper');
     $this->data['text_yes'] = $this->language->get('text_yes');
     $this->data['text_no'] = $this->language->get('text_no');
     $this->data['text_module_links'] = $this->language->get('text_module_links');
     $this->data['text_module_links_2'] = $this->language->get('text_module_links_2');
     $this->data['entry_payment_module'] = $this->language->get('entry_payment_module');
     $this->data['entry_shipping_modules'] = $this->language->get('entry_shipping_modules');
     $this->data['entry_payment_modules'] = $this->language->get('entry_payment_modules');
     $this->data['entry_shipping_module'] = $this->language->get('entry_shipping_module');
     $this->data['text_select_shipping'] = $this->language->get('text_select_shipping');
     $this->data['entry_template'] = $this->language->get('entry_template');
     $this->data['entry_template_description'] = $this->language->get('entry_template_description');
     $this->data['text_simplecheckout'] = $this->language->get('text_simplecheckout');
     $this->data['text_agreement_block'] = $this->language->get('text_agreement_block');
     $this->data['entry_agreement_id'] = $this->language->get('entry_agreement_id');
     $this->data['entry_agreement_text'] = $this->language->get('entry_agreement_text');
     $this->data['entry_agreement_checkbox'] = $this->language->get('entry_agreement_checkbox');
     $this->data['entry_agreement_checkbox_init'] = $this->language->get('entry_agreement_checkbox_init');
     $this->data['text_shipping_block'] = $this->language->get('text_shipping_block');
     $this->data['entry_shipping_title'] = $this->language->get('text_shipping_title');
     $this->data['entry_shipping_address_empty'] = $this->language->get('entry_shipping_address_empty');
     $this->data['text_payment_block'] = $this->language->get('text_payment_block');
     $this->data['entry_payment_address_empty'] = $this->language->get('entry_payment_address_empty');
     $this->data['text_customer_block'] = $this->language->get('text_customer_block');
     $this->data['entry_customer_register'] = $this->language->get('entry_customer_register');
     $this->data['text_user_choice'] = $this->language->get('text_user_choice');
     $this->data['entry_customer_login'] = $this->language->get('entry_customer_login');
     $this->data['entry_customer_type'] = $this->language->get('entry_customer_type');
     $this->data['entry_customer_type_selection'] = $this->language->get('entry_customer_type_selection');
     $this->data['entry_customer_group_after_reg'] = $this->language->get('entry_customer_group_after_reg');
     $this->data['entry_customer_register_init'] = $this->language->get('entry_customer_register_init');
     $this->data['entry_customer_address_select'] = $this->language->get('entry_customer_address_select');
     $this->data['text_registration_page'] = $this->language->get('text_registration_page');
     $this->data['entry_registration_agreement_id'] = $this->language->get('entry_registration_agreement_id');
     $this->data['entry_registration_agreement_checkbox'] = $this->language->get('entry_registration_agreement_checkbox');
     $this->data['entry_registration_agreement_checkbox_init'] = $this->language->get('entry_registration_agreement_checkbox_init');
     $this->data['entry_registration_captcha'] = $this->language->get('entry_registration_captcha');
     $this->data['text_fields_default'] = $this->language->get('text_fields_default');
     $this->data['entry_field_id'] = $this->language->get('entry_field_id');
     $this->data['entry_field_label'] = $this->language->get('entry_field_label');
     $this->data['entry_field_type'] = $this->language->get('entry_field_type');
     $this->data['entry_field_init'] = $this->language->get('entry_field_init');
     $this->data['entry_field_values'] = $this->language->get('entry_field_values');
     $this->data['entry_field_validation'] = $this->language->get('entry_field_validation');
     $this->data['entry_field_save_to'] = $this->language->get('entry_field_save_to');
     $this->data['entry_shipping_address_full'] = $this->language->get('entry_shipping_address_full');
     $this->data['entry_payment_address_full'] = $this->language->get('entry_payment_address_full');
     $this->data['entry_shipping_address_full_description'] = $this->language->get('entry_shipping_address_full_description');
     $this->data['entry_payment_address_full_description'] = $this->language->get('entry_payment_address_full_description');
     $this->data['text_validation_none'] = $this->language->get('text_validation_none');
     $this->data['text_validation_length'] = $this->language->get('text_validation_length');
     $this->data['text_validation_regexp'] = $this->language->get('text_validation_regexp');
     $this->data['text_validation_values'] = $this->language->get('text_validation_values');
     $this->data['text_validation_not_null'] = $this->language->get('text_validation_not_null');
     $this->data['entry_field_validation_error'] = $this->language->get('entry_field_validation_error');
     $this->data['text_select'] = $this->language->get('text_select');
     $this->data['entry_customer_subscribe'] = $this->language->get('entry_customer_subscribe');
     $this->data['entry_customer_subscribe_init'] = $this->language->get('entry_customer_subscribe_init');
     $this->data['text_add_field'] = $this->language->get('text_add_field');
     $this->data['button_add'] = $this->language->get('button_add');
     $this->data['button_delete'] = $this->language->get('button_delete');
     $this->data['entry_customer_password_confirm'] = $this->language->get('entry_customer_password_confirm');
     $this->data['entry_geoip_init'] = $this->language->get('entry_geoip_init');
     $this->data['entry_shipping_module'] = $this->language->get('entry_shipping_module');
     $this->data['entry_customer_fields'] = $this->language->get('entry_customer_fields');
     $this->data['entry_password_length'] = $this->language->get('entry_password_length');
     $this->data['entry_customer_email_field'] = $this->language->get('entry_customer_email_field');
     $this->data['text_hide'] = $this->language->get('text_hide');
     $this->data['text_show_not_required'] = $this->language->get('text_show_not_required');
     $this->data['text_required'] = $this->language->get('text_required');
     $this->data['text_validation_function'] = $this->language->get('text_validation_function');
     $this->data['entry_payment_autoselect_first'] = $this->language->get('entry_payment_autoselect_first');
     $this->data['entry_shipping_autoselect_first'] = $this->language->get('entry_shipping_autoselect_first');
     $this->data['entry_jquery_masked_input_mask'] = $this->language->get('entry_jquery_masked_input_mask');
     $this->data['entry_city_autocomplete'] = $this->language->get('entry_city_autocomplete');
     $this->data['entry_generate_password'] = $this->language->get('entry_generate_password');
     $this->data['entry_placeholder'] = $this->language->get('entry_placeholder');
     $this->data['entry_save_label'] = $this->language->get('entry_save_label');
     $this->data['text_order_minmax'] = $this->language->get('text_order_minmax');
     $this->data['entry_use_total'] = $this->language->get('entry_use_total');
     $this->data['entry_min_amount'] = $this->language->get('entry_min_amount');
     $this->data['entry_max_amount'] = $this->language->get('entry_max_amount');
     $this->data['entry_min_quantity'] = $this->language->get('entry_min_quantity');
     $this->data['entry_max_quantity'] = $this->language->get('entry_max_quantity');
     $this->data['entry_min_weight'] = $this->language->get('entry_min_weight');
     $this->data['entry_max_weight'] = $this->language->get('entry_max_weight');
     $this->data['entry_payment_method'] = $this->language->get('entry_payment_method');
     $this->data['text_shipping_address_block'] = $this->language->get('text_shipping_address_block');
     $this->data['entry_shipping_address_select'] = $this->language->get('entry_shipping_address_select');
     $this->data['entry_shipping_address_show'] = $this->language->get('entry_shipping_address_show');
     $this->data['entry_shipping_address_same_init'] = $this->language->get('entry_shipping_address_same_init');
     $this->data['entry_shipping_address_same_show'] = $this->language->get('entry_shipping_address_same_show');
     $this->data['entry_shipping_address_fields'] = $this->language->get('entry_shipping_address_fields');
     $this->data['entry_help_text'] = $this->language->get('entry_help_text');
     $this->data['entry_help_id'] = $this->language->get('entry_help_id');
     $this->data['text_help_block'] = $this->language->get('text_help_block');
     $this->data['entry_hide'] = $this->language->get('entry_hide');
     $this->data['entry_hide_if_logged'] = $this->language->get('entry_hide_if_logged');
     $this->data['entry_empty_email'] = $this->language->get('entry_empty_email');
     $this->data['entry_show_weight'] = $this->language->get('entry_show_weight');
     $this->data['entry_fields_for_reload'] = $this->language->get('entry_fields_for_reload');
     $this->data['entry_use_cookies'] = $this->language->get('entry_use_cookies');
     $this->data['entry_show_will_be_registerd'] = $this->language->get('entry_show_will_be_registerd');
     $this->data['entry_guest_checkout'] = $this->language->get('entry_guest_checkout');
     $this->data['entry_field_object'] = $this->language->get('entry_field_object');
     $this->data['text_account_info_page'] = $this->language->get('text_account_info_page');
     $this->data['text_account_address_page'] = $this->language->get('text_account_address_page');
     $this->data['text_restore'] = $this->language->get('text_restore');
     $this->data['text_checkout_asap_logged'] = $this->language->get('text_checkout_asap_logged');
     $this->data['text_checkout_asap_not_logged'] = $this->language->get('text_checkout_asap_not_logged');
     $this->data['text_no_only_after_click'] = $this->language->get('text_no_only_after_click');
     $this->data['text_payment_options_for_groups'] = $this->language->get('text_payment_options_for_groups');
     $this->data['text_shipping_options_for_groups'] = $this->language->get('text_shipping_options_for_groups');
     $this->data['entry_googleapi'] = $this->language->get('entry_googleapi');
     $this->data['entry_googleapi_key'] = $this->language->get('entry_googleapi_key');
     $this->data['entry_googleapi_language'] = $this->language->get('entry_googleapi_language');
     $this->data['entry_confirm_email'] = $this->language->get('entry_confirm_email');
     $this->data['entry_field_place'] = $this->language->get('entry_field_place');
     $this->data['entry_field_object_field'] = $this->language->get('entry_field_object_field');
     $this->data['entry_steps'] = $this->language->get('entry_steps');
     $this->data['entry_steps_summary'] = $this->language->get('entry_steps_summary');
     $this->data['entry_comment_target'] = $this->language->get('entry_comment_target');
     $this->data['entry_minify'] = $this->language->get('entry_minify');
     $this->data['entry_stub_not_show'] = $this->language->get('entry_stub_not_show');
     $this->data['entry_stub_show_always'] = $this->language->get('entry_stub_show_always');
     $this->data['entry_stub_show_only_for_empty'] = $this->language->get('entry_stub_show_only_for_empty');
     $this->data['entry_stub_use_description'] = $this->language->get('entry_stub_use_description');
     $this->data['text_stub_description'] = $this->language->get('text_stub_description');
     $this->data['text_template_1'] = $this->language->get('text_template_1');
     $this->data['text_template_2'] = $this->language->get('text_template_2');
     $this->data['text_template_3'] = $this->language->get('text_template_3');
     $this->data['text_template_4'] = $this->language->get('text_template_4');
     $this->data['text_help_move_field'] = $this->language->get('text_help_move_field');
     $this->data['entry_tag_for_headers'] = $this->language->get('entry_tag_for_headers');
     $this->data['entry_only_business_days'] = $this->language->get('entry_only_business_days');
     $this->data['entry_only_for_days'] = $this->language->get('entry_only_for_days');
     $this->data['entry_min_date'] = $this->language->get('entry_min_date');
     $this->data['entry_max_date'] = $this->language->get('entry_max_date');
     $this->data['entry_start_date'] = $this->language->get('entry_start_date');
     $this->data['entry_end_date'] = $this->language->get('entry_end_date');
     $this->data['text_drag_n_drop'] = $this->language->get('text_drag_n_drop');
     $this->data['entry_debug_mode'] = $this->language->get('entry_debug_mode');
     $this->data['entry_show_button_back'] = $this->language->get('entry_show_button_back');
     $this->data['entry_geoip_mode'] = $this->language->get('entry_geoip_mode');
     $this->data['text_examples'] = $this->language->get('text_examples');
     $this->data['text_example_two_columns'] = $this->language->get('text_example_two_columns');
     $this->data['text_example_one_column'] = $this->language->get('text_example_one_column');
     $this->data['text_example_combined'] = $this->language->get('text_example_combined');
     $this->data['text_example_three_columns'] = $this->language->get('text_example_three_columns');
     $this->data['text_geoip_mode_1'] = $this->language->get('text_geoip_mode_1');
     $this->data['text_geoip_mode_2'] = $this->language->get('text_geoip_mode_2');
     $this->data['text_geoip_mode_3'] = $this->language->get('text_geoip_mode_3');
     $this->data['text_example'] = $this->language->get('text_example');
     $this->data['text_example_for_links'] = $this->language->get('text_example_for_links');
     $this->data['entry_use_geo_selector'] = $this->language->get('entry_use_geo_selector');
     $this->data['entry_geo_selector_type'] = $this->language->get('entry_geo_selector_type');
     $this->data['text_geo_selector_type_1'] = $this->language->get('text_geo_selector_type_1');
     $this->data['text_geo_selector_type_2'] = $this->language->get('text_geo_selector_type_2');
     $this->data['text_geo_selector_type_3'] = $this->language->get('text_geo_selector_type_3');
     $this->data['text_help_geo_selector'] = $this->language->get('text_help_geo_selector');
     $this->data['entry_type_of_links'] = $this->language->get('entry_type_of_links');
     $this->data['text_payment_shipping'] = $this->language->get('text_payment_shipping');
     $this->data['text_shipping_payment'] = $this->language->get('text_shipping_payment');
     $this->init_field('simple_links', array());
     $this->init_field('simple_links_2', array());
     $this->init_field('simple_common_template', '{left_column}{cart}{customer}{/left_column}{right_column}{shipping}{payment}{agreement}{/right_column}');
     $this->init_field('simple_common_view_agreement_id');
     $this->init_field('simple_common_view_agreement_text');
     $this->init_field('simple_common_view_agreement_checkbox');
     $this->init_field('simple_common_view_agreement_checkbox_init');
     $this->init_field('simple_shipping_view_title');
     $this->init_field('simple_shipping_view_address_empty');
     $this->init_field('simple_payment_view_address_empty');
     $this->init_field('simple_payment_view_autoselect_first');
     $this->init_field('simple_shipping_view_autoselect_first');
     $this->init_field('simple_customer_action_register');
     $this->init_field('simple_customer_view_login');
     $this->init_field('simple_customer_view_customer_type');
     $this->init_field('simple_customer_view_customer_register_init');
     $this->init_field('simple_customer_view_address_select');
     $this->init_field('simple_registration_agreement_id');
     $this->init_field('simple_registration_agreement_checkbox');
     $this->init_field('simple_registration_agreement_checkbox_init');
     $this->init_field('simple_registration_captcha');
     $this->init_field('simple_shipping_view_address_full', array());
     $this->init_field('simple_payment_view_address_full', array());
     $this->init_field('simple_customer_action_subscribe');
     $this->init_field('simple_customer_view_customer_subscribe_init');
     $this->init_field('simple_registration_subscribe');
     $this->init_field('simple_registration_subscribe_init');
     $this->init_field('simple_customer_view_password_confirm');
     $this->init_field('simple_customer_view_password_length_min');
     $this->init_field('simple_customer_view_password_length_max');
     $this->init_field('simple_registration_password_confirm');
     $this->init_field('simple_registration_password_length_min');
     $this->init_field('simple_registration_password_length_max');
     $this->init_field('simple_registration_view_customer_type');
     $this->init_field('simple_set_checkout_customer');
     $this->init_field('simple_set_checkout_address');
     $this->init_field('simple_set_registration');
     $this->init_field('simple_set_account_info');
     $this->init_field('simple_set_account_address');
     $this->init_field('simple_customer_view_email');
     $this->init_field('simple_customer_view_email_confirm');
     $this->init_field('simple_customer_generate_password');
     $this->init_field('simple_registration_generate_password');
     $this->init_field('simple_registration_view_email_confirm');
     $this->init_field('simple_show_shipping_address');
     $this->init_field('simple_show_shipping_address_same_init', 1);
     $this->init_field('simple_show_shipping_address_same_show', 1);
     $this->init_field('simple_shipping_view_address_select');
     $this->init_field('simple_use_total');
     $this->init_field('simple_min_amount');
     $this->init_field('simple_max_amount');
     $this->init_field('simple_min_quantity');
     $this->init_field('simple_max_quantity');
     $this->init_field('simple_min_weight');
     $this->init_field('simple_max_weight');
     $this->init_field('simple_debug');
     $this->init_field('simple_common_view_help_id');
     $this->init_field('simple_common_view_help_text');
     $this->init_field('simple_joomla_path');
     $this->init_field('simple_joomla_route');
     $this->init_field('simple_shipping_methods_hide');
     $this->init_field('simple_payment_methods_hide');
     $this->init_field('simple_customer_hide_if_logged');
     $this->init_field('simple_address_hide_if_logged');
     $this->init_field('simple_empty_email');
     $this->init_field('simple_show_weight');
     $this->init_field('simple_set_for_reload');
     $this->init_field('simple_use_cookies');
     $this->init_field('simple_show_will_be_registered');
     $this->init_field('simple_disable_guest_checkout');
     $this->init_field('simple_checkout_asap_for_not_logged');
     $this->init_field('simple_checkout_asap_for_logged');
     $this->init_field('simple_group_shipping');
     $this->init_field('simple_group_payment');
     $this->init_field('simple_account_view_customer_type');
     $this->init_field('simple_headers', array());
     $this->init_field('simple_header_tag', 'h3');
     $this->init_field('simple_geoip_mode', '1');
     $this->init_field('simple_googleapi');
     $this->init_field('simple_googleapi_key');
     $this->init_field('simple_show_back');
     $this->init_field('simple_shipping_titles', array());
     $this->init_field('simple_payment_titles', array());
     $this->init_field('simple_type_of_selection_of_group', 'radio');
     $this->init_field('simple_customer_group_id_after_reg', $this->config->get('config_customer_group_id'));
     $this->init_field('simple_steps');
     $this->init_field('simple_steps_summary');
     $this->init_field('simple_comment_target');
     $this->init_field('simple_minify', 0);
     $this->init_field('simple_customer_use_geo_selector', 0);
     $this->init_field('simple_customer_geo_selector_type', 1);
     $this->init_field('simple_shipping_address_use_geo_selector', 0);
     $this->init_field('simple_shipping_address_geo_selector_type', 1);
     $this->init_field('simple_childs_payment_first', 0);
     // fix
     $this->data['tab_methods'] = $this->data['tab_methods'] == 'tab_methods' ? 'Stubs for methods' : $this->data['tab_methods'];
     $this->load->model('setting/extension');
     $fields_for_autoreloading_needed = false;
     $payment_extensions = \model\setting\ExtensionDAO::getInstance()->getExtensions('payment');
     $tmp = array();
     foreach ($payment_extensions as $extension) {
         if ($this->config->get($extension['code'] . '_status')) {
             $tmp[] = $extension;
         }
         if ($this->config->get($extension['code'] . '_geo_zone_id')) {
             $fields_for_autoreloading_needed = true;
         }
     }
     $payment_extensions = $tmp;
     $this->data['payment_extensions'] = array();
     $files = glob(DIR_APPLICATION . 'controller/payment/*.php');
     if ($files) {
         foreach ($files as $file) {
             $extension = basename($file, '.php');
             if (in_array($extension, $payment_extensions)) {
                 $this->load_language('payment/' . $extension);
                 $this->data['payment_extensions'][$extension] = $this->language->get('heading_title');
             }
         }
     }
     $shipping_extensions = \model\setting\ExtensionDAO::getInstance()->getExtensions('shipping');
     $tmp = array();
     foreach ($shipping_extensions as $extension) {
         if ($this->config->get($extension['code'] . '_status')) {
             $tmp[] = $extension;
         }
         if ($this->config->get($extension['code'] . '_geo_zone_id')) {
             $fields_for_autoreloading_needed = true;
         }
     }
     $shipping_extensions = $tmp;
     $this->data['shipping_extensions'] = array();
     $files = glob(DIR_APPLICATION . 'controller/shipping/*.php');
     if ($files) {
         foreach ($files as $file) {
             $extension = basename($file, '.php');
             if (in_array($extension, $shipping_extensions)) {
                 $this->load_language('shipping/' . $extension);
                 $this->data['shipping_extensions'][$extension] = $this->language->get('heading_title');
             }
         }
     }
     $this->data['shipping_extensions_2'] = $this->data['shipping_extensions'];
     foreach ($this->data['simple_links_2'] as $key => $value) {
         if (!isset($this->data['shipping_extensions_2'][$key])) {
             $tmp = explode('.', $key);
             $text = $key;
             if (isset($tmp[0]) && !empty($this->data['shipping_extensions'][$tmp[0]])) {
                 $text = $this->data['shipping_extensions'][$tmp[0]] . ' (' . $key . ')';
             }
             $this->data['shipping_extensions_2'][$key] = $text;
         }
     }
     if (!$fields_for_autoreloading_needed) {
         //    $this->data['simple_set_for_reload'] = '';
     }
     $shipping_codes = array_keys($this->data['shipping_extensions']);
     $customer_group_id = $this->config->get('config_customer_group_id');
     $this->data['shipping_extensions_for_customer'] = array_diff(isset($this->data['simple_set_checkout_customer']['shipping'][$customer_group_id]) ? array_keys($this->data['simple_set_checkout_customer']['shipping'][$customer_group_id]) : array(), $shipping_codes);
     $this->data['shipping_extensions_for_shipping_address'] = array_diff(isset($this->data['simple_set_checkout_address']['shipping'][$customer_group_id]) ? array_keys($this->data['simple_set_checkout_address']['shipping'][$customer_group_id]) : array(), $shipping_codes);
     $this->load->model('localisation/language');
     $languages = $this->model_localisation_language->getLanguages();
     $this->data['languages'] = array();
     foreach ($languages as $language) {
         $language['code'] = str_replace('-', '_', strtolower($language['code']));
         $this->data['languages'][] = $language;
     }
     $current_language = strtolower($this->config->get('config_admin_language'));
     $this->data['current_language'] = $current_language;
     $this->load->model('catalog/information');
     $this->data['informations'] = $this->model_catalog_information->getInformations();
     $this->init_field('simple_fields_main', array());
     $this->init_field('simple_fields_custom', array());
     $this->data['simple_fields_all'] = $this->data['simple_fields_main'] + $this->data['simple_fields_custom'];
     $address_fields = array('main_firstname', 'main_lastname', 'main_company', 'main_company_id', 'main_tax_id', 'main_address_1', 'main_address_2', 'main_city', 'main_postcode', 'main_zone_id', 'main_country_id');
     $account_info_fields = array('main_email', 'main_firstname', 'main_lastname', 'main_fax', 'main_telephone');
     $this->data['simple_fields_for_checkout_customer'] = array();
     $this->data['simple_fields_for_checkout_shipping_address'] = array();
     $this->data['simple_fields_for_registration'] = array();
     $this->data['simple_fields_for_account_info'] = array();
     $this->data['simple_fields_for_account_address'] = array();
     foreach ($this->data['simple_fields_main'] as $settings) {
         $key = $settings['id'];
         $text = !empty($settings['label'][$current_language]) ? $settings['label'][$current_language] : $key;
         $this->data['simple_fields_for_checkout_customer'][$key] = $text;
         if (in_array($key, $address_fields)) {
             $this->data['simple_fields_for_checkout_shipping_address'][$key] = $text;
         }
         if (in_array($key, $address_fields) || in_array($key, $account_info_fields)) {
             $this->data['simple_fields_for_registration'][$key] = $text;
         }
         if (in_array($key, $account_info_fields)) {
             $this->data['simple_fields_for_account_info'][$key] = $text;
         }
         if (in_array($key, $address_fields)) {
             $this->data['simple_fields_for_account_address'][$key] = $text;
         }
     }
     $headers = array();
     foreach ($this->data['simple_headers'] as $settings) {
         $key = $settings['id'];
         $text = !empty($settings['label'][$current_language]) ? $settings['label'][$current_language] : $key;
         $headers[$key] = $text;
     }
     foreach ($this->data['simple_fields_custom'] as $settings) {
         $key = $settings['id'];
         $text = !empty($settings['label'][$current_language]) ? $settings['label'][$current_language] : $key;
         $this->data['simple_fields_for_checkout_customer'][$key] = $text;
         if ($settings['object_type'] == 'address' || $settings['object_type'] == 'order') {
             $this->data['simple_fields_for_checkout_shipping_address'][$key] = $text;
         }
         if ($settings['object_type'] == 'address' || $settings['object_type'] == 'customer') {
             $this->data['simple_fields_for_registration'][$key] = $text;
         }
         if ($settings['object_type'] == 'customer') {
             $this->data['simple_fields_for_account_info'][$key] = $text;
         }
         if ($settings['object_type'] == 'address') {
             $this->data['simple_fields_for_account_address'][$key] = $text;
         }
     }
     $this->data['simple_fields_for_registration'] += $headers;
     $this->data['simple_fields_for_checkout_customer'] += $headers + array('split_split' => '<-- ' . $this->language->get('text_splitter') . ' -->');
     $this->data['simple_fields_for_checkout_shipping_address'] += $headers + array('split_split' => '<-- ' . $this->language->get('text_splitter') . ' -->');
     $this->data['simple_fields_for_account_info'] += $headers;
     $this->data['simple_fields_for_account_address'] += $headers;
     foreach ($this->data['groups'] as $group) {
         if (empty($this->data['simple_set_checkout_customer']['group'][$group['customer_group_id']]) && !empty($this->data['simple_set_checkout_customer']['group'][1])) {
             $this->data['simple_set_checkout_customer']['group'][$group['customer_group_id']] = $this->data['simple_set_checkout_customer']['group'][1];
         }
         if (empty($this->data['simple_set_checkout_address']['group'][$group['customer_group_id']]) && !empty($this->data['simple_set_checkout_address']['group'][1])) {
             $this->data['simple_set_checkout_address']['group'][$group['customer_group_id']] = $this->data['simple_set_checkout_address']['group'][1];
         }
         if (empty($this->data['simple_set_registration']['group'][$group['customer_group_id']]) && !empty($this->data['simple_set_registration']['group'][1])) {
             $this->data['simple_set_registration']['group'][$group['customer_group_id']] = $this->data['simple_set_registration']['group'][1];
         }
         if (empty($this->data['simple_set_account_info']['group'][$group['customer_group_id']]) && !empty($this->data['simple_set_account_info']['group'][1])) {
             $this->data['simple_set_account_info']['group'][$group['customer_group_id']] = $this->data['simple_set_account_info']['group'][1];
         }
         if (empty($this->data['simple_set_account_address']['group'][$group['customer_group_id']]) && !empty($this->data['simple_set_account_address']['group'][1])) {
             $this->data['simple_set_account_address']['group'][$group['customer_group_id']] = $this->data['simple_set_account_address']['group'][1];
         }
     }
     if (isset($this->error['warning'])) {
         $this->data['error_warning'] = $this->error['warning'];
     } else {
         $this->data['error_warning'] = '';
     }
     $this->load->model('localisation/country');
     $this->data['countries'] = $this->model_localisation_country->getCountries();
     $this->load->model('localisation/zone');
     $this->data['zones'] = isset($this->data['simple_fields_main']['main_country_id']['init']) ? $this->model_localisation_zone->getZonesByCountryId($this->data['simple_fields_main']['main_country_id']['init']) : array();
     $this->data['zone_action'] = $this->url->link('module/simple/zone', 'token=' . $this->session->data['token'], 'SSL');
     $header_content = '';
     $footer_content = '';
     if (file_exists(DIR_CATALOG . 'view/theme/' . $this->get_setting('config_template') . '/template/account/forgotten.tpl')) {
         $tpl = file_get_contents(DIR_CATALOG . 'view/theme/' . $this->get_setting('config_template') . '/template/account/forgotten.tpl');
         $f_b = utf8_strpos($tpl, '<form');
         $header_content = utf8_substr($tpl, 0, $f_b);
         $f_e = utf8_strpos($tpl, '</form>');
         $footer_content = utf8_substr($tpl, $f_e + 7);
     }
     $this->data['theme_folder'] = DIR_CATALOG . 'view/theme/' . $this->get_setting('config_template') . '/';
     $this->data['styles_path'] = DIR_CATALOG . 'view/theme/' . $this->get_setting('config_template') . '/stylesheet/simple.css';
     $this->data['common_header_path'] = DIR_CATALOG . 'view/theme/' . $this->get_setting('config_template') . '/template/common/simple_header.tpl';
     $this->data['common_header_content'] = $header_content;
     $this->data['common_footer_path'] = DIR_CATALOG . 'view/theme/' . $this->get_setting('config_template') . '/template/common/simple_footer.tpl';
     $this->data['common_footer_content'] = $footer_content;
     $this->template = 'module/simple.tpl';
     $this->children = array('common/header', 'common/footer');
     $this->response->setOutput($this->render());
 }
 public function index()
 {
     $redirect = '';
     $this->load->model('setting/setting');
     $settings = $this->model_setting_setting->getSetting('short_checkout');
     if (isset($settings['status']) && $settings['status'] == 0) {
         $settings = false;
     }
     $this->data['settings'] = $settings;
     if ($settings) {
         /*Short checkout*/
         if ($this->cart->hasShipping()) {
             // Validate if shipping address has been set.
             $this->load->model('account/address');
             if ($this->customer->isLogged() && isset($this->session->data['shipping_address_id'])) {
                 $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']);
             } elseif (isset($this->session->data['guest'])) {
                 $shipping_address = $this->session->data['guest']['shipping'];
             }
             if (empty($shipping_address)) {
                 $redirect = $this->url->link('checkout/checkout', '', 'SSL');
             }
             // Validate if shipping method has been set.
             if (!isset($this->session->data['shipping_method'])) {
                 $redirect = $this->url->link('checkout/checkout', '', 'SSL');
             }
         } else {
             unset($this->session->data['shipping_method']);
             unset($this->session->data['shipping_methods']);
         }
         // Validate if payment address has been set.
         $this->load->model('account/address');
         if ($this->customer->isLogged() && isset($this->session->data['payment_address_id'])) {
             $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']);
         } elseif (isset($this->session->data['guest'])) {
             $payment_address = $this->session->data['guest']['payment'];
         }
         if (empty($payment_address)) {
             $redirect = $this->url->link('checkout/checkout', '', 'SSL');
         }
         // Validate if payment method has been set.
         if (!isset($this->session->data['payment_method'])) {
             $redirect = $this->url->link('checkout/checkout', '', 'SSL');
         }
         // Validate cart has products and has stock.
         if (!$this->cart->hasProducts() && empty($this->session->data['vouchers']) || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
             $redirect = $this->url->link('checkout/cart');
         }
         // Validate minimum quantity requirments.
         $products = $this->cart->getProducts();
         foreach ($products as $product) {
             $product_total = 0;
             foreach ($products as $product_2) {
                 if ($product_2['product_id'] == $product['product_id']) {
                     $product_total += $product_2['quantity'];
                 }
             }
             if ($product['minimum'] > $product_total) {
                 $redirect = $this->url->link('checkout/cart');
                 break;
             }
         }
         $json = array();
         if (!$redirect) {
             $total_data = array();
             $total = 0;
             $taxes = $this->cart->getTaxes();
             $this->load->model('setting/extension');
             $sort_order = array();
             $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('total');
             foreach ($results as $key => $value) {
                 $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
             }
             array_multisort($sort_order, SORT_ASC, $results);
             foreach ($results as $result) {
                 if ($this->config->get($result['code'] . '_status')) {
                     $this->load->model('total/' . $result['code']);
                     $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
                 }
             }
             $sort_order = array();
             foreach ($total_data as $key => $value) {
                 $sort_order[$key] = $value['sort_order'];
             }
             array_multisort($sort_order, SORT_ASC, $total_data);
             $this->language->load('checkout/checkout');
             $data = array();
             $data['invoice_prefix'] = $this->config->get('config_invoice_prefix');
             $data['store_id'] = $this->config->get('config_store_id');
             $data['store_name'] = $this->config->get('config_name');
             if ($data['store_id']) {
                 $data['store_url'] = $this->config->get('config_url');
             } else {
                 $data['store_url'] = HTTP_SERVER;
             }
             if (isset($this->session->data['guest'])) {
                 if ($this->customer->isLogged()) {
                     $data['customer_id'] = $this->customer->getId();
                 } else {
                     $data['customer_id'] = 0;
                 }
                 if ($this->customer->isLogged()) {
                     $data['customer_group_id'] = $this->customer->getCustomerGroupId();
                 } else {
                     $data['customer_group_id'] = $this->config->get('config_customer_group_id');
                 }
                 if ($this->session->data['guest']['firstname'] != '') {
                     $data['firstname'] = $this->session->data['guest']['firstname'];
                 } else {
                     $data['firstname'] = '';
                 }
                 if ($this->session->data['guest']['lastname'] != '') {
                     $data['lastname'] = $this->session->data['guest']['lastname'];
                 } else {
                     $data['lastname'] = '';
                 }
                 if ($this->session->data['guest']['email'] != '') {
                     $data['email'] = $this->session->data['guest']['email'];
                 } else {
                     $data['email'] = '';
                 }
                 if ($this->session->data['guest']['telephone'] != '') {
                     $data['telephone'] = $this->session->data['guest']['telephone'];
                 } else {
                     $data['telephone'] = '';
                 }
                 if ($this->session->data['guest']['fax'] != '') {
                     $data['fax'] = $this->session->data['guest']['fax'];
                 } else {
                     $data['fax'] = '';
                 }
                 $this->load->model('account/address');
                 $payment_address = $this->session->data['guest']['payment'];
             }
             if ($this->session->data['guest']['firstname'] != '') {
                 $data['payment_firstname'] = $payment_address['firstname'];
             } else {
                 $data['payment_firstname'] = '';
             }
             if ($this->session->data['guest']['lastname'] != '') {
                 $data['payment_lastname'] = $payment_address['lastname'];
             } else {
                 $data['payment_lastname'] = '';
             }
             if ($this->session->data['guest']['company'] != '') {
                 $data['payment_company'] = $this->session->data['guest']['company'];
             } else {
                 $data['payment_company'] = '';
             }
             if ($payment_address['address_1'] != '') {
                 $data['payment_address_1'] = $payment_address['address_1'];
             } else {
                 $data['payment_address_1'] = '';
             }
             if ($payment_address['address_2'] != '') {
                 $data['payment_address_2'] = $payment_address['address_2'];
             } else {
                 $data['payment_address_2'] = '';
             }
             if ($payment_address['city'] != '') {
                 $data['payment_city'] = $payment_address['city'];
             } else {
                 $data['payment_city'] = '';
             }
             if ($payment_address['postcode'] != '') {
                 $data['payment_postcode'] = $payment_address['postcode'];
             } else {
                 $data['payment_postcode'] = '';
             }
             $data['payment_company_id'] = '';
             $data['payment_tax_id'] = '';
             $data['payment_zone'] = $payment_address['zone'];
             $data['payment_zone_id'] = $payment_address['zone_id'];
             $data['payment_country'] = $payment_address['country'];
             $data['payment_country_id'] = $payment_address['country_id'];
             $data['payment_address_format'] = $payment_address['address_format'];
             if (isset($this->session->data['payment_method']['title'])) {
                 $data['payment_method'] = $this->session->data['payment_method']['title'];
             } else {
                 $data['payment_method'] = '';
             }
             if (isset($this->session->data['payment_method']['code'])) {
                 $data['payment_code'] = $this->session->data['payment_method']['code'];
             } else {
                 $data['payment_code'] = '';
             }
             if ($this->cart->hasShipping()) {
                 if (isset($this->session->data['guest'])) {
                     $shipping_address = $this->session->data['guest']['shipping'];
                 }
                 if ($shipping_address['firstname'] != '') {
                     $data['shipping_firstname'] = $shipping_address['firstname'];
                 } else {
                     $data['shipping_firstname'] = '';
                 }
                 if ($shipping_address['lastname'] != '') {
                     $data['shipping_lastname'] = $shipping_address['lastname'];
                 } else {
                     $data['shipping_lastname'] = '';
                 }
                 if ($this->session->data['guest']['company'] != '') {
                     $data['shipping_company'] = $this->session->data['guest']['company'];
                 } else {
                     $data['shipping_company'] = '';
                 }
                 if ($shipping_address['address_1'] != '') {
                     $data['shipping_address_1'] = $shipping_address['address_1'];
                 } else {
                     $data['shipping_address_1'] = '';
                 }
                 if ($shipping_address['address_2'] != '') {
                     $data['shipping_address_2'] = $shipping_address['address_2'];
                 } else {
                     $data['shipping_address_2'] = '';
                 }
                 if ($shipping_address['city'] != '') {
                     $data['shipping_city'] = $shipping_address['city'];
                 } else {
                     $data['shipping_city'] = '';
                 }
                 $data['shipping_postcode'] = $shipping_address['postcode'];
                 $data['shipping_zone'] = $shipping_address['zone'];
                 $data['shipping_zone_id'] = $shipping_address['zone_id'];
                 $data['shipping_country'] = $shipping_address['country'];
                 $data['shipping_country_id'] = $shipping_address['country_id'];
                 $data['shipping_address_format'] = $shipping_address['address_format'];
                 if (isset($this->session->data['shipping_method']['title'])) {
                     $data['shipping_method'] = $this->session->data['shipping_method']['title'];
                 } else {
                     $data['shipping_method'] = '';
                 }
                 if (isset($this->session->data['shipping_method']['code'])) {
                     $data['shipping_code'] = $this->session->data['shipping_method']['code'];
                 } else {
                     $data['shipping_code'] = '';
                 }
             } else {
                 $data['shipping_firstname'] = '';
                 $data['shipping_lastname'] = '';
                 $data['shipping_company'] = '';
                 $data['shipping_address_1'] = '';
                 $data['shipping_address_2'] = '';
                 $data['shipping_city'] = '';
                 $data['shipping_postcode'] = '';
                 $data['shipping_zone'] = '';
                 $data['shipping_zone_id'] = '';
                 $data['shipping_country'] = '';
                 $data['shipping_country_id'] = '';
                 $data['shipping_address_format'] = '';
                 $data['shipping_method'] = '';
                 $data['shipping_code'] = '';
             }
             $product_data = array();
             foreach ($this->cart->getProducts() as $product) {
                 $option_data = array();
                 foreach ($product['option'] as $option) {
                     if ($option['type'] != 'file') {
                         $value = $option['option_value'];
                     } else {
                         $value = $this->encryption->decrypt($option['option_value']);
                     }
                     $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $value, 'type' => $option['type']);
                 }
                 $product_data[] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'download' => $product['download'], 'quantity' => $product['quantity'], 'subtract' => $product['subtract'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => $this->tax->getTax($product['total'], $product['tax_class_id']), 'reward' => $product['reward']);
             }
             // Gift Voucher
             $voucher_data = array();
             if (!empty($this->session->data['vouchers'])) {
                 foreach ($this->session->data['vouchers'] as $voucher) {
                     $voucher_data[] = array('description' => $voucher['description'], 'code' => substr(md5(rand()), 0, 7), 'to_name' => $voucher['to_name'], 'to_email' => $voucher['to_email'], 'from_name' => $voucher['from_name'], 'from_email' => $voucher['from_email'], 'voucher_theme_id' => $voucher['voucher_theme_id'], 'message' => $voucher['message'], 'amount' => $voucher['amount']);
                 }
             }
             $data['products'] = $product_data;
             $data['vouchers'] = $voucher_data;
             $data['totals'] = $total_data;
             $data['comment'] = $this->session->data['comment'];
             $data['total'] = $total;
             if (isset($this->request->cookie['tracking'])) {
                 $this->load->model('affiliate/affiliate');
                 $affiliate_info = $this->model_affiliate_affiliate->getAffiliateByCode($this->request->cookie['tracking']);
                 $subtotal = $this->cart->getSubTotal();
                 if ($affiliate_info) {
                     $data['affiliate_id'] = $affiliate_info['affiliate_id'];
                     $data['commission'] = $subtotal / 100 * $affiliate_info['commission'];
                 } else {
                     $data['affiliate_id'] = 0;
                     $data['commission'] = 0;
                 }
             } else {
                 $data['affiliate_id'] = 0;
                 $data['commission'] = 0;
             }
             $data['language_id'] = $this->config->get('config_language_id');
             $data['currency_id'] = $this->currency->getId();
             $data['currency_code'] = $this->currency->getCode();
             $data['currency_value'] = $this->currency->getValue($this->currency->getCode());
             $data['ip'] = $this->request->server['REMOTE_ADDR'];
             if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
                 $data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
             } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) {
                 $data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP'];
             } else {
                 $data['forwarded_ip'] = '';
             }
             if (isset($this->request->server['HTTP_USER_AGENT'])) {
                 $data['user_agent'] = $this->request->server['HTTP_USER_AGENT'];
             } else {
                 $data['user_agent'] = '';
             }
             if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) {
                 $data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE'];
             } else {
                 $data['accept_language'] = '';
             }
             $this->load->model('checkout/order');
             $this->session->data['order_id'] = $this->model_checkout_order->addOrder($data);
             $this->data['column_name'] = $this->language->get('column_name');
             $this->data['column_model'] = $this->language->get('column_model');
             $this->data['column_quantity'] = $this->language->get('column_quantity');
             $this->data['column_price'] = $this->language->get('column_price');
             $this->data['column_total'] = $this->language->get('column_total');
             $this->data['text_confirm'] = $this->language->get('text_confirm');
             $this->data['text_change_data'] = $this->language->get('text_change_data');
             $this->data['back_link'] = $this->url->link('checkout/cart');
             $this->data['products'] = array();
             foreach ($this->cart->getProducts() as $product) {
                 $option_data = array();
                 foreach ($product['option'] as $option) {
                     if ($option['type'] != 'file') {
                         $value = $option['option_value'];
                     } else {
                         $filename = $this->encryption->decrypt($option['option_value']);
                         $value = utf8_substr($filename, 0, utf8_strrpos($filename, '.'));
                     }
                     $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
                 }
                 $this->data['products'][] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'subtract' => $product['subtract'], 'price' => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'))), 'total' => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']), 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']));
             }
             // Gift Voucher
             $this->data['vouchers'] = array();
             if (!empty($this->session->data['vouchers'])) {
                 foreach ($this->session->data['vouchers'] as $voucher) {
                     $this->data['vouchers'][] = array('description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount']));
                 }
             }
             $this->data['totals'] = $total_data;
             $this->data['payment'] = $this->getChild('payment/' . $this->session->data['payment_method']['code']);
         } else {
             $this->data['redirect'] = $redirect;
         }
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/confirm.tpl.php')) {
             $this->template = $this->config->get('config_template') . '/template/checkout/confirm.tpl.php';
         } else {
             $this->template = 'default/template/checkout/confirm.tpl.php';
         }
         $json['output'] = $this->render();
         $this->response->setOutput(json_encode($json));
         /* END Short checkout*/
     } else {
         if ($this->cart->hasShipping()) {
             // Validate if shipping address has been set.
             $this->load->model('account/address');
             if ($this->customer->isLogged() && isset($this->session->data['shipping_address_id'])) {
                 $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']);
             } elseif (isset($this->session->data['guest'])) {
                 $shipping_address = $this->session->data['guest']['shipping'];
             }
             if (empty($shipping_address)) {
                 $redirect = $this->url->link('checkout/checkout', '', 'SSL');
             }
             // Validate if shipping method has been set.
             if (!isset($this->session->data['shipping_method'])) {
                 $redirect = $this->url->link('checkout/checkout', '', 'SSL');
             }
         } else {
             unset($this->session->data['shipping_method']);
             unset($this->session->data['shipping_methods']);
         }
         // Validate if payment address has been set.
         $this->load->model('account/address');
         if ($this->customer->isLogged() && isset($this->session->data['payment_address_id'])) {
             $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']);
         } elseif (isset($this->session->data['guest'])) {
             $payment_address = $this->session->data['guest']['payment'];
         }
         if (empty($payment_address)) {
             $redirect = $this->url->link('checkout/checkout', '', 'SSL');
         }
         // Validate if payment method has been set.
         if (!isset($this->session->data['payment_method'])) {
             $redirect = $this->url->link('checkout/checkout', '', 'SSL');
         }
         // Validate cart has products and has stock.
         if (!$this->cart->hasProducts() && empty($this->session->data['vouchers']) || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
             $redirect = $this->url->link('checkout/cart');
         }
         // Validate minimum quantity requirments.
         $products = $this->cart->getProducts();
         foreach ($products as $product) {
             $product_total = 0;
             foreach ($products as $product_2) {
                 if ($product_2['product_id'] == $product['product_id']) {
                     $product_total += $product_2['quantity'];
                 }
             }
             if ($product['minimum'] > $product_total) {
                 $redirect = $this->url->link('checkout/cart');
                 break;
             }
         }
         if (!$redirect) {
             $total_data = array();
             $total = 0;
             $taxes = $this->cart->getTaxes();
             $this->load->model('setting/extension');
             $sort_order = array();
             $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('total');
             foreach ($results as $key => $value) {
                 $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
             }
             array_multisort($sort_order, SORT_ASC, $results);
             foreach ($results as $result) {
                 if ($this->config->get($result['code'] . '_status')) {
                     $this->load->model('total/' . $result['code']);
                     $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
                 }
             }
             $sort_order = array();
             foreach ($total_data as $key => $value) {
                 $sort_order[$key] = $value['sort_order'];
             }
             array_multisort($sort_order, SORT_ASC, $total_data);
             $this->language->load('checkout/checkout');
             $data = array();
             $data['invoice_prefix'] = $this->config->get('config_invoice_prefix');
             $data['store_id'] = $this->config->get('config_store_id');
             $data['store_name'] = $this->config->get('config_name');
             if ($data['store_id']) {
                 $data['store_url'] = $this->config->get('config_url');
             } else {
                 $data['store_url'] = HTTP_SERVER;
             }
             if ($this->customer->isLogged()) {
                 $data['customer_id'] = $this->customer->getId();
                 $data['customer_group_id'] = $this->customer->getCustomerGroupId();
                 $data['firstname'] = $this->customer->getFirstName();
                 $data['lastname'] = $this->customer->getLastName();
                 $data['email'] = $this->customer->getEmail();
                 $data['telephone'] = $this->customer->getTelephone();
                 $data['fax'] = $this->customer->getFax();
                 $this->load->model('account/address');
                 $payment_address = $this->model_account_address->getAddress($this->session->data['payment_address_id']);
             } elseif (isset($this->session->data['guest'])) {
                 $data['customer_id'] = 0;
                 $data['customer_group_id'] = $this->config->get('config_customer_group_id');
                 $data['firstname'] = $this->session->data['guest']['firstname'];
                 $data['lastname'] = $this->session->data['guest']['lastname'];
                 $data['email'] = $this->session->data['guest']['email'];
                 $data['telephone'] = $this->session->data['guest']['telephone'];
                 $data['fax'] = $this->session->data['guest']['fax'];
                 $payment_address = $this->session->data['guest']['payment'];
             }
             $data['payment_firstname'] = $payment_address['firstname'];
             $data['payment_lastname'] = $payment_address['lastname'];
             $data['payment_company'] = $payment_address['company'];
             $data['payment_address_1'] = $payment_address['address_1'];
             $data['payment_address_2'] = $payment_address['address_2'];
             $data['payment_city'] = $payment_address['city'];
             $data['payment_postcode'] = $payment_address['postcode'];
             $data['payment_zone'] = $payment_address['zone'];
             $data['payment_zone_id'] = $payment_address['zone_id'];
             $data['payment_country'] = $payment_address['country'];
             $data['payment_country_id'] = $payment_address['country_id'];
             $data['payment_address_format'] = $payment_address['address_format'];
             if (isset($this->session->data['payment_method']['title'])) {
                 $data['payment_method'] = $this->session->data['payment_method']['title'];
             } else {
                 $data['payment_method'] = '';
             }
             if (isset($this->session->data['payment_method']['code'])) {
                 $data['payment_code'] = $this->session->data['payment_method']['code'];
             } else {
                 $data['payment_code'] = '';
             }
             if ($this->cart->hasShipping()) {
                 if ($this->customer->isLogged()) {
                     $this->load->model('account/address');
                     $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']);
                 } elseif (isset($this->session->data['guest'])) {
                     $shipping_address = $this->session->data['guest']['shipping'];
                 }
                 $data['shipping_firstname'] = $shipping_address['firstname'];
                 $data['shipping_lastname'] = $shipping_address['lastname'];
                 $data['shipping_company'] = $shipping_address['company'];
                 $data['shipping_address_1'] = $shipping_address['address_1'];
                 $data['shipping_address_2'] = $shipping_address['address_2'];
                 $data['shipping_city'] = $shipping_address['city'];
                 $data['shipping_postcode'] = $shipping_address['postcode'];
                 $data['shipping_zone'] = $shipping_address['zone'];
                 $data['shipping_zone_id'] = $shipping_address['zone_id'];
                 $data['shipping_country'] = $shipping_address['country'];
                 $data['shipping_country_id'] = $shipping_address['country_id'];
                 $data['shipping_address_format'] = $shipping_address['address_format'];
                 if (isset($this->session->data['shipping_method']['title'])) {
                     $data['shipping_method'] = $this->session->data['shipping_method']['title'];
                 } else {
                     $data['shipping_method'] = '';
                 }
                 if (isset($this->session->data['shipping_method']['code'])) {
                     $data['shipping_code'] = $this->session->data['shipping_method']['code'];
                 } else {
                     $data['shipping_code'] = '';
                 }
             } else {
                 $data['shipping_firstname'] = '';
                 $data['shipping_lastname'] = '';
                 $data['shipping_company'] = '';
                 $data['shipping_address_1'] = '';
                 $data['shipping_address_2'] = '';
                 $data['shipping_city'] = '';
                 $data['shipping_postcode'] = '';
                 $data['shipping_zone'] = '';
                 $data['shipping_zone_id'] = '';
                 $data['shipping_country'] = '';
                 $data['shipping_country_id'] = '';
                 $data['shipping_address_format'] = '';
                 $data['shipping_method'] = '';
                 $data['shipping_code'] = '';
             }
             $product_data = array();
             foreach ($this->cart->getProducts() as $product) {
                 $option_data = array();
                 foreach ($product['option'] as $option) {
                     if ($option['type'] != 'file') {
                         $value = $option['option_value'];
                     } else {
                         $value = $this->encryption->decrypt($option['option_value']);
                     }
                     $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $value, 'type' => $option['type']);
                 }
                 $product_data[] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'download' => $product['download'], 'quantity' => $product['quantity'], 'subtract' => $product['subtract'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => $this->tax->getTax($product['total'], $product['tax_class_id']), 'reward' => $product['reward']);
             }
             // Gift Voucher
             $voucher_data = array();
             if (!empty($this->session->data['vouchers'])) {
                 foreach ($this->session->data['vouchers'] as $voucher) {
                     $voucher_data[] = array('description' => $voucher['description'], 'code' => substr(md5(rand()), 0, 7), 'to_name' => $voucher['to_name'], 'to_email' => $voucher['to_email'], 'from_name' => $voucher['from_name'], 'from_email' => $voucher['from_email'], 'voucher_theme_id' => $voucher['voucher_theme_id'], 'message' => $voucher['message'], 'amount' => $voucher['amount']);
                 }
             }
             $data['products'] = $product_data;
             $data['vouchers'] = $voucher_data;
             $data['totals'] = $total_data;
             $data['comment'] = $this->session->data['comment'];
             $data['total'] = $total;
             if (isset($this->request->cookie['tracking'])) {
                 $this->load->model('affiliate/affiliate');
                 $affiliate_info = $this->model_affiliate_affiliate->getAffiliateByCode($this->request->cookie['tracking']);
                 if ($affiliate_info) {
                     $data['affiliate_id'] = $affiliate_info['affiliate_id'];
                     $data['commission'] = $total / 100 * $affiliate_info['commission'];
                 } else {
                     $data['affiliate_id'] = 0;
                     $data['commission'] = 0;
                 }
             } else {
                 $data['affiliate_id'] = 0;
                 $data['commission'] = 0;
             }
             $data['language_id'] = $this->config->get('config_language_id');
             $data['currency_id'] = $this->currency->getId();
             $data['currency_code'] = $this->currency->getCode();
             $data['currency_value'] = $this->currency->getValue($this->currency->getCode());
             $data['ip'] = $this->request->server['REMOTE_ADDR'];
             if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
                 $data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
             } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) {
                 $data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP'];
             } else {
                 $data['forwarded_ip'] = '';
             }
             if (isset($this->request->server['HTTP_USER_AGENT'])) {
                 $data['user_agent'] = $this->request->server['HTTP_USER_AGENT'];
             } else {
                 $data['user_agent'] = '';
             }
             if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) {
                 $data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE'];
             } else {
                 $data['accept_language'] = '';
             }
             $this->load->model('checkout/order');
             $this->session->data['order_id'] = $this->model_checkout_order->addOrder($data);
             $this->data['column_name'] = $this->language->get('column_name');
             $this->data['column_model'] = $this->language->get('column_model');
             $this->data['column_quantity'] = $this->language->get('column_quantity');
             $this->data['column_price'] = $this->language->get('column_price');
             $this->data['column_total'] = $this->language->get('column_total');
             $this->data['products'] = array();
             foreach ($this->cart->getProducts() as $product) {
                 $option_data = array();
                 foreach ($product['option'] as $option) {
                     if ($option['type'] != 'file') {
                         $value = $option['option_value'];
                     } else {
                         $filename = $this->encryption->decrypt($option['option_value']);
                         $value = utf8_substr($filename, 0, utf8_strrpos($filename, '.'));
                     }
                     $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
                 }
                 $this->data['products'][] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'subtract' => $product['subtract'], 'price' => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'))), 'total' => $this->currency->format($this->tax->calculate($product['total'], $product['tax_class_id'], $this->config->get('config_tax'))), 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']));
             }
             // Gift Voucher
             $this->data['vouchers'] = array();
             if (!empty($this->session->data['vouchers'])) {
                 foreach ($this->session->data['vouchers'] as $voucher) {
                     $this->data['vouchers'][] = array('description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount']));
                 }
             }
             $this->data['totals'] = $total_data;
             $this->data['payment'] = $this->getChild('payment/' . $this->session->data['payment_method']['code']);
         } else {
             $this->data['redirect'] = $redirect;
         }
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/confirm.tpl.php')) {
             $this->template = $this->config->get('config_template') . '/template/checkout/confirm.tpl.php';
         } else {
             $this->template = 'default/template/checkout/confirm.tpl.php';
         }
         $this->response->setOutput($this->render());
     }
 }
 public function index()
 {
     $this->language->load('checkout/simplecheckout');
     $this->data['address_empty'] = false;
     $address = $this->simple->payment_address;
     $address_fields = $this->simple->payment_address_fields;
     $reload = explode(',', $this->config->get('simple_set_for_reload'));
     if ($address['country_id'] == '' && in_array('main_country_id', $reload) && !empty($address_fields['main_country_id']) && $address_fields['main_country_id']['type'] != 'hidden') {
         $this->data['address_empty'] = true;
     }
     if ($address['zone_id'] === '' && in_array('main_zone_id', $reload) && !empty($address_fields['main_zone_id']) && $address_fields['main_zone_id']['type'] != 'hidden') {
         $this->data['address_empty'] = true;
     }
     if ($address['city'] == '' && in_array('main_city', $reload) && !empty($address_fields['main_city']) && $address_fields['main_city']['type'] != 'hidden') {
         $this->data['address_empty'] = true;
     }
     if ($address['postcode'] == '' && in_array('main_postcode', $reload) && !empty($address_fields['main_postcode']) && $address_fields['main_postcode']['type'] != 'hidden') {
         $this->data['address_empty'] = true;
     }
     $this->data['simple_debug'] = $this->config->get('simple_debug');
     $this->data['address'] = $address;
     $this->data['simple_payment_view_address_empty'] = $this->config->get('simple_payment_view_address_empty');
     $simple_payment_view_address_full = $this->config->get('simple_payment_view_address_full');
     $simple_payment_view_autoselect_first = $this->config->get('simple_payment_methods_hide') ? true : $this->config->get('simple_payment_view_autoselect_first');
     $simple_payment_methods_hide = $this->config->get('simple_payment_methods_hide');
     $this->data['payment_methods'] = array();
     $total_data = array();
     $total = 0;
     $taxes = $this->cart->getTaxes();
     $this->load->model('setting/extension');
     $sort_order = array();
     $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('total');
     foreach ($results as $key => $value) {
         $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
     }
     array_multisort($sort_order, SORT_ASC, $results);
     foreach ($results as $result) {
         if ($this->config->get($result['code'] . '_status')) {
             $this->load->model('total/' . $result['code']);
             $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
         }
     }
     $method_data = array();
     $this->load->model('setting/extension');
     $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('payment');
     $simple_links = $this->cart->hasShipping() ? $this->config->get('simple_links') : array();
     $shipping_method_code = false;
     if (!$this->config->get('simple_childs_payment_first')) {
         $shipping_method = $this->simple->shipping_method;
         $shipping_method_code = !empty($shipping_method['code']) ? $shipping_method['code'] : false;
         $shipping_method_code = $shipping_method_code ? explode('.', $shipping_method_code) : false;
         $shipping_method_code = count($shipping_method_code) == 2 ? $shipping_method_code : false;
     }
     if ($this->customer->isLogged()) {
         $customer_group_id = $this->customer->getCustomerGroupId();
     } else {
         $customer_group_id = $this->config->get('config_customer_group_id');
     }
     if ($this->config->get('simple_customer_view_customer_type')) {
         $customer_groups = $this->simple->get_customer_groups();
         if (isset($this->request->post['customer_group_id']) && array_key_exists($this->request->post['customer_group_id'], $customer_groups)) {
             $customer_group_id = $this->request->post['customer_group_id'];
         }
     }
     $filter_methods = array();
     $simple_group_payment = $this->config->get('simple_group_payment');
     if (!empty($simple_group_payment[$customer_group_id])) {
         $filter_methods = explode(',', $simple_group_payment[$customer_group_id]);
     }
     $simple_payment_titles = $this->config->get('simple_payment_titles');
     $version = $this->simple->opencart_version;
     $cart_has_recurring = 0;
     if ($version >= 156) {
         $cart_has_recurring = $this->cart->hasRecurringProducts();
     }
     foreach ($results as $result) {
         $show_module = true;
         if ($this->data['address_empty'] && !empty($simple_payment_view_address_full[$result['code']])) {
             $show_module = false;
         }
         if (is_array($filter_methods) && !empty($filter_methods)) {
             if (in_array($result['code'], $filter_methods)) {
                 $show_module = true;
             } else {
                 $show_module = false;
             }
         }
         if ($this->config->get($result['code'] . '_status') && $show_module) {
             $for_shipping_methods = array();
             if (!$this->config->get('simple_childs_payment_first') && !empty($simple_links[$result['code']])) {
                 $for_shipping_methods = explode(",", $simple_links[$result['code']]);
             }
             if (empty($for_shipping_methods) || $shipping_method_code && (in_array($shipping_method_code[0], $for_shipping_methods) || in_array($shipping_method_code[0] . '.' . $shipping_method_code[1], $for_shipping_methods))) {
                 $this->load->model('payment/' . $result['code']);
                 $method = $this->{'model_payment_' . $result['code']}->getMethod($address, $total);
                 if ($method) {
                     $method['description'] = !empty($simple_payment_titles[$result['code']]['use_description']) && !empty($simple_payment_titles[$result['code']]['description'][$this->simple->get_language_code()]) ? html_entity_decode($simple_payment_titles[$result['code']]['description'][$this->simple->get_language_code()]) : (!empty($method['description']) ? $method['description'] : '');
                     if ($cart_has_recurring > 0) {
                         if (method_exists($this->{'model_payment_' . $result['code']}, 'recurringPayments')) {
                             if ($this->{'model_payment_' . $result['code']}->recurringPayments() == true) {
                                 $method_data[$result['code']] = $method;
                             }
                         }
                     } else {
                         $method_data[$result['code']] = $method;
                     }
                 }
             }
         }
     }
     $sort_order = array();
     foreach ($method_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $method_data);
     $this->data['payment_methods'] = $method_data;
     $this->data['payment_method'] = null;
     $this->data['error_warning'] = '';
     $this->data['checked_code'] = '';
     $this->data['disabled_methods'] = array();
     if (!empty($simple_payment_titles)) {
         foreach ($simple_payment_titles as $key => $value) {
             if (!array_key_exists($key, $this->data['payment_methods']) && !empty($value['show']) && ($value['show'] == 1 || $value['show'] == 2 && $this->data['address_empty'])) {
                 $this->data['disabled_methods'][$key]['title'] = !empty($value['title'][$this->simple->get_language_code()]) ? html_entity_decode($value['title'][$this->simple->get_language_code()]) : $key;
                 $this->data['disabled_methods'][$key]['description'] = !empty($value['description'][$this->simple->get_language_code()]) ? html_entity_decode($value['description'][$this->simple->get_language_code()]) : '';
             }
         }
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && !empty($this->request->post['payment_method_checked']) && !empty($this->data['payment_methods'][$this->request->post['payment_method_checked']])) {
         $this->data['checked_code'] = $this->request->post['payment_method_checked'];
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['payment_method']) && !empty($this->data['payment_methods'][$this->request->post['payment_method']])) {
         $this->data['payment_method'] = $this->data['payment_methods'][$this->request->post['payment_method']];
         if (isset($this->request->post['payment_method_current']) && $this->request->post['payment_method_current'] != $this->request->post['payment_method']) {
             $this->data['checked_code'] = $this->request->post['payment_method'];
         }
     }
     if ($this->request->server['REQUEST_METHOD'] == 'GET' && isset($this->request->cookie['payment_method']) && !empty($this->data['payment_methods'][$this->request->cookie['payment_method']])) {
         $this->data['payment_method'] = $this->data['payment_methods'][$this->request->cookie['payment_method']];
     }
     if (!empty($this->data['payment_methods'])) {
         $first_method = reset($this->data['payment_methods']);
     }
     if (!empty($first_method) && ($simple_payment_methods_hide || $simple_payment_view_autoselect_first && $this->data['checked_code'] == '')) {
         $this->data['payment_method'] = $first_method;
     }
     if (isset($this->data['payment_method'])) {
         setcookie('payment_method', $this->data['payment_method']['code'], time() + 60 * 60 * 24 * 30);
     }
     $this->data['code'] = !empty($this->data['payment_method']) ? $this->data['payment_method']['code'] : '';
     $this->simple->payment_methods = $this->data['payment_methods'];
     $this->simple->payment_method = $this->data['payment_method'];
     $this->data['simple_show_errors'] = !empty($this->request->post['simple_create_order']) || !empty($this->request->post['simple_step_next']) && !empty($this->request->post['simple_step']) && $this->request->post['simple_step'] == 'simplecheckout_payment';
     $this->validate();
     $this->save_to_session();
     $this->data['text_payment_address'] = $this->language->get('text_payment_address');
     $this->data['error_no_payment'] = sprintf($this->language->get('error_no_payment'), $this->url->link('information/contact'));
     $this->data['text_checkout_payment_method'] = $this->language->get('text_checkout_payment_method');
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/simplecheckout_payment.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/checkout/simplecheckout_payment.tpl';
     } else {
         $this->template = 'default/template/checkout/simplecheckout_payment.tpl';
     }
     $this->response->setOutput($this->render());
 }
 private function order()
 {
     if (isset($this->session->data['order_id']) && !isset($this->session->data['prevent_delete'][$this->session->data['order_id']]) && !isset($this->session->data['prevent_delete'][0])) {
         $this->simple->delete_order($this->session->data['order_id']);
         unset($this->session->data['order_id']);
     }
     $customer = $this->simple->customer_info;
     if (empty($customer['email'])) {
         $email = $this->config->get('simple_empty_email');
         $email = !empty($email) ? $email : 'empty@localhost';
         $customer['email'] = $email;
     }
     $this->simple->customer_info = $customer;
     $version = $this->simple->opencart_version;
     $total_data = array();
     $total = 0;
     $taxes = $this->cart->getTaxes();
     $this->load->model('setting/extension');
     $sort_order = array();
     $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('total');
     foreach ($results as $key => $value) {
         $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
     }
     array_multisort($sort_order, SORT_ASC, $results);
     foreach ($results as $result) {
         if ($this->config->get($result['code'] . '_status')) {
             $this->load->model('total/' . $result['code']);
             $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
         }
     }
     $sort_order = array();
     foreach ($total_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $total_data);
     $data = array();
     $data['invoice_prefix'] = $this->config->get('config_invoice_prefix');
     $data['store_id'] = $this->config->get('config_store_id');
     $data['store_name'] = $this->config->get('config_name');
     if ($data['store_id']) {
         $data['store_url'] = $this->config->get('config_url');
     } else {
         $data['store_url'] = HTTP_SERVER;
     }
     $data['customer_id'] = $this->simple->customer_info['customer_id'];
     $data['customer_group_id'] = $this->simple->customer_info['customer_group_id'];
     $data['firstname'] = $this->simple->customer_info['firstname'];
     $data['lastname'] = $this->simple->customer_info['lastname'];
     $data['email'] = $this->simple->customer_info['email'];
     $data['telephone'] = $this->simple->customer_info['telephone'];
     $data['fax'] = $this->simple->customer_info['fax'];
     $data['payment_firstname'] = $this->simple->payment_address['firstname'];
     $data['payment_lastname'] = $this->simple->payment_address['lastname'];
     $data['payment_company'] = $this->simple->payment_address['company'];
     $data['payment_address_1'] = $this->simple->payment_address['address_1'];
     $data['payment_address_2'] = $this->simple->payment_address['address_2'];
     $data['payment_city'] = $this->simple->payment_address['city'];
     $data['payment_postcode'] = $this->simple->payment_address['postcode'];
     $data['payment_zone'] = $this->simple->payment_address['zone'];
     $data['payment_zone_id'] = $this->simple->payment_address['zone_id'];
     $data['payment_country'] = $this->simple->payment_address['country'];
     $data['payment_country_id'] = $this->simple->payment_address['country_id'];
     $data['payment_address_format'] = $this->simple->payment_address['address_format'];
     $data['payment_company_id'] = $this->simple->payment_address['company_id'];
     $data['payment_tax_id'] = $this->simple->payment_address['tax_id'];
     $payment_method = $this->simple->payment_method;
     if (isset($payment_method['title'])) {
         $data['payment_method'] = $payment_method['title'];
     } else {
         $data['payment_method'] = '';
     }
     if (isset($payment_method['code'])) {
         $data['payment_code'] = $payment_method['code'];
     } else {
         $data['payment_code'] = '';
     }
     if ($this->cart->hasShipping()) {
         $data['shipping_firstname'] = $this->simple->shipping_address['firstname'];
         $data['shipping_lastname'] = $this->simple->shipping_address['lastname'];
         $data['shipping_company'] = $this->simple->shipping_address['company'];
         $data['shipping_address_1'] = $this->simple->shipping_address['address_1'];
         $data['shipping_address_2'] = $this->simple->shipping_address['address_2'];
         $data['shipping_city'] = $this->simple->shipping_address['city'];
         $data['shipping_postcode'] = $this->simple->shipping_address['postcode'];
         $data['shipping_zone'] = $this->simple->shipping_address['zone'];
         $data['shipping_zone_id'] = $this->simple->shipping_address['zone_id'];
         $data['shipping_country'] = $this->simple->shipping_address['country'];
         $data['shipping_country_id'] = $this->simple->shipping_address['country_id'];
         $data['shipping_address_format'] = $this->simple->shipping_address['address_format'];
         $shipping_method = $this->simple->shipping_method;
         if (isset($shipping_method['title'])) {
             $data['shipping_method'] = $shipping_method['title'];
         } else {
             $data['shipping_method'] = '';
         }
         if (isset($shipping_method['code'])) {
             $data['shipping_code'] = $shipping_method['code'];
         } else {
             $data['shipping_code'] = '';
         }
     } else {
         $data['shipping_firstname'] = '';
         $data['shipping_lastname'] = '';
         $data['shipping_company'] = '';
         $data['shipping_address_1'] = '';
         $data['shipping_address_2'] = '';
         $data['shipping_city'] = '';
         $data['shipping_postcode'] = '';
         $data['shipping_zone'] = '';
         $data['shipping_zone_id'] = '';
         $data['shipping_country'] = '';
         $data['shipping_country_id'] = '';
         $data['shipping_address_format'] = '';
         $data['shipping_method'] = '';
         $data['shipping_code'] = '';
     }
     $product_data = array();
     if ($version < 152) {
         if (method_exists($this->tax, 'setZone')) {
             if ($this->cart->hasShipping()) {
                 $this->tax->setZone($data['shipping_country_id'], $data['shipping_zone_id']);
             } else {
                 $this->tax->setZone($data['payment_country_id'], $data['payment_zone_id']);
             }
         }
         $this->load->library('encryption');
         foreach ($this->cart->getProducts() as $product) {
             $option_data = array();
             foreach ($product['option'] as $option) {
                 if ($option['type'] != 'file') {
                     $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $option['option_value'], 'type' => $option['type']);
                 } else {
                     $encryption = new Encryption($this->config->get('config_encryption'));
                     $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $encryption->decrypt($option['option_value']), 'type' => $option['type']);
                 }
             }
             $product_data[] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'download' => $product['download'], 'quantity' => $product['quantity'], 'subtract' => $product['subtract'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => method_exists($this->tax, 'getRate') ? $this->tax->getRate($product['tax_class_id']) : $this->tax->getTax($product['price'], $product['tax_class_id']));
         }
         // Gift Voucher
         if (isset($this->session->data['vouchers']) && $this->session->data['vouchers']) {
             foreach ($this->session->data['vouchers'] as $voucher) {
                 $product_data[] = array('product_id' => 0, 'name' => $voucher['description'], 'model' => '', 'option' => array(), 'download' => array(), 'quantity' => 1, 'subtract' => false, 'price' => $voucher['amount'], 'total' => $voucher['amount'], 'tax' => 0);
             }
         }
         $data['products'] = $product_data;
         $data['totals'] = $total_data;
         $data['comment'] = $this->simple->comment;
         $data['total'] = $total;
         $data['reward'] = $this->cart->getTotalRewardPoints();
     } elseif ($version >= 152) {
         foreach ($this->cart->getProducts() as $product) {
             $option_data = array();
             foreach ($product['option'] as $option) {
                 if ($option['type'] != 'file') {
                     $value = $option['option_value'];
                 } else {
                     $value = $this->encryption->decrypt($option['option_value']);
                 }
                 $option_data[] = array('product_option_id' => $option['product_option_id'], 'product_option_value_id' => $option['product_option_value_id'], 'option_id' => $option['option_id'], 'option_value_id' => $option['option_value_id'], 'name' => $option['name'], 'value' => $value, 'type' => $option['type']);
             }
             $product_data[] = array('product_id' => $product['product_id'], 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'download' => $product['download'], 'quantity' => $product['quantity'], 'subtract' => $product['subtract'], 'price' => $product['price'], 'total' => $product['total'], 'tax' => $this->tax->getTax($product['price'], $product['tax_class_id']), 'reward' => $product['reward']);
         }
         // Gift Voucher
         $voucher_data = array();
         if (!empty($this->session->data['vouchers'])) {
             foreach ($this->session->data['vouchers'] as $voucher) {
                 $voucher_data[] = array('description' => $voucher['description'], 'code' => substr(md5(rand()), 0, 10), 'to_name' => $voucher['to_name'], 'to_email' => $voucher['to_email'], 'from_name' => $voucher['from_name'], 'from_email' => $voucher['from_email'], 'voucher_theme_id' => $voucher['voucher_theme_id'], 'message' => $voucher['message'], 'amount' => $voucher['amount']);
             }
         }
         $data['products'] = $product_data;
         $data['vouchers'] = $voucher_data;
         $data['totals'] = $total_data;
         $data['comment'] = $this->simple->comment;
         $data['total'] = $total;
     }
     if (isset($this->request->cookie['tracking'])) {
         $this->load->model('affiliate/affiliate');
         $affiliate_info = $this->model_affiliate_affiliate->getAffiliateByCode($this->request->cookie['tracking']);
         $subtotal = $this->cart->getSubTotal();
         if ($affiliate_info) {
             $data['affiliate_id'] = $affiliate_info['affiliate_id'];
             $data['commission'] = $subtotal / 100 * $affiliate_info['commission'];
         } else {
             $data['affiliate_id'] = 0;
             $data['commission'] = 0;
         }
     } else {
         $data['affiliate_id'] = 0;
         $data['commission'] = 0;
     }
     $data['language_id'] = $this->config->get('config_language_id');
     $data['currency_id'] = $this->currency->getId();
     $data['currency_code'] = $this->currency->getCode();
     $data['currency_value'] = $this->currency->getValue($this->currency->getCode());
     $data['ip'] = $this->request->server['REMOTE_ADDR'];
     if (!empty($this->request->server['HTTP_X_FORWARDED_FOR'])) {
         $data['forwarded_ip'] = $this->request->server['HTTP_X_FORWARDED_FOR'];
     } elseif (!empty($this->request->server['HTTP_CLIENT_IP'])) {
         $data['forwarded_ip'] = $this->request->server['HTTP_CLIENT_IP'];
     } else {
         $data['forwarded_ip'] = '';
     }
     if (isset($this->request->server['HTTP_USER_AGENT'])) {
         $data['user_agent'] = $this->request->server['HTTP_USER_AGENT'];
     } else {
         $data['user_agent'] = '';
     }
     if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) {
         $data['accept_language'] = $this->request->server['HTTP_ACCEPT_LANGUAGE'];
     } else {
         $data['accept_language'] = '';
     }
     $shipping_address_same = $this->simple->shipping_address_same;
     $custom_data_order_1 = $this->simple->get_custom_data_for_object(Simple::SET_CHECKOUT_CUSTOMER, Simple::OBJECT_TYPE_ORDER);
     $custom_data_order_2 = array();
     $custom_data_customer = $this->simple->get_custom_data_for_object(Simple::SET_CHECKOUT_CUSTOMER, Simple::OBJECT_TYPE_CUSTOMER);
     $custom_data_payment_address = $this->simple->get_custom_data_for_object(Simple::SET_CHECKOUT_CUSTOMER, Simple::OBJECT_TYPE_ADDRESS);
     $tmp = array();
     foreach ($custom_data_payment_address as $key => $value) {
         $tmp['payment_' . $key] = $value;
     }
     $custom_data_payment_address = $tmp;
     $tmp = null;
     $custom_data_shipping_address = array();
     if (!$shipping_address_same) {
         $custom_data_order_2 = $this->simple->get_custom_data_for_object(Simple::SET_CHECKOUT_ADDRESS, Simple::OBJECT_TYPE_ORDER);
         $custom_data_shipping_address = $this->simple->get_custom_data_for_object(Simple::SET_CHECKOUT_ADDRESS, Simple::OBJECT_TYPE_ADDRESS);
         $tmp = array();
         foreach ($custom_data_shipping_address as $key => $value) {
             $tmp['shipping_' . $key] = $value;
         }
         $custom_data_shipping_address = $tmp;
         $tmp = null;
     }
     $data = array_merge($data, $custom_data_order_1, $custom_data_order_2, $custom_data_customer, $custom_data_payment_address, $custom_data_shipping_address);
     $data['simple'] = array();
     $data['simple']['order'] = $this->simple->get_custom_data(Simple::SET_CHECKOUT_CUSTOMER, Simple::OBJECT_TYPE_ORDER);
     $data['simple']['customer'] = $this->simple->get_custom_data(Simple::SET_CHECKOUT_CUSTOMER, Simple::OBJECT_TYPE_CUSTOMER);
     $data['simple']['payment_address'] = $this->simple->get_custom_data(Simple::SET_CHECKOUT_CUSTOMER, Simple::OBJECT_TYPE_ADDRESS);
     if (!$shipping_address_same) {
         $data['simple']['order'] = $this->simple->get_custom_data(Simple::SET_CHECKOUT_ADDRESS, Simple::OBJECT_TYPE_ADDRESS);
         $data['simple']['shipping_address'] = $this->simple->get_custom_data(Simple::SET_CHECKOUT_ADDRESS, Simple::OBJECT_TYPE_ADDRESS);
     }
     $this->load->model('checkout/order');
     $order_id = 0;
     if ($version < 152) {
         $order_id = $this->model_checkout_order->create($data);
         // Gift Voucher
         if (isset($this->session->data['vouchers']) && is_array($this->session->data['vouchers'])) {
             $this->load->model('checkout/voucher');
             foreach ($this->session->data['vouchers'] as $voucher) {
                 $this->model_checkout_voucher->addVoucher($order_id, $voucher);
             }
         }
     } elseif ($version >= 152) {
         $order_id = $this->model_checkout_order->addOrder($data);
     }
     $this->session->data['order_id'] = $order_id;
     return $order_id;
 }
Beispiel #10
0
 public function get_payment_methods($payment_address, $total, $to_deposit = false)
 {
     // Payment Methods
     $method_data = array();
     $this->load->model('setting/extension');
     $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('payment');
     $cart_has_recurring = $this->cart->hasRecurringProducts();
     foreach ($results as $result) {
         $code = $result['code'];
         if ($this->config->get($code . '_status')) {
             if ($code == 'multi_pay' || $code == 'code') {
                 continue;
             }
             $this->load->model('payment/' . $code);
             if ($to_deposit) {
                 /// если ищем способы для пополнения депозита
                 // то найдем те у кого есть метод get_info
                 if (method_exists($this->{'model_payment_' . $code}, 'get_info')) {
                     $method = $this->{'model_payment_' . $code}->get_info();
                 } else {
                     continue;
                 }
             } else {
                 $method = $this->{'model_payment_' . $code}->getMethod($payment_address, $total);
             }
             if ($method) {
                 if ($cart_has_recurring > 0) {
                     if (method_exists($this->{'model_payment_' . $code}, 'recurringPayments')) {
                         if ($this->{'model_payment_' . $code}->recurringPayments() == true) {
                             $method_data[$code] = $method;
                         }
                     }
                 } elseif ($to_deposit) {
                     // если на входе отбирать только для пополнения депозита
                     if (_g($method, 'to_deposit')) {
                         $method_data[$code] = $method;
                     }
                 } else {
                     $method_data[$code] = $method;
                 }
             }
         }
     }
     $sort_order = array();
     foreach ($method_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $method_data);
     return $method_data;
 }
Beispiel #11
0
 public function update()
 {
     //        $this->log->write(print_r($this->request->request, true));
     $this->language->load('checkout/cart');
     $json = array();
     if (isset($this->request->post['product_id'])) {
         $this->load->model('catalog/product');
         //            $this->log->write("Getting product info");
         $product_info = $this->model_catalog_product->getProduct($this->request->post['product_id']);
         //            $this->log->write(print_r($product_info, true));
         if ($product_info) {
             if (empty($this->request->post['quantity'])) {
                 $quantity = 1;
             } else {
                 $quantity = $this->request->post['quantity'];
             }
             $product_total = 0;
             $products = $this->cart->getProducts();
             foreach ($products as $product_2) {
                 if ($product_2['product_id'] == $this->request->post['product_id']) {
                     $product_total += $product_2['quantity'];
                 }
             }
             if ($product_info['minimum'] > $product_total + $quantity) {
                 $json['error']['warning'] = sprintf($this->language->get('error_minimum'), $product_info['name'], $product_info['minimum']);
             }
             if (empty($this->request->post['option'])) {
                 $option = array();
             } else {
                 $option = array_filter($this->request->post['option']);
             }
             $product_options = $this->model_catalog_product->getProductOptions($this->request->post['product_id']);
             foreach ($product_options as $product_option) {
                 if ($product_option['required'] && (empty($this->request->post['option'][$product_option['product_option_id']]) || !$this->request->post['option'][$product_option['product_option_id']])) {
                     $json['error'][$product_option['product_option_id']] = sprintf($this->language->get('error_required'), $product_option['name']);
                 }
             }
         }
         if (!isset($json['error'])) {
             //                $this->log->write(print_r($option, true));
             $this->cart->add($this->request->post['product_id'], $this->parameters['itemPrice'], $quantity, $option);
             $json['success'] = sprintf($this->language->get('text_success'), $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']), $product_info['name'], $this->url->link('checkout/cart'));
             unset($this->session->data['shipping_methods']);
             unset($this->session->data['shipping_method']);
             unset($this->session->data['payment_methods']);
             unset($this->session->data['payment_method']);
         } else {
             $json['redirect'] = str_replace('&amp;', '&', $this->url->link('product/product', 'product_id=' . $this->request->post['product_id']));
         }
     }
     if (isset($this->request->post['remove'])) {
         $this->cart->remove($this->request->post['remove']);
         unset($this->session->data['shipping_methods']);
         unset($this->session->data['shipping_method']);
         unset($this->session->data['payment_methods']);
         unset($this->session->data['payment_method']);
     }
     if (isset($this->request->post['voucher'])) {
         if ($this->session->data['vouchers'][$this->request->post['voucher']]) {
             unset($this->session->data['vouchers'][$this->request->post['voucher']]);
         }
     }
     $this->load->model('tool/image');
     $this->data['text_empty'] = $this->language->get('text_empty');
     $this->data['button_checkout'] = $this->language->get('button_checkout');
     $this->data['button_remove'] = $this->language->get('button_remove');
     $this->data['products'] = array();
     foreach ($this->cart->getProducts() as $result) {
         if ($result['image']) {
             $image = $this->model_tool_image->resize($result['image'], 40, 40);
         } else {
             $image = '';
         }
         $option_data = array();
         //            $this->log->write(print_r($result['option'], true));
         foreach ($result['option'] as $option) {
             if ($option['type'] != 'file') {
                 $option_data[] = array('name' => $option['name'], 'value' => utf8_truncate($option['option_value']));
             } else {
                 $this->load->library('encryption');
                 $encryption = new Encryption($this->config->get('config_encryption'));
                 $file = substr($encryption->decrypt($option['option_value']), 0, strrpos($encryption->decrypt($option['option_value']), '.'));
                 $option_data[] = array('name' => $option['name'], 'value' => utf8_truncate($file));
             }
         }
         if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
             $price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $price = false;
         }
         if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
             $total = $this->currency->format($this->tax->calculate($result['total'], $result['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $total = false;
         }
         $this->data['products'][] = array('key' => $result['key'], 'product_id' => $result['product_id'], 'thumb' => $image, 'name' => $result['name'], 'model' => $result['model'], 'option' => $option_data, 'quantity' => $result['quantity'], 'stock' => $result['stock'], 'price' => $price, 'total' => $total, 'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']));
     }
     // Gift Voucher
     $this->data['vouchers'] = array();
     if (isset($this->session->data['vouchers']) && $this->session->data['vouchers']) {
         foreach ($this->session->data['vouchers'] as $key => $voucher) {
             $this->data['vouchers'][] = array('key' => $key, 'description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount']));
         }
     }
     // Calculate Totals
     $total_data = array();
     $total = 0;
     $taxes = $this->cart->getTaxes();
     if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
         $this->load->model('setting/extension');
         $sort_order = array();
         $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('total');
         foreach ($results as $key => $value) {
             $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
         }
         array_multisort($sort_order, SORT_ASC, $results);
         foreach ($results as $result) {
             if ($this->config->get($result['code'] . '_status')) {
                 $this->load->model('total/' . $result['code']);
                 $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
             }
         }
         $sort_order = array();
         foreach ($total_data as $key => $value) {
             $sort_order[$key] = $value['sort_order'];
         }
         array_multisort($sort_order, SORT_ASC, $total_data);
     }
     $json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
     $json['total_data'] = sprintf($this->language->get('text_items_data'), $this->cart->countProducts());
     $this->data['totals'] = $total_data;
     $this->data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');
     $templateName = '/template/common/cart.tpl.php';
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . $templateName)) {
         $this->template = $this->config->get('config_template') . $templateName;
     } else {
         $this->template = 'default' . $templateName;
     }
     $json['output'] = $this->render();
     $this->getResponse()->setOutput(json_encode($json));
 }
Beispiel #12
0
 public function quote()
 {
     $this->language->load('total/shipping');
     $json = array();
     if (!$this->cart->hasProducts()) {
         $json['redirect'] = $this->url->link('checkout/cart');
     }
     if (isset($this->request->post['country_id']) && isset($this->request->post['zone_id']) && isset($this->request->post['postcode'])) {
         if ($this->request->post['country_id'] == '') {
             $json['error']['country'] = $this->language->get('error_country');
         }
         if ($this->request->post['zone_id'] == '') {
             $json['error']['zone'] = $this->language->get('error_zone');
         }
         $this->load->model('localisation/country');
         $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
         if ($country_info && $country_info['postcode_required'] && utf8_strlen($this->request->post['postcode']) < 2 || utf8_strlen($this->request->post['postcode']) > 10) {
             $json['error']['postcode'] = $this->language->get('error_postcode');
         }
         if (!isset($json['error'])) {
             $this->tax->setShippingAddress($this->request->post['country_id'], $this->request->post['zone_id']);
             $this->session->data['guest']['shipping']['country_id'] = $this->request->post['country_id'];
             $this->session->data['guest']['shipping']['zone_id'] = $this->request->post['zone_id'];
             $this->session->data['guest']['shipping']['postcode'] = $this->request->post['postcode'];
             if ($country_info) {
                 $country = $country_info['name'];
                 $iso_code_2 = $country_info['iso_code_2'];
                 $iso_code_3 = $country_info['iso_code_3'];
                 $address_format = $country_info['address_format'];
             } else {
                 $country = '';
                 $iso_code_2 = '';
                 $iso_code_3 = '';
                 $address_format = '';
             }
             $this->load->model('localisation/zone');
             $zone_info = $this->model_localisation_zone->getZone($this->request->post['zone_id']);
             if ($zone_info) {
                 $zone = $zone_info['name'];
                 $code = $zone_info['code'];
             } else {
                 $zone = '';
                 $code = '';
             }
             $address_data = array('firstname' => '', 'lastname' => '', 'company' => '', 'address_1' => '', 'address_2' => '', 'postcode' => $this->request->post['postcode'], 'city' => '', 'zone_id' => $this->request->post['zone_id'], 'zone' => $zone, 'zone_code' => $code, 'country_id' => $this->request->post['country_id'], 'country' => $country, 'iso_code_2' => $iso_code_2, 'iso_code_3' => $iso_code_3, 'address_format' => $address_format);
             $quote_data = array();
             $this->load->model('setting/extension');
             $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('shipping');
             foreach ($results as $result) {
                 if ($this->config->get($result->getCode() . '_status')) {
                     $quote = ShippingMethodDAO::getInstance()->getMethod($result->getCode())->getQuote($address_data);
                     if ($quote) {
                         $quote_data[$result->getCode()] = array('title' => $quote['title'], 'quote' => $quote['quote'], 'sort_order' => $quote['sort_order'], 'error' => $quote['error']);
                     }
                 }
             }
             $sort_order = array();
             foreach ($quote_data as $key => $value) {
                 $sort_order[$key] = $value['sort_order'];
             }
             array_multisort($sort_order, SORT_ASC, $quote_data);
             $this->session->data['shipping_methods'] = $quote_data;
             if (isset($this->session->data['shipping_methods'])) {
                 $json['shipping_methods'] = $this->session->data['shipping_methods'];
             }
             if (!isset($this->session->data['shipping_methods']) || !$this->session->data['shipping_methods']) {
                 $json['error']['warning'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact'));
             }
         }
     }
     $this->getResponse()->setOutput(json_encode($json));
 }
Beispiel #13
0
 public function index()
 {
     //        $this->log->write("Opening checkout/shipping");
     $this->language->load('checkout/checkout');
     $json = array();
     $this->load->model('account/address');
     if ($this->customer->isLogged()) {
         $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']);
     } elseif (isset($this->session->data['guest'])) {
         $shipping_address = $this->session->data['guest']['shipping'];
     }
     if (empty($shipping_address)) {
         $json['redirect'] = $this->url->link('checkout/checkout', '', 'SSL');
     }
     if (!$this->cart->hasProducts() && (!isset($this->session->data['vouchers']) || !$this->session->data['vouchers']) || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
         $json['redirect'] = $this->url->link('checkout/cart');
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         if (!$json) {
             if (!isset($this->request->post['shipping_method'])) {
                 $json['error']['warning'] = $this->language->get('error_shipping');
             } else {
                 $shipping = explode('.', $this->request->post['shipping_method']);
                 if (!isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
                     $json['error']['warning'] = $this->language->get('error_shipping');
                 }
             }
         }
         if (!$json) {
             $shipping = explode('.', $this->request->post['shipping_method']);
             $this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]];
             $this->session->data['comment'] = strip_tags($this->request->post['comment']);
         }
     } else {
         if (isset($shipping_address)) {
             if (!isset($this->session->data['shipping_methods'])) {
                 $quote_data = array();
                 $this->load->model('setting/extension');
                 $this->load->model('localisation/description');
                 $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('shipping');
                 $this->log->write(print_r($results, true));
                 //print_r($results); die();
                 foreach ($results as $result) {
                     $shippingMethod = ShippingMethodDAO::getInstance()->getMethod($result->getCode());
                     if ($shippingMethod->isEnabled()) {
                         //						if ($this->config->get($result['code'] . '_status')) {
                         //                            $this->log->write("Trying to load shipping/" . $result['code']);
                         //							$this->load->model('shipping/' . $result['code']);
                         $quote = $shippingMethod->getQuote($shipping_address);
                         //                            $this->log->write(print_r($quote, true));
                         if ($quote) {
                             //$res = $this->model_localisation_description->getDescription(null, $quote['quote'][$result['code']]['title']);
                             //$tempArr = reset($quote['quote']);
                             //$desc = '' . print_r($tempArr[@description], true);
                             //print_r($quote['quote']); die();
                             $quote_data[$result->getCode()] = array('title' => $quote['title'], 'quote' => $quote['quote'], 'sort_order' => $quote['sort_order'], 'error' => $quote['error']);
                         }
                     }
                 }
                 $sort_order = array();
                 foreach ($quote_data as $key => $value) {
                     $sort_order[$key] = $value['sort_order'];
                 }
                 array_multisort($sort_order, SORT_ASC, $quote_data);
                 //print_r($quote_data); die();
                 $this->session->data['shipping_methods'] = $quote_data;
             }
         }
         $this->data['text_shipping_method'] = $this->language->get('text_shipping_method');
         $this->data['text_comments'] = $this->language->get('text_comments');
         $this->data['button_continue'] = $this->language->get('button_continue');
         if (isset($this->session->data['shipping_methods']) && !$this->session->data['shipping_methods']) {
             $this->data['error_warning'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact'));
         } else {
             $this->data['error_warning'] = '';
         }
         if (isset($this->session->data['shipping_methods'])) {
             $this->data['shipping_methods'] = $this->session->data['shipping_methods'];
         } else {
             $this->data['shipping_methods'] = array();
         }
         if (isset($this->session->data['shipping_method']['code'])) {
             $this->data['code'] = $this->session->data['shipping_method']['code'];
         } else {
             $this->data['code'] = '';
         }
         if (isset($this->session->data['comment'])) {
             $this->data['comment'] = $this->session->data['comment'];
         } else {
             $this->data['comment'] = '';
         }
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/shipping.tpl.php')) {
             $this->template = $this->config->get('config_template') . '/template/checkout/shipping.tpl.php';
         } else {
             $this->template = 'default/template/checkout/shipping.tpl.php';
         }
         $json['output'] = $this->render();
     }
     //$this->log->write(print_r($json, true));
     $this->getResponse()->setOutput(json_encode($json));
 }
 public function index()
 {
     $this->language->load('checkout/cart');
     $this->language->load('checkout/simplecheckout');
     if ($this->config->get('config_customer_price') && !$this->customer->isLogged()) {
         $this->data['attention'] = sprintf($this->language->get('text_login'), $this->url->link('account/login'), $this->url->link('account/simpleregister'));
         $this->simple->block_order = true;
         $this->simple->add_error('cart');
     } else {
         $this->data['attention'] = '';
     }
     $this->data['error_warning'] = '';
     if (isset(self::$error['warning'])) {
         $this->data['error_warning'] = self::$error['warning'];
     }
     if (!$this->cart->hasStock()) {
         if ($this->config->get('config_stock_warning')) {
             $this->data['error_warning'] = $this->language->get('error_stock');
         }
         if (!$this->config->get('config_stock_checkout')) {
             $this->data['error_warning'] = $this->language->get('error_stock');
             $this->simple->block_order = true;
             $this->simple->add_error('cart');
         }
     }
     $use_total = $this->config->get('simple_use_total');
     $min_amount = $this->config->get('simple_min_amount');
     $max_amount = $this->config->get('simple_max_amount');
     $min_quantity = $this->config->get('simple_min_quantity');
     $max_quantity = $this->config->get('simple_max_quantity');
     $min_weight = $this->config->get('simple_min_weight');
     $max_weight = $this->config->get('simple_max_weight');
     if (!empty($min_amount) || !empty($max_amount)) {
         if ($use_total) {
             $cart_subtotal = $this->cart->getTotal();
         } else {
             $cart_subtotal = $this->cart->getSubTotal();
         }
     }
     if (!empty($this->session->data['vouchers'])) {
         foreach ($this->session->data['vouchers'] as $key => $voucher) {
             $cart_subtotal += $voucher['amount'];
         }
     }
     $cart_quantity = $this->cart->countProducts();
     $cart_weight = $this->cart->getWeight();
     $this->data['quantity'] = $cart_quantity;
     if (!empty($min_amount) && $min_amount > $cart_subtotal) {
         $this->simple->block_order = true;
         $this->simple->add_error('cart');
         $this->data['error_warning'] = sprintf($this->language->get('error_min_amount'), $this->currency->format($min_amount));
     }
     if (!empty($max_amount) && $max_amount < $cart_subtotal) {
         $this->simple->block_order = true;
         $this->simple->add_error('cart');
         $this->data['error_warning'] = sprintf($this->language->get('error_max_amount'), $this->currency->format($max_amount));
     }
     if (!empty($min_quantity) && $min_quantity > $cart_quantity) {
         $this->simple->block_order = true;
         $this->simple->add_error('cart');
         $this->data['error_warning'] = sprintf($this->language->get('error_min_quantity'), $min_quantity);
     }
     if (!empty($max_quantity) && $max_quantity < $cart_quantity) {
         $this->simple->block_order = true;
         $this->simple->add_error('cart');
         $this->data['error_warning'] = sprintf($this->language->get('error_max_quantity'), $max_quantity);
     }
     if (!empty($min_weight) && !empty($cart_weight) && $min_weight > $cart_weight) {
         $this->simple->block_order = true;
         $this->simple->add_error('cart');
         $this->data['error_warning'] = sprintf($this->language->get('error_min_weight'), $min_weight);
     }
     if (!empty($max_weight) && !empty($cart_weight) && $max_weight < $cart_weight) {
         $this->simple->block_order = true;
         $this->simple->add_error('cart');
         $this->data['error_warning'] = sprintf($this->language->get('error_max_weight'), $max_weight);
     }
     $this->data['action'] = $this->url->link('checkout/simplecheckout_cart');
     $this->load->model('tool/image');
     $this->load->library('encryption');
     $this->data['column_image'] = $this->language->get('column_image');
     $this->data['column_name'] = $this->language->get('column_name');
     $this->data['column_model'] = $this->language->get('column_model');
     $this->data['column_quantity'] = $this->language->get('column_quantity');
     $this->data['column_price'] = $this->language->get('column_price');
     $this->data['column_total'] = $this->language->get('column_total');
     $this->data['text_until_cancelled'] = $this->language->get('text_until_cancelled');
     $this->data['text_freq_day'] = $this->language->get('text_freq_day');
     $this->data['text_freq_week'] = $this->language->get('text_freq_week');
     $this->data['text_freq_month'] = $this->language->get('text_freq_month');
     $this->data['text_freq_bi_month'] = $this->language->get('text_freq_bi_month');
     $this->data['text_freq_year'] = $this->language->get('text_freq_year');
     $this->data['text_trial'] = $this->language->get('text_trial');
     $this->data['text_recurring'] = $this->language->get('text_recurring');
     $this->data['text_length'] = $this->language->get('text_length');
     $this->data['text_recurring_item'] = $this->language->get('text_recurring_item');
     $this->data['text_payment_profile'] = $this->language->get('text_payment_profile');
     $this->data['button_update'] = $this->language->get('button_update');
     $this->data['products'] = array();
     $this->data['config_stock_warning'] = $this->config->get('config_stock_warning');
     $this->data['config_stock_checkout'] = $this->config->get('config_stock_checkout');
     $this->data['products'] = array();
     $products = $this->cart->getProducts();
     $points_total = 0;
     $version = $this->simple->opencart_version;
     foreach ($products as $product) {
         $product_total = 0;
         foreach ($products as $product_2) {
             if ($product_2['product_id'] == $product['product_id']) {
                 $product_total += $product_2['quantity'];
             }
         }
         if ($product['minimum'] > $product_total) {
             $this->data['error_warning'] = sprintf($this->language->get('error_minimum'), $product['name'], $product['minimum']);
             $this->simple->block_order = true;
             $this->simple->add_error('cart');
         }
         $option_data = array();
         foreach ($product['option'] as $option) {
             if ($option['type'] != 'file') {
                 $value = $option['option_value'];
             } else {
                 $encryption = new Encryption($this->config->get('config_encryption'));
                 $option_value = $encryption->decrypt($option['option_value']);
                 $filename = substr($option_value, 0, strrpos($option_value, '.'));
                 $value = $filename;
             }
             $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value);
         }
         if ($product['image']) {
             $image_cart_width = $this->config->get('config_image_cart_width');
             $image_cart_width = $image_cart_width ? $image_cart_width : 40;
             $image_cart_height = $this->config->get('config_image_cart_height');
             $image_cart_height = $image_cart_height ? $image_cart_height : 40;
             $image = $this->model_tool_image->resize($product['image'], $image_cart_width, $image_cart_height);
         } else {
             $image = '';
         }
         if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
             $price = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')));
         } else {
             $price = false;
         }
         if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
             $total = $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity']);
         } else {
             $total = false;
         }
         if ($version >= 156) {
             $profile_description = '';
             if ($product['recurring']) {
                 $frequencies = array('day' => $this->language->get('text_day'), 'week' => $this->language->get('text_week'), 'semi_month' => $this->language->get('text_semi_month'), 'month' => $this->language->get('text_month'), 'year' => $this->language->get('text_year'));
                 if ($product['recurring_trial']) {
                     $recurring_price = $this->currency->format($this->tax->calculate($product['recurring_trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')));
                     $profile_description = sprintf($this->language->get('text_trial_description'), $recurring_price, $product['recurring_trial_cycle'], $frequencies[$product['recurring_trial_frequency']], $product['recurring_trial_duration']) . ' ';
                 }
                 $recurring_price = $this->currency->format($this->tax->calculate($product['recurring_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax')));
                 if ($product['recurring_duration']) {
                     $profile_description .= sprintf($this->language->get('text_payment_description'), $recurring_price, $product['recurring_cycle'], $frequencies[$product['recurring_frequency']], $product['recurring_duration']);
                 } else {
                     $profile_description .= sprintf($this->language->get('text_payment_until_canceled_description'), $recurring_price, $product['recurring_cycle'], $frequencies[$product['recurring_frequency']], $product['recurring_duration']);
                 }
             }
             $this->data['products'][] = array('key' => $product['key'], 'thumb' => $image, 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'stock' => $product['stock'], 'reward' => $product['reward'] ? sprintf($this->language->get('text_reward'), $product['reward']) : '', 'price' => $price, 'total' => $total, 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']), 'recurring' => $product['recurring'], 'profile_name' => $product['profile_name'], 'profile_description' => $profile_description);
         } else {
             $this->data['products'][] = array('key' => $product['key'], 'thumb' => $image, 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'stock' => $product['stock'], 'reward' => $product['reward'] ? sprintf($this->language->get('text_reward'), $product['reward']) : '', 'price' => $price, 'total' => $total, 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']));
         }
         if ($product['points']) {
             $points_total += $product['points'];
         }
     }
     // Gift Voucher
     $this->data['vouchers'] = array();
     if (!empty($this->session->data['vouchers'])) {
         foreach ($this->session->data['vouchers'] as $key => $voucher) {
             $this->data['vouchers'][] = array('key' => $key, 'description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount']));
         }
     }
     $total_data = array();
     $total = 0;
     $taxes = $this->cart->getTaxes();
     $this->data['modules'] = array();
     if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
         $this->load->model('setting/extension');
         $sort_order = array();
         $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('total');
         foreach ($results as $key => $value) {
             $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
         }
         array_multisort($sort_order, SORT_ASC, $results);
         foreach ($results as $result) {
             if ($this->config->get($result['code'] . '_status')) {
                 $this->load->model('total/' . $result['code']);
                 $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
                 $this->data['modules'][$result['code']] = true;
             }
         }
         $sort_order = array();
         foreach ($total_data as $key => $value) {
             $sort_order[$key] = $value['sort_order'];
         }
         array_multisort($sort_order, SORT_ASC, $total_data);
     }
     $this->data['totals'] = $total_data;
     $this->data['entry_coupon'] = $this->language->get('entry_coupon');
     $this->data['entry_voucher'] = $this->language->get('entry_voucher');
     $points = $this->customer->getRewardPoints();
     $points_to_use = $points > $points_total ? $points_total : $points;
     $this->data['points'] = $points_to_use;
     $this->data['entry_reward'] = sprintf($this->language->get('entry_reward'), $points_to_use);
     $this->data['reward'] = isset($this->session->data['reward']) ? $this->session->data['reward'] : '';
     $this->data['voucher'] = isset($this->session->data['voucher']) ? $this->session->data['voucher'] : '';
     $this->data['coupon'] = isset($this->session->data['coupon']) ? $this->session->data['coupon'] : '';
     $this->data['simple_show_weight'] = $this->config->get('simple_show_weight');
     $this->data['simple'] = $this->simple;
     if ($this->data['simple_show_weight']) {
         $this->data['weight'] = $this->weight->format($this->cart->getWeight(), $this->config->get('config_weight_class_id'), $this->language->get('decimal_point'), $this->language->get('thousand_point'));
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/simplecheckout_cart.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/checkout/simplecheckout_cart.tpl';
         $this->data['template'] = $this->config->get('config_template');
     } else {
         $this->template = 'default/template/checkout/simplecheckout_cart.tpl';
         $this->data['template'] = 'default';
     }
     $current_theme = $this->config->get('config_template');
     if ($current_theme == 'shoppica' || $current_theme == 'shoppica2') {
         $this->data['cart_total'] = $this->currency->format($total);
     } else {
         $this->data['cart_total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
     }
     if ($this->simple->get_simple_steps() && $this->simple->get_simple_steps_summary()) {
         $this->set_summary_info();
     }
     $this->response->setOutput($this->render());
 }
Beispiel #15
0
 public function uninstall()
 {
     if (!$this->user->hasPermission('modify', 'extension/shipping')) {
         $this->session->data['error'] = $this->language->get('error_permission');
         $this->redirect($this->url->link('extension/shipping', 'token=' . $this->session->data['token'], 'SSL'));
     } else {
         $this->load->model('setting/extension');
         \model\setting\ExtensionDAO::getInstance()->uninstall('shipping', $this->request->get['extension']);
         SettingsDAO::getInstance()->deleteSettings($this->request->get['extension']);
         require_once DIR_APPLICATION . 'controller/shipping/' . $this->request->get['extension'] . '.php';
         $class = 'ControllerShipping' . str_replace('_', '', $this->request->get['extension']);
         $class = new $class($this->registry);
         if (method_exists($class, 'uninstall')) {
             $class->uninstall();
         }
         $this->redirect($this->url->link('extension/shipping', 'token=' . $this->session->data['token'], 'SSL'));
     }
 }
 public function index()
 {
     if (!$this->cart->hasShipping()) {
         return;
     }
     $this->language->load('checkout/simplecheckout');
     $this->data['address_empty'] = false;
     $address = $this->simple->shipping_address;
     $address_fields = $this->simple->shipping_address_fields;
     $reload = explode(',', $this->config->get('simple_set_for_reload'));
     if ($address['country_id'] == '' && in_array('main_country_id', $reload) && !empty($address_fields['main_country_id']) && $address_fields['main_country_id']['type'] != 'hidden') {
         $this->data['address_empty'] = true;
     }
     if ($address['zone_id'] === '' && in_array('main_zone_id', $reload) && !empty($address_fields['main_zone_id']) && $address_fields['main_zone_id']['type'] != 'hidden') {
         $this->data['address_empty'] = true;
     }
     if ($address['city'] == '' && in_array('main_city', $reload) && !empty($address_fields['main_city']) && $address_fields['main_city']['type'] != 'hidden') {
         $this->data['address_empty'] = true;
     }
     if ($address['postcode'] == '' && in_array('main_postcode', $reload) && !empty($address_fields['main_postcode']) && $address_fields['main_postcode']['type'] != 'hidden') {
         $this->data['address_empty'] = true;
     }
     $this->data['simple_debug'] = $this->config->get('simple_debug');
     $this->data['address'] = $address;
     $this->data['simple_shipping_view_title'] = $this->config->get('simple_shipping_view_title');
     $this->data['simple_shipping_view_address_empty'] = $this->config->get('simple_shipping_view_address_empty');
     $simple_shipping_view_address_full = $this->config->get('simple_shipping_view_address_full');
     $simple_shipping_view_autoselect_first = $this->config->get('simple_shipping_methods_hide') ? true : $this->config->get('simple_shipping_view_autoselect_first');
     $simple_shipping_methods_hide = $this->config->get('simple_shipping_methods_hide');
     if ($this->customer->isLogged()) {
         $customer_group_id = $this->customer->getCustomerGroupId();
     } else {
         $customer_group_id = $this->config->get('config_customer_group_id');
     }
     if ($this->config->get('simple_customer_view_customer_type')) {
         $customer_groups = $this->simple->get_customer_groups();
         if (isset($this->request->post['customer_group_id']) && array_key_exists($this->request->post['customer_group_id'], $customer_groups)) {
             $customer_group_id = $this->request->post['customer_group_id'];
         }
     }
     $filter_methods = array();
     $simple_group_shipping = $this->config->get('simple_group_shipping');
     if (!empty($simple_group_shipping[$customer_group_id])) {
         $filter_methods = explode(',', $simple_group_shipping[$customer_group_id]);
     }
     $this->data['shipping_methods'] = array();
     $quote_data = array();
     $this->load->model('setting/extension');
     $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('shipping');
     $simple_shipping_titles = $this->config->get('simple_shipping_titles');
     $simple_links = $this->config->get('simple_links_2');
     $simple_links = !empty($simple_links) && is_array($simple_links) ? $simple_links : array();
     $payment_method_code = false;
     if ($this->config->get('simple_childs_payment_first')) {
         $payment_method = $this->simple->payment_method;
         $payment_method_code = !empty($payment_method['code']) ? $payment_method['code'] : false;
     }
     foreach ($results as $result) {
         $show_module = true;
         if ($this->data['address_empty'] && !empty($simple_shipping_view_address_full[$result['code']])) {
             $show_module = false;
         }
         if (is_array($filter_methods) && !empty($filter_methods)) {
             if (in_array($result['code'], $filter_methods)) {
                 $show_module = true;
             } else {
                 $show_module = false;
             }
         }
         if ($this->config->get($result['code'] . '_status') && $show_module) {
             $for_payment_methods = array();
             if ($this->config->get('simple_childs_payment_first') && !empty($simple_links[$result['code']])) {
                 $for_payment_methods = explode(",", $simple_links[$result['code']]);
             }
             if (empty($for_payment_methods) || $payment_method_code && in_array($payment_method_code, $for_payment_methods)) {
                 $quote = ShippingMethodDAO::getInstance()->getMethod($result['code'])->getQuote($address);
                 if ($quote) {
                     $quote_data[$result['code']] = array('title' => $quote['title'], 'quote' => $quote['quote'], 'sort_order' => $quote['sort_order'], 'error' => $quote['error'], 'warning' => isset($quote['warning']) ? $quote['warning'] : '', 'description' => !empty($simple_shipping_titles[$result['code']]['use_description']) && !empty($simple_shipping_titles[$result['code']]['description'][$this->simple->get_language_code()]) ? html_entity_decode($simple_shipping_titles[$result['code']]['description'][$this->simple->get_language_code()]) : '');
                 }
             }
         }
     }
     $sort_order = array();
     foreach ($quote_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $quote_data);
     $this->data['shipping_methods'] = $quote_data;
     $this->data['shipping_method'] = null;
     $this->data['error_warning'] = '';
     $this->data['checked_code'] = '';
     $this->data['disabled_methods'] = array();
     if (!empty($simple_shipping_titles)) {
         foreach ($simple_shipping_titles as $key => $value) {
             if (!array_key_exists($key, $this->data['shipping_methods']) && !empty($value['show']) && ($value['show'] == 1 || $value['show'] == 2 && $this->data['address_empty'])) {
                 $this->data['disabled_methods'][$key]['title'] = !empty($value['title'][$this->simple->get_language_code()]) ? html_entity_decode($value['title'][$this->simple->get_language_code()]) : $key;
                 $this->data['disabled_methods'][$key]['description'] = !empty($value['description'][$this->simple->get_language_code()]) ? html_entity_decode($value['description'][$this->simple->get_language_code()]) : '';
             }
         }
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && !empty($this->request->post['shipping_method_checked'])) {
         $shipping = explode('.', $this->request->post['shipping_method_checked']);
         if (isset($this->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
             $this->data['checked_code'] = $this->request->post['shipping_method_checked'];
         }
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['shipping_method'])) {
         $shipping = explode('.', $this->request->post['shipping_method']);
         if (isset($this->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
             $this->data['shipping_method'] = $this->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]];
             if (isset($this->request->post['shipping_method_current']) && $this->request->post['shipping_method_current'] != $this->request->post['shipping_method']) {
                 $this->data['checked_code'] = $this->request->post['shipping_method'];
             }
         }
     }
     if ($this->request->server['REQUEST_METHOD'] == 'GET' && (isset($this->session->data['shipping_method']) || isset($this->request->cookie['shipping_method']))) {
         $user_checked = false;
         if (isset($this->session->data['shipping_method'])) {
             $shipping = explode('.', $this->session->data['shipping_method']['code']);
             $user_checked = true;
         } elseif (isset($this->request->cookie['shipping_method'])) {
             $shipping = explode('.', $this->request->cookie['shipping_method']);
         }
         if (isset($this->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) {
             $this->data['shipping_method'] = $this->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]];
             if ($user_checked) {
                 $this->data['checked_code'] = $this->session->data['shipping_method']['code'];
             }
         }
     }
     if (!empty($this->data['shipping_methods'])) {
         $first = reset($this->data['shipping_methods']);
         if (!empty($first['quote'])) {
             $first_method = reset($first['quote']);
         }
     }
     if (!empty($first_method) && ($simple_shipping_methods_hide || $simple_shipping_view_autoselect_first && $this->data['checked_code'] == '')) {
         $this->data['shipping_method'] = $first_method;
     }
     if (isset($this->data['shipping_method'])) {
         setcookie('shipping_method', $this->data['shipping_method']['code'], time() + 60 * 60 * 24 * 30);
     }
     $this->data['code'] = !empty($this->data['shipping_method']) ? $this->data['shipping_method']['code'] : '';
     $this->simple->shipping_methods = $this->data['shipping_methods'];
     $this->simple->shipping_method = $this->data['shipping_method'];
     $this->data['simple_show_errors'] = !empty($this->request->post['simple_create_order']) || !empty($this->request->post['simple_step_next']) && !empty($this->request->post['simple_step']) && $this->request->post['simple_step'] == 'simplecheckout_shipping';
     $this->validate();
     $this->save_to_session();
     $this->data['text_checkout_shipping_method'] = $this->language->get('text_checkout_shipping_method');
     $this->data['text_shipping_address'] = $this->language->get('text_shipping_address');
     $this->data['error_no_shipping'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact'));
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/simplecheckout_shipping.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/checkout/simplecheckout_shipping.tpl';
     } else {
         $this->template = 'default/template/checkout/simplecheckout_shipping.tpl';
     }
     $this->response->setOutput($this->render());
 }
 public function index()
 {
     //		$this->getLoader()->model('design/layout');
     $this->getLoader()->model('catalog/category');
     $this->getLoader()->model('catalog/product');
     $this->getLoader()->model('catalog/information');
     $this->language->load('common/calendar');
     $this->data['text_our_holidays'] = $this->language->get('text_our_holidays');
     $this->data['text_workday'] = $this->language->get('text_workday');
     $this->data['text_holiday'] = $this->language->get('text_holiday');
     $this->language->load('common/header');
     $this->data['text_auction'] = $this->language->get('text_auction');
     //print_r($photos);
     if ($this->getConfig()->get('wk_auction_timezone_set')) {
         $this->data['menuauction'] = $this->url->link('catalog/wkallauctions', '', 'SSL');
     }
     $this->language->load('shop/general');
     $this->data['text_button_download'] = $this->language->get('text_button_download');
     $this->data['isSaler'] = $this->customer->getCustomerGroupId() == 6;
     $this->data['showDownload'] = false;
     if (empty($_REQUEST['route'])) {
         $_REQUEST['route'] = 'information/specaction';
     }
     if ($_REQUEST['route'] == "product/category" || $_REQUEST['route'] == "information/specaction") {
         $this->data['showDownload'] = true;
     }
     if (isset($this->request->get['route'])) {
         $route = $this->request->get['route'];
     } else {
         $route = 'common/home';
     }
     $this->data['route'] = $route;
     $layout_id = 0;
     if (substr($route, 0, 16) == 'product/category' && isset($this->request->get['path'])) {
         $path = explode('_', (string) $this->request->get['path']);
         $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));
     }
     if (substr($route, 0, 15) == 'product/product' && isset($this->request->get['product_id'])) {
         $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
     }
     if (substr($route, 0, 23) == 'information/information' && isset($this->request->get['information_id'])) {
         $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
     }
     if (!$layout_id) {
         $layout_id = \model\design\LayoutDAO::getInstance()->getLayout($route);
     }
     if (!$layout_id) {
         $layout_id = $this->getConfig()->get('config_layout_id');
     }
     $module_data = array();
     $extensions = \model\setting\ExtensionDAO::getInstance()->getExtensions('module');
     foreach ($extensions as $extension) {
         $modules = $this->getConfig()->get($extension['code'] . '_module');
         if ($modules) {
             foreach ($modules as $module) {
                 if ($module['layout_id'] == $layout_id && $module['position'] == 'special_bottom' && $module['status']) {
                     $module_data[] = array('code' => $extension['code'], 'setting' => $module, 'sort_order' => $module['sort_order']);
                 }
             }
         }
     }
     //print_r($modules); die();
     $sort_order = array();
     foreach ($module_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $module_data);
     $this->data['modules'] = array();
     $module_data = array_reverse($module_data);
     foreach ($module_data as $module) {
         $module = $this->getChild('module/' . $module['code'], $module['setting']);
         if ($module) {
             $this->data['modules'][] = $module;
         }
     }
     if ($route == 'information/specaction') {
         $this->data['photos'] = PhotoDAO::getInstance()->getAllApprovedPhotos();
     }
     //print_r($module_data); die();
     $this->render($this->getConfig()->get('config_template') . '/template/common/special_bottom.tpl');
 }
Beispiel #18
0
 public function index()
 {
     $this->language->load('checkout/checkout');
     $json = array();
     if (!$this->cart->hasProducts() && (!isset($this->session->data['vouchers']) || !$this->session->data['vouchers']) || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
         $json['redirect'] = $this->url->link('checkout/cart');
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         if (isset($this->request->post['account'])) {
             $this->session->data['account'] = $this->request->post['account'];
         }
         if (isset($this->request->post['email']) && isset($this->request->post['password'])) {
             if ($this->customer->login($this->request->post['email'], $this->request->post['password'])) {
                 unset($this->session->data['guest']);
                 // Calculate Totals
                 $total_data = array();
                 $total = 0;
                 $taxes = $this->cart->getTaxes();
                 if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
                     $this->load->model('setting/extension');
                     $sort_order = array();
                     $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('total');
                     foreach ($results as $key => $value) {
                         $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
                     }
                     array_multisort($sort_order, SORT_ASC, $results);
                     foreach ($results as $result) {
                         if ($this->config->get($result['code'] . '_status')) {
                             $this->load->model('total/' . $result['code']);
                             $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes);
                         }
                     }
                     $sort_order = array();
                     foreach ($total_data as $key => $value) {
                         $sort_order[$key] = $value['sort_order'];
                     }
                     array_multisort($sort_order, SORT_ASC, $total_data);
                 }
                 $json['logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', 'SSL'), $this->customer->getFirstName(), $this->url->link('account/logout', '', 'SSL'));
                 $json['total'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
             } else {
                 $json['error']['warning'] = $this->language->get('error_login');
             }
         }
     } else {
         $this->data['text_new_customer'] = $this->language->get('text_new_customer');
         $this->data['text_returning_customer'] = $this->language->get('text_returning_customer');
         $this->data['text_checkout'] = $this->language->get('text_checkout');
         $this->data['text_register'] = $this->language->get('text_register');
         $this->data['text_guest'] = $this->language->get('text_guest');
         $this->data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer');
         $this->data['text_register_account'] = $this->language->get('text_register_account');
         $this->data['text_forgotten'] = $this->language->get('text_forgotten');
         $this->data['entry_email'] = $this->language->get('entry_email');
         $this->data['entry_password'] = $this->language->get('entry_password');
         $this->data['button_continue'] = $this->language->get('button_continue');
         $this->data['button_login'] = $this->language->get('button_login');
         $this->data['guest_checkout'] = $this->config->get('config_guest_checkout') && !$this->config->get('config_customer_price') && !$this->cart->hasDownload();
         if (isset($this->session->data['account'])) {
             $this->data['account'] = $this->session->data['account'];
         } else {
             $this->data['account'] = 'register';
         }
         // loginza
         $this->data['action_loginza'] = urlencode(HTTPS_SERVER . 'index.php?route=account/loginza');
         $this->data['text_enter_with_loginza'] = $this->language->get('text_enter_with_loginza');
         $this->session->data['loginza_redirect'] = $this->url->link('checkout/checkout');
         // loginza
         $this->data['forgotten'] = $this->url->link('account/forgotten', '', 'SSL');
         if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/login.tpl')) {
             $this->template = $this->config->get('config_template') . '/template/checkout/login.tpl';
         } else {
             $this->template = 'default/template/checkout/login.tpl';
         }
         $json['output'] = $this->render();
     }
     $this->getResponse()->setOutput(json_encode($json));
 }
Beispiel #19
0
 protected function index()
 {
     $this->data['title'] = $this->document->getTitle();
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         $this->data['base'] = $this->config->get('config_ssl');
     } else {
         $this->data['base'] = $this->config->get('config_url');
     }
     $this->data['description'] = $this->document->getDescription();
     $this->data['keywords'] = $this->document->getKeywords();
     $this->data['links'] = $this->document->getLinks();
     $this->data['styles'] = $this->document->getStyles();
     $this->data['scripts'] = $this->document->getScripts();
     $this->data['lang'] = $this->language->get('code');
     $this->data['direction'] = $this->language->get('direction');
     $this->data['google_analytics'] = html_entity_decode($this->config->get('config_google_analytics'), ENT_QUOTES, 'UTF-8');
     $this->language->load('common/header');
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         $server = HTTPS_IMAGE;
     } else {
         $server = HTTP_IMAGE;
     }
     if ($this->config->get('config_icon') && file_exists(DIR_IMAGE . $this->config->get('config_icon'))) {
         $this->data['icon'] = $server . $this->config->get('config_icon');
     } else {
         $this->data['icon'] = '';
     }
     $this->data['name'] = $this->config->get('config_name');
     if ($this->config->get('config_logo') && file_exists(DIR_IMAGE . $this->config->get('config_logo'))) {
         $this->data['logo'] = $server . $this->config->get('config_logo');
     } else {
         $this->data['logo'] = '';
     }
     // Calculate Totals
     $total_data = array();
     $total = 0;
     $taxes = $this->cart->getTaxes(false);
     if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
         $this->load->model('setting/extension');
         $sort_order = array();
         $results = \model\setting\ExtensionDAO::getInstance()->getExtensions('total');
         foreach ($results as $key => $value) {
             $sort_order[$key] = $this->config->get($value['code'] . '_sort_order');
         }
         array_multisort($sort_order, SORT_ASC, $results);
         foreach ($results as $result) {
             if ($this->config->get($result['code'] . '_status')) {
                 $this->load->model('total/' . $result['code']);
                 $this->{'model_total_' . $result['code']}->getTotal($total_data, $total, $taxes, false);
             }
         }
     }
     if ($this->customer->isLogged()) {
         $this->load->model('shop/general');
         $isVip = $this->model_shop_general->isVip($this->customer->getId());
     }
     $str = "";
     if (isset($isVip) && $isVip) {
         $url = 'catalog/view/theme/default/image/vip.png';
         $str = "&nbsp;&nbsp;&nbsp;<img src='" . $url . "' alt='vip' height='20' class='bottom5' />&nbsp;";
     }
     $this->data['button_go'] = $this->language->get('GO');
     $this->data['entry_search'] = '';
     $this->data['keyword'] = '';
     $this->data['text_home'] = $this->language->get('text_home');
     $this->data['text_favorites'] = $this->language->get('text_favorites');
     $this->data['text_wishlist'] = sprintf($this->language->get('text_wishlist'), isset($this->session->data['wishlist']) ? count($this->session->data['wishlist']) : 0);
     $this->data['text_cart'] = sprintf($this->language->get('text_cart'), isset($this->session->data['cart']) ? count($this->session->data['cart']) : 0);
     $this->data['text_items'] = sprintf($this->language->get('text_items'), $this->cart->countProducts() + (isset($this->session->data['vouchers']) ? count($this->session->data['vouchers']) : 0), $this->currency->format($total));
     $this->data['textSearchPrompt'] = $this->language->get('SEARCH_PROMPT');
     $this->data['text_welcome'] = sprintf($this->language->get('text_welcome'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'));
     $this->data['text_welcome_help'] = sprintf($this->language->get('text_welcome_help'), $this->url->link('account/login', '', 'SSL'));
     $this->data['text_welcome_guest_left'] = sprintf($this->language->get('text_welcome_guest_left'), $this->url->link('account/login', '', 'SSL'));
     $this->data['text_welcome_guest_right'] = sprintf($this->language->get('text_welcome_guest_right'), $this->url->link('account/register', '', 'SSL'));
     $this->data['text_logged'] = sprintf($this->language->get('text_logged'), $str, $this->url->link('account/account', '', 'SSL'), $this->customer->getNickName(), $this->url->link('account/logout', '', 'SSL'));
     $this->data['text_logged_help'] = sprintf($this->language->get('text_logged_help'), $str, $this->customer->getNickName());
     $this->data['text_logged_customer_left'] = sprintf($this->language->get('text_logged_customer_left'), $str, $this->url->link('account/account', '', 'SSL'), $this->customer->getNickName(), $this->customer->getNickName());
     $this->data['text_logged_customer_right'] = sprintf($this->language->get('text_logged_customer_right'), $this->url->link('account/logout', '', 'SSL'));
     $this->data['text_account'] = $this->language->get('text_account');
     $this->data['text_checkout'] = $this->language->get('text_checkout');
     $this->data['text_language'] = $this->language->get('text_language');
     $this->data['text_advanced'] = $this->language->get('ADVANCED');
     $this->data['text_bookmark'] = $this->language->get('BOOKMARK');
     $this->data['text_contact'] = $this->language->get('CONTACT');
     $this->data['text_currency'] = $this->language->get('text_currency');
     $this->data['text_keyword'] = $this->language->get('KEYWORD');
     $this->data['text_login'] = $this->language->get('LOGIN');
     $this->data['text_logout'] = $this->language->get('LOGOUT');
     $this->data['text_repurchase_order'] = $this->language->get('text_repurchase_order');
     $this->data['text_auction'] = $this->language->get('text_auction');
     $this->data['text_sitemap'] = $this->language->get('SITEMAP');
     $this->data['text_special'] = $this->language->get('SPECIAL');
     $this->data['textGallery'] = $this->language->get('GALLERY');
     $this->data['textShoppingGuide'] = $this->language->get('text_shopping_guide');
     $this->data['text_totop'] = $this->language->get('text_totop');
     $this->data['text_back'] = $this->language->get('text_back');
     $this->data['home'] = $this->url->link('common/home');
     $this->data['wishlist'] = $this->url->link('account/wishlist');
     $this->data['logged'] = $this->customer->isLogged();
     $this->data['account'] = $this->url->link('account/account', '', 'SSL');
     $this->data['cart'] = $this->url->link('checkout/cart');
     if ($this->config->get('wk_auction_timezone_set')) {
         $this->data['menuauction'] = $this->url->link('catalog/wkallauctions', '', 'SSL');
     }
     $this->data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');
     $this->data['repurchase_order'] = $this->url->link('product/repurchase', '', 'SSL');
     $this->data['urlGallery'] = $this->url->link('product/gallery', '', 'SSL');
     $this->data['urlShoppingGuide'] = $this->url->link('shop/admin/showPage&page_id=15', '', 'SSL');
     if (isset($this->request->get['filter_name'])) {
         $this->data['filter_name'] = $this->request->get['filter_name'];
     } else {
         $this->data['filter_name'] = '';
     }
     $this->data['action'] = $this->url->link('common/home');
     if (!isset($this->request->get['route'])) {
         $this->data['redirect'] = $this->url->link('common/home');
     } else {
         $data = $this->request->get;
         unset($data['_route_']);
         $route = $data['route'];
         unset($data['route']);
         $url = '';
         if ($data) {
             //$url = '&amp;' . urldecode(http_build_query($data, '', '&amp;'));
             $url = '&' . urldecode(http_build_query($data, '', '&'));
         }
         $this->data['redirect'] = $this->url->link($route, $url);
     }
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && !empty($this->request->post['language_code'])) {
         $this->session->data['language'] = $this->request->post['language_code'];
         foreach ($this->load->model('localisation/language')->getLanguages() as $language) {
             if ($language['code'] == $this->session->data['language']) {
                 $this->session->data['language_id'] = $language['language_id'];
                 break;
             }
         }
         if (isset($this->request->post['redirect'])) {
             $this->redirect($this->request->post['redirect']);
         } else {
             $this->redirect($this->url->link('common/home'));
         }
     }
     $this->data['language_code'] = $this->session->data['language'];
     $this->load->model('localisation/language');
     $this->data['languages'] = array();
     $results = $this->model_localisation_language->getLanguages();
     foreach ($results as $result) {
         if ($result['status']) {
             $this->data['languages'][] = array('name' => $result['name'], 'code' => $result['code'], 'image' => $result['image']);
         }
     }
     $tmpQuery = $this->request->get;
     unset($tmpQuery['language']);
     $this->data['languagelessQuery'] = implode('&', array_map(function ($key, $value) {
         return "{$key}={$value}";
     }, array_keys($tmpQuery), $tmpQuery));
     if ($this->request->server['REQUEST_METHOD'] == 'POST' && !empty($this->request->post['currency_code'])) {
         $this->currency->set($this->request->post['currency_code']);
         unset($this->session->data['shipping_methods']);
         unset($this->session->data['shipping_method']);
         if (isset($this->request->post['redirect'])) {
             $this->redirect($this->request->post['redirect']);
         } else {
             $this->redirect($this->url->link('common/home'));
         }
     }
     $this->data['currency_code'] = $this->currency->getCode();
     $this->load->model('localisation/currency');
     $this->data['currencies'] = array();
     $results = $this->model_localisation_currency->getCurrencies();
     foreach ($results as $result) {
         if ($result['status']) {
             if ($result['code'] == 'RUB') {
                 continue;
             }
             $this->data['currencies'][] = array('title' => $result['title'], 'code' => $result['code'], 'symbol_left' => $result['symbol_left'], 'symbol_right' => $result['symbol_right']);
         }
     }
     $this->load->language('shop/general');
     $this->data['text_no_select_images'] = $this->language->get('text_no_select_images');
     $this->data['text_button_download'] = $this->language->get('text_button_download');
     $this->setBreadcrumbs();
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header.tpl.php')) {
         $this->template = $this->config->get('config_template') . '/template/common/header.tpl.php';
     } else {
         $this->template = 'default/template/common/header.tpl.php';
     }
     $this->render();
 }