private function init()
 {
     $this->load->library('simple/simplecheckout');
     $this->simplecheckout = SimpleCheckout::getInstance($this->registry);
     $this->simplecheckout->setCurrentBlock('payment');
     $this->language->load('checkout/simplecheckout');
 }
 public static function getInstance($registry, $settingsId = 0)
 {
     if (self::$_instance === null) {
         self::$_instance = new self($registry, $settingsId);
     }
     return self::$_instance;
 }
 public function index()
 {
     $this->load->library('simple/simplecheckout');
     $this->simplecheckout = SimpleCheckout::getInstance($this->registry);
     $this->simplecheckout->setCurrentBlock('login');
     if ($this->customer->isLogged()) {
         if ($this->simplecheckout->isAjaxRequest()) {
             return;
         } else {
             $this->simplecheckout->redirect($this->url->link('checkout/simplecheckout', '', 'SSL'));
             return;
         }
     }
     $this->load->model('account/customer');
     $this->language->load('checkout/simplecheckout');
     $this->_templateData['error_login'] = '';
     if ($this->request->server['REQUEST_METHOD'] == 'POST') {
         $error = false;
         if ($this->simplecheckout->getOpencartVersion() > 200) {
             $login_info = $this->model_account_customer->getLoginAttempts($this->request->post['email']);
             if ($login_info && $login_info['total'] >= $this->config->get('config_login_attempts') && strtotime('-1 hour') < strtotime($login_info['date_modified'])) {
                 $this->_templateData['error_login'] = $this->language->get('error_attempts');
                 $this->simplecheckout->addError();
                 $error = true;
             }
         }
         if (!$error) {
             if (!empty($this->request->post['email']) && !empty($this->request->post['password']) && $this->customer->login($this->request->post['email'], $this->request->post['password'])) {
                 unset($this->session->data['guest']);
                 if ($this->simplecheckout->getOpencartVersion() > 200) {
                     $this->model_account_customer->deleteLoginAttempts($this->request->post['email']);
                 }
             } else {
                 $this->_templateData['error_login'] = $this->language->get('error_login');
                 $this->simplecheckout->addError();
                 if ($this->simplecheckout->getOpencartVersion() > 200) {
                     $this->model_account_customer->addLoginAttempt($this->request->post['email']);
                 }
             }
         }
     }
     $this->_templateData['text_checkout_customer'] = $this->language->get('text_checkout_customer');
     $this->_templateData['text_checkout_customer_login'] = $this->language->get('text_checkout_customer_login');
     $this->_templateData['text_checkout_customer_cancel'] = $this->language->get('text_checkout_customer_cancel');
     $this->_templateData['text_forgotten'] = $this->language->get('text_forgotten');
     $this->_templateData['entry_email'] = $this->language->get('entry_email');
     $this->_templateData['entry_password'] = $this->language->get('entry_password');
     $this->_templateData['button_login'] = $this->language->get('button_login');
     $this->_templateData['forgotten'] = $this->url->link('account/forgotten', '', 'SSL');
     if (isset($this->request->post['email'])) {
         $this->_templateData['email'] = trim($this->request->post['email']);
     } else {
         $this->_templateData['email'] = '';
     }
     $this->_templateData['additional_path'] = $this->simplecheckout->getAdditionalPath();
     $this->_templateData['has_error'] = $this->simplecheckout->hasError();
     $this->setOutputContent($this->renderPage('checkout/simplecheckout_login.tpl', $this->_templateData));
 }
 public function index($args = null)
 {
     $this->load->library('simple/simplecheckout');
     $this->simplecheckout = SimpleCheckout::getInstance($this->registry);
     $type = !empty($args['type']) ? $args['type'] : 'text';
     $this->simplecheckout->setCurrentBlock($type);
     $this->load->model('catalog/information');
     $this->_templateData['text_id'] = !empty($args['id']) ? $args['id'] : (!empty($this->request->get['id']) ? $this->request->get['id'] : 0);
     $this->_templateData['text_title'] = '';
     $this->_templateData['text_content'] = '';
     $this->_templateData['text_type'] = $type;
     $this->_templateData['display_header'] = $this->simplecheckout->getSettingValue('displayHeader');
     $information = $this->model_catalog_information->getInformation($this->_templateData['text_id']);
     if ($information) {
         $this->_templateData['text_title'] = $information['title'];
         $this->_templateData['text_content'] = html_entity_decode($information['description'], ENT_QUOTES, 'UTF-8');
     }
     $this->simplecheckout->resetCurrentBlock();
     $this->setOutputContent($this->renderPage('checkout/simplecheckout_text.tpl', $this->_templateData));
 }
Beispiel #5
0
 protected function index($setting)
 {
     $route = '';
     if (!empty($setting['page'])) {
         if ($setting['page'] == 'checkout') {
             $route = 'checkout/simplecheckout';
         } elseif ($setting['page'] == 'register') {
             $route = 'account/simpleregister';
         }
     }
     if ($route && empty($setting['scripts'])) {
         $this->_templateData['simple_content'] = $this->getChildController($route, array('module' => true, 'group' => !empty($setting['settingsId']) ? $setting['settingsId'] : 0));
         $this->setOutputContent($this->renderPage('module/simple.tpl', $this->_templateData));
     } elseif (!empty($setting['scripts'])) {
         if ($route == 'checkout/simplecheckout') {
             $this->load->library('simple/simplecheckout');
             SimpleCheckout::getInstance($this->registry, !empty($setting['settingsId']) ? $setting['settingsId'] : 0);
         } elseif ($route == 'account/simpleregister') {
             $this->load->library('simple/simpleregister');
             SimpleRegister::getInstance($this->registry);
         }
     }
 }
 public function prevent_delete()
 {
     $this->load->library('simple/simplecheckout');
     $this->simplecheckout = SimpleCheckout::getInstance($this->registry);
     $this->simplecheckout->setPreventDeleteFlag();
 }
 public function index()
 {
     $this->load->library('simple/simplecheckout');
     $this->simplecheckout = SimpleCheckout::getInstance($this->registry);
     $this->simplecheckout->setCurrentBlock('summary');
     $version = $this->simplecheckout->getOpencartVersion();
     $this->language->load('checkout/cart');
     $this->language->load('checkout/simplecheckout');
     $this->load->model('tool/image');
     if ($version >= 200) {
         $this->load->model('tool/upload');
     }
     $this->load->library('encryption');
     $this->_templateData['column_image'] = $this->language->get('column_image');
     $this->_templateData['column_name'] = $this->language->get('column_name');
     $this->_templateData['column_model'] = $this->language->get('column_model');
     $this->_templateData['column_quantity'] = $this->language->get('column_quantity');
     $this->_templateData['column_price'] = $this->language->get('column_price');
     $this->_templateData['column_total'] = $this->language->get('column_total');
     $this->_templateData['text_summary'] = $this->language->get('text_summary');
     $this->_templateData['text_summary_comment'] = $this->language->get('text_summary_comment');
     $this->_templateData['text_summary_shipping_address'] = $this->language->get('text_summary_shipping_address');
     $this->_templateData['text_summary_payment_address'] = $this->language->get('text_summary_payment_address');
     $this->_templateData['text_until_cancelled'] = $this->language->get('text_until_cancelled');
     $this->_templateData['text_freq_day'] = $this->language->get('text_freq_day');
     $this->_templateData['text_freq_week'] = $this->language->get('text_freq_week');
     $this->_templateData['text_freq_month'] = $this->language->get('text_freq_month');
     $this->_templateData['text_freq_bi_month'] = $this->language->get('text_freq_bi_month');
     $this->_templateData['text_freq_year'] = $this->language->get('text_freq_year');
     $this->_templateData['text_trial'] = $this->language->get('text_trial');
     $this->_templateData['text_recurring'] = $this->language->get('text_recurring');
     $this->_templateData['text_length'] = $this->language->get('text_length');
     $this->_templateData['text_recurring_item'] = $this->language->get('text_recurring_item');
     $this->_templateData['text_payment_profile'] = $this->language->get('text_payment_profile');
     $this->_templateData['button_update'] = $this->language->get('button_update');
     $this->_templateData['products'] = array();
     $products = $this->cart->getProducts();
     $points_total = 0;
     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'];
             }
         }
         $option_data = array();
         foreach ($product['option'] as $option) {
             if ($version >= 200) {
                 if ($option['type'] != 'file') {
                     $value = $option['value'];
                 } else {
                     $upload_info = $this->model_tool_upload->getUploadByCode($option['value']);
                     if ($upload_info) {
                         $value = $upload_info['name'];
                     } else {
                         $value = '';
                     }
                 }
             } else {
                 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 >= 200) {
             $recurring = '';
             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 = sprintf($this->language->get('text_trial_description'), $this->currency->format($this->tax->calculate($product['recurring']['trial_price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['trial_cycle'], $frequencies[$product['recurring']['trial_frequency']], $product['recurring']['trial_duration']) . ' ';
                 }
                 if ($product['recurring']['duration']) {
                     $recurring .= sprintf($this->language->get('text_payment_description'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']);
                 } else {
                     $recurring .= sprintf($this->language->get('text_payment_until_canceled_description'), $this->currency->format($this->tax->calculate($product['recurring']['price'] * $product['quantity'], $product['tax_class_id'], $this->config->get('config_tax'))), $product['recurring']['cycle'], $frequencies[$product['recurring']['frequency']], $product['recurring']['duration']);
                 }
             }
             $this->_templateData['products'][] = array('key' => $product['key'], 'thumb' => $image, 'name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'recurring' => $recurring, 'quantity' => $product['quantity'], 'stock' => $product['stock'] ? true : !(!$this->config->get('config_stock_checkout') || $this->config->get('config_stock_warning')), 'reward' => $product['reward'] ? sprintf($this->language->get('text_points'), $product['reward']) : '', 'price' => $price, 'total' => $total, 'href' => $this->url->link('product/product', 'product_id=' . $product['product_id']));
         } elseif ($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->_templateData['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->_templateData['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->_templateData['vouchers'] = array();
     if (!empty($this->session->data['vouchers'])) {
         foreach ($this->session->data['vouchers'] as $key => $voucher) {
             $this->_templateData['vouchers'][] = array('key' => $key, 'description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount']));
         }
     }
     $total_data = array();
     $total = 0;
     $taxes = $this->cart->getTaxes();
     $this->_templateData['modules'] = array();
     if ($this->config->get('config_customer_price') && $this->customer->isLogged() || !$this->config->get('config_customer_price')) {
         $sort_order = array();
         if ($version < 200) {
             $this->load->model('setting/extension');
             $results = $this->model_setting_extension->getExtensions('total');
         } else {
             $this->load->model('extension/extension');
             $results = $this->model_extension_extension->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->_templateData['modules'][$result['code']] = true;
             }
         }
         $sort_order = array();
         foreach ($total_data as $key => $value) {
             $sort_order[$key] = $value['sort_order'];
             if (!isset($value['text'])) {
                 $total_data[$key]['text'] = $this->currency->format($value['value']);
             }
         }
         array_multisort($sort_order, SORT_ASC, $total_data);
     }
     $this->_templateData['totals'] = $total_data;
     $points = $this->customer->getRewardPoints();
     $points_to_use = $points > $points_total ? $points_total : $points;
     $this->_templateData['points'] = $points_to_use;
     $this->_templateData['reward'] = isset($this->session->data['reward']) ? $this->session->data['reward'] : '';
     $this->_templateData['voucher'] = isset($this->session->data['voucher']) ? $this->session->data['voucher'] : '';
     $this->_templateData['coupon'] = isset($this->session->data['coupon']) ? $this->session->data['coupon'] : '';
     $payment_address = $this->simplecheckout->getPaymentAddress();
     $payment_address_format = $payment_address['address_format'];
     if (!empty($payment_address_format)) {
         $format = $payment_address_format;
     } else {
         $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
     }
     $find = array('{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}', '{company_id}', '{tax_id}');
     $replace = array('firstname' => $payment_address['firstname'], 'lastname' => $payment_address['lastname'], 'company' => $payment_address['company'], 'address_1' => $payment_address['address_1'], 'address_2' => $payment_address['address_2'], 'city' => $payment_address['city'], 'postcode' => $payment_address['postcode'], 'zone' => $payment_address['zone'], 'zone_code' => $payment_address['zone_code'], 'country' => $payment_address['country'], 'company_id' => isset($payment_address['company_id']) ? $payment_address['company_id'] : '', 'tax_id' => isset($payment_address['tax_id']) ? $payment_address['tax_id'] : '');
     foreach ($payment_address as $id => $value) {
         if (isset($replace[$id]) || $id == 'address_format' || $id == 'custom_field') {
             continue;
         }
         if (strpos($id, 'payment_') === 0) {
             $id = str_replace('payment_', '', $id);
             $find[] = '{' . $id . '}';
             $replace[$id] = $value;
         } elseif (strpos($id, 'shipping_') === false) {
             $find[] = '{' . $id . '}';
             $replace[$id] = $value;
         }
     }
     $this->_templateData['summary_payment_address'] = trim(str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))));
     $this->_templateData['summary_shipping_address'] = '';
     if ($this->cart->hasShipping()) {
         $shipping_address = $this->simplecheckout->getShippingAddress();
         $shipping_address_format = $shipping_address['address_format'];
         if (!empty($shipping_address_format)) {
             $format = $shipping_address_format;
         } else {
             $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
         }
         $find = array('{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}', '{company_id}', '{tax_id}');
         $replace = array('firstname' => $shipping_address['firstname'], 'lastname' => $shipping_address['lastname'], 'company' => $shipping_address['company'], 'address_1' => $shipping_address['address_1'], 'address_2' => $shipping_address['address_2'], 'city' => $shipping_address['city'], 'postcode' => $shipping_address['postcode'], 'zone' => $shipping_address['zone'], 'zone_code' => $shipping_address['zone_code'], 'country' => $shipping_address['country'], 'company_id' => isset($shipping_address['company_id']) ? $shipping_address['company_id'] : '', 'tax_id' => isset($shipping_address['tax_id']) ? $shipping_address['tax_id'] : '');
         foreach ($shipping_address as $id => $value) {
             if (isset($replace[$id]) || $id == 'address_format' || $id == 'custom_field') {
                 continue;
             }
             if (strpos($id, 'shipping_') === 0) {
                 $id = str_replace('shipping_', '', $id);
                 $find[] = '{' . $id . '}';
                 $replace[$id] = $value;
             } elseif (strpos($id, 'payment_') === false) {
                 $find[] = '{' . $id . '}';
                 $replace[$id] = $value;
             }
         }
         $this->_templateData['summary_shipping_address'] = trim(str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))));
     }
     $this->_templateData['display_header'] = $this->simplecheckout->getSettingValue('displayHeader');
     $this->_templateData['summary_comment'] = $this->simplecheckout->getComment();
     $this->simplecheckout->resetCurrentBlock();
     $this->setOutputContent($this->renderPage('checkout/simplecheckout_summary.tpl', $this->_templateData));
 }