public function confirm($order_id) { $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); if ($order_info) { $this->load->model('localisation/language'); $language = new Language($order_info['language_directory']); $language->load($order_info['language_filename']); $language->load('mail/voucher'); $voucher_query = $this->db->query("SELECT *, vtd.name AS theme FROM `" . DB_PREFIX . "voucher` v LEFT JOIN " . DB_PREFIX . "voucher_theme vt ON (v.voucher_theme_id = vt.voucher_theme_id) LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) AND vtd.language_id = '" . (int)$order_info['language_id'] . "' WHERE v.order_id = '" . (int)$order_id . "'"); foreach ($voucher_query->rows as $voucher) { // HTML Mail $template = new Template(); $template->data['title'] = sprintf($language->get('text_subject'), $voucher['from_name']); $template->data['text_greeting'] = sprintf($language->get('text_greeting'), $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value'])); $template->data['text_from'] = sprintf($language->get('text_from'), $voucher['from_name']); $template->data['text_message'] = $language->get('text_message'); $template->data['text_redeem'] = sprintf($language->get('text_redeem'), $voucher['code']); $template->data['text_footer'] = $language->get('text_footer'); if (file_exists(DIR_IMAGE . $voucher['image'])) { $template->data['image'] = $this->config->get('config_url') . 'image/' . $voucher['image']; } else { $template->data['image'] = ''; } $template->data['store_name'] = $order_info['store_name']; $template->data['store_url'] = $order_info['store_url']; $template->data['message'] = nl2br($voucher['message']); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/voucher.tpl')) { $html = $template->fetch($this->config->get('config_template') . '/template/mail/voucher.tpl'); } else { $html = $template->fetch('default/template/mail/voucher.tpl'); } $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($voucher['to_email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject(html_entity_decode(sprintf($language->get('text_subject'), $voucher['from_name']), ENT_QUOTES, 'UTF-8')); $mail->setHtml($html); $mail->send(); } } }
public function send($order_id) { $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); // If order status in the complete range create any vouchers that where in the order need to be made available. if (in_array($order_info['order_status_id'], $this->config->get('config_complete_status'))) { $voucher_query = $this->db->query("SELECT *, vtd.name AS theme FROM `" . DB_PREFIX . "voucher` v LEFT JOIN " . DB_PREFIX . "voucher_theme vt ON (v.voucher_theme_id = vt.voucher_theme_id) LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) AND vtd.language_id = '" . (int) $order_info['language_id'] . "' WHERE v.order_id = '" . (int) $order_info['order_id'] . "'"); if ($voucher_query->num_rows) { // Send out any gift voucher mails $language = new Language($order_info['language_directory']); $language->load($order_info['language_directory']); $language->load('mail/voucher'); foreach ($voucher_query->rows as $voucher) { // HTML Mail $data = array(); $data['title'] = sprintf($language->get('text_subject'), $voucher['from_name']); $data['text_greeting'] = sprintf($language->get('text_greeting'), $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value'])); $data['text_from'] = sprintf($language->get('text_from'), $voucher['from_name']); $data['text_message'] = $language->get('text_message'); $data['text_redeem'] = sprintf($language->get('text_redeem'), $voucher['code']); $data['text_footer'] = $language->get('text_footer'); if (is_file(DIR_IMAGE . $voucher['image'])) { $data['image'] = $this->config->get('config_url') . 'image/' . $voucher['image']; } else { $data['image'] = ''; } $data['store_name'] = $order_info['store_name']; $data['store_url'] = $order_info['store_url']; $data['message'] = nl2br($voucher['message']); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/voucher.tpl')) { $html = $this->load->view($this->config->get('config_template') . '/template/mail/voucher.tpl', $data); } else { $html = $this->load->view('default/template/mail/voucher.tpl', $data); } $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); $mail->smtp_username = $this->config->get('config_mail_smtp_username'); $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); $mail->smtp_port = $this->config->get('config_mail_smtp_port'); $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); $mail->setTo($voucher['to_email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')); $mail->setSubject(html_entity_decode(sprintf($language->get('text_subject'), $voucher['from_name']), ENT_QUOTES, 'UTF-8')); $mail->setHtml($html); $mail->send(); } } } }
public function index() { $code = ''; $this->load->model('localisation/language'); $languages = $this->model_localisation_language->getLanguages(); if (isset($this->request->cookie['language'])) { $code = $this->request->cookie['language']; } // Language Detection if (!empty($this->request->server['HTTP_ACCEPT_LANGUAGE']) && !array_key_exists($code, $languages)) { $browser_languages = explode(',', $this->request->server['HTTP_ACCEPT_LANGUAGE']); foreach ($browser_languages as $browser_language) { if (array_key_exists(strtolower($browser_language), $languages)) { $code = strtolower($browser_language); break; } } } if (!array_key_exists($code, $languages)) { $code = $this->config->get('config_language'); } if (!isset($this->request->cookie['language']) || $this->request->cookie['language'] != $code) { setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']); } // Overwrite the default language object $language = new Language($code); $language->load($code); $this->registry->set('language', $language); // Set the config language_id $this->config->set('config_language_id', $languages[$code]['language_id']); }
public function editOrder($order_id, $data) { $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $data['order_status_id'] . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $data['order_status_id'] . "', notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "', comment = '" . $this->db->escape(strip_tags($data['comment'])) . "', date_added = NOW()"); if (isset($data['notify'])) { $query = $this->db->query("SELECT *, os.name AS status, l.code AS language FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "order_status os ON (o.order_status_id = os.order_status_id AND os.language_id = o.language_id) LEFT JOIN " . DB_PREFIX . "language l ON (o.language_id = l.language_id) WHERE o.order_id = '" . (int) $order_id . "'"); if ($query->num_rows) { $language = new Language($query->row['language']); $language->load('customer/order'); $subject = sprintf($language->get('mail_subject'), html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8'), $order_id); $message = $language->get('mail_order') . ' ' . $order_id . "\n"; $message .= $language->get('mail_date_added') . ' ' . date($language->get('date_format_short'), strtotime($query->row['date_added'])) . "\n\n"; $message .= $language->get('mail_order_status') . "\n\n"; $message .= $query->row['status'] . "\n\n"; $message .= $language->get('mail_invoice') . "\n"; $message .= html_entity_decode(HTTP_CATALOG . 'index.php?route=account/invoice&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\n\n"; if (isset($data['comment'])) { $message .= $language->get('mail_comment') . "\n\n"; $message .= strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "\n\n"; } $message .= $language->get('mail_footer'); $mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password'), ENT_QUOTES, 'UTF-8'), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout')); $mail->setTo($query->row['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender(html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8')); $mail->setSubject($subject); $mail->setText($message); $mail->send(); } } }
public function index() { if (!isset($this->session->data['language'])) { $languages = glob(DIR_LANGUAGE . '*', GLOB_ONLYDIR); foreach ($languages as $language) { $languages[] = basename($language); } if (isset($this->request->server['HTTP_ACCEPT_LANGUAGE'])) { $browser_languages = explode(',', $this->request->server['HTTP_ACCEPT_LANGUAGE']); foreach ($browser_languages as $browser_language) { if (in_array($browser_language, $languages)) { $this->session->data['language'] = $browser_language; break; } } } } if (!isset($this->session->data['language']) || !is_dir(DIR_LANGUAGE . str_replace('../', '/', $this->session->data['language']))) { $this->session->data['language'] = $this->config->get('language.default'); } // Language $language = new Language($this->session->data['language']); $language->load($this->session->data['language']); $this->registry->set('language', $language); }
/** * StopWords constructor - load stop words for current locale * * @todo specify locale to constructor, will require shift away from defined constant */ public function __construct() { if (!defined('_XMF_STOPWORDS')) { Language::load('stopwords'); } if (defined('_XMF_STOPWORDS')) { $sw = explode(' ', _XMF_STOPWORDS); $this->stopwordList = array_fill_keys($sw, true); } }
public function confirm($order_id) { $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); if ($order_info) { $this->load->model('localisation/language'); $language = new Language($order_info['language_directory']); $language->load('default'); $language->load('mail/voucher'); $voucher_query = $this->db->query("SELECT v.voucher_id, v.code, v.from_name, v.from_email, v.to_name, v.to_email, v.`voucher_theme_id`, v.`message`, v.`amount`, v.`status`, v.`date_added`, vtd.name AS theme FROM `" . DB_PREFIX . "voucher` v LEFT JOIN " . DB_PREFIX . "voucher_theme vt ON (v.voucher_theme_id = vt.voucher_theme_id) LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) AND vtd.language_id = '" . (int) $order_info['language_id'] . "' WHERE v.order_id = '" . (int) $order_id . "'"); foreach ($voucher_query->rows as $voucher) { // HTML Mail $data = array(); $data['title'] = sprintf($language->get('text_subject'), $voucher['from_name']); $data['text_greeting'] = sprintf($language->get('text_greeting'), $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value'])); $data['text_from'] = sprintf($language->get('text_from'), $voucher['from_name']); $data['text_message'] = $language->get('text_message'); $data['text_redeem'] = sprintf($language->get('text_redeem'), $voucher['code']); $data['text_footer'] = $language->get('text_footer'); if (is_file(DIR_IMAGE . $voucher['image'])) { $data['image'] = $this->config->get('config_url') . 'image/' . $voucher['image']; } else { $data['image'] = ''; } $data['store_name'] = $order_info['store_name']; $data['store_url'] = $order_info['store_url']; $data['message'] = nl2br($voucher['message']); if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/voucher.tpl')) { $html = $this->load->view($this->config->get('config_template') . '/template/mail/voucher.tpl', $data); } else { $html = $this->load->view('default/template/mail/voucher.tpl', $data); } $mail = new Mail($this->config->get('config_mail')); $mail->setTo($voucher['to_email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject(sprintf($language->get('text_subject'), $voucher['from_name'])); $mail->setHtml($html); $mail->send(); } } }
/** * @covers Xmf\Language::load */ public function testLoad() { $str = '_user'; $x = Language::load($str); if (isset($GLOBALS['xoopsConfig']['language'])) { $language = $GLOBALS['xoopsConfig']['language']; $this->assertSame($str, $x); } else { $this->assertSame(true, $x); } }
public function index() { // Language $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "language` WHERE code = '" . $this->db->escape($this->config->get('config_admin_language')) . "'"); if ($query->num_rows) { $this->config->set('config_language_id', $query->row['language_id']); } // Language $language = new Language($this->config->get('config_admin_language')); $language->load($this->config->get('config_admin_language')); $this->registry->set('language', $language); }
public function addHistory($order_id, $data) { $this->db->query("UPDATE `" . DB_PREFIX . "order` SET \r\n order_status_id = '" . (int) $data['order_status_id'] . "', \r\n date_modified = NOW() \r\n WHERE order_id = '" . (int) $order_id . "'"); if ($data['append']) { $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET \r\n order_id = '" . (int) $order_id . "', \r\n order_status_id = '" . (int) $data['order_status_id'] . "', \r\n notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "', \r\n comment = '" . $this->db->escape(strip_tags($data['comment'])) . "', \r\n date_added = NOW()"); } if ($data['notify']) { $order_query = $this->db->query("SELECT *, os.name AS status \r\n FROM `" . DB_PREFIX . "order` o \r\n LEFT JOIN " . DB_PREFIX . "order_status os ON (o.order_status_id = os.order_status_id AND os.language_id = o.language_id) \r\n LEFT JOIN " . DB_PREFIX . "language l ON (o.language_id = l.language_id) \r\n WHERE o.order_id = '" . (int) $order_id . "'"); if ($order_query->num_rows) { $language = new Language($order_query->row['directory']); $language->load($order_query->row['filename']); //$language->load('mail/order'); //TODO: cargar la plantilla de email asociada con esta accion $subject = sprintf($language->get('text_subject'), $order_query->row['store_name'], $order_id); $message = "<p><b>" . $language->get('text_order') . ' ' . $order_id . "</b></p>"; $message .= "<p>" . $language->get('text_date_added') . ' ' . date('d-m-Y', strtotime($order_query->row['date_added'])) . "</p>"; $message .= "<p>" . $language->get('text_order_status') . ' <b>' . $order_query->row['status'] . "</b></p>"; $message .= "<p>" . $language->get('text_invoice') . "</p>"; $message .= "<a href=\"" . html_entity_decode($order_query->row['store_url'] . 'index.php?r=account/invoice&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\">Ver Pedido</a>"; if ($data['comment']) { $message .= "<br /><p>" . $language->get('text_comment') . "</p>"; $message .= "<br /><p>" . strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "</p>"; } $message .= $language->get('text_footer'); $this->load->library('email/mailer'); $mailer = new Mailer(); if ($this->config->get('config_smtp_method') == 'smtp') { $mailer->IsSMTP(); $mailer->Host = $this->config->get('config_smtp_host'); $mailer->Username = $this->config->get('config_smtp_username'); $mailer->Password = base64_decode($this->config->get('config_smtp_password')); $mailer->Port = $this->config->get('config_smtp_port'); $mailer->Timeout = $this->config->get('config_smtp_timeout'); $mailer->SMTPSecure = $this->config->get('config_smtp_ssl'); $mailer->SMTPAuth = $this->config->get('config_smtp_auth') ? true : false; } elseif ($this->config->get('config_smtp_method') == 'sendmail') { $mailer->IsSendmail(); } else { $mailer->IsMail(); } $mailer->IsHTML(); $mailer->AddAddress($order_query->row['email'], $order_query->row['payment_firstname']); $mailer->SetFrom($this->config->get('config_email'), $this->config->get('config_name')); $mailer->Subject = $subject; $mailer->Body = $message; $mailer->Send(); } } }
public static function load() { // Set Path Path::load(); // Set Link Link::load(); // Set URL Url::load(); // Set Language Language::load(); // Set parameters self::_setParameters(); // Set Controller self::_setController(); // Set Headers self::_setDefaultHeader(); }
public function index() { // Settings $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '0'"); foreach ($query->rows as $setting) { if (!$setting['serialized']) { $this->config->set($setting['key'], $setting['value']); } else { $this->config->set($setting['key'], json_decode($setting['value'], true)); } } // Language $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "language` WHERE code = '" . $this->db->escape($this->config->get('config_admin_language')) . "'"); if ($query->num_rows) { $this->config->set('config_language_id', $query->row['language_id']); } // Language $language = new Language($this->config->get('config_admin_language')); $language->load($this->config->get('config_admin_language')); $this->registry->set('language', $language); // Customer $this->registry->set('customer', new Cart\Customer($this->registry)); // Affiliate $this->registry->set('affiliate', new Cart\Affiliate($this->registry)); // Currency $this->registry->set('currency', new Cart\Currency($this->registry)); // Tax $this->registry->set('tax', new Cart\Tax($this->registry)); if ($this->config->get('config_tax_default') == 'shipping') { $this->tax->setShippingAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); } if ($this->config->get('config_tax_default') == 'payment') { $this->tax->setPaymentAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); } $this->tax->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id')); // Weight $this->registry->set('weight', new Cart\Weight($this->registry)); // Length $this->registry->set('length', new Cart\Length($this->registry)); // Cart $this->registry->set('cart', new Cart\Cart($this->registry)); // Encryption $this->registry->set('encryption', new Encryption($this->config->get('config_encryption'))); // OpenBay Pro $this->registry->set('openbay', new Openbay($this->registry)); }
public function index() { // Language Detection $languages = array(); $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "language` WHERE status = '1'"); foreach ($query->rows as $result) { $languages[$result['code']] = $result; } if (isset($session->data['language']) && array_key_exists($session->data['language'], $languages)) { $code = $session->data['language']; } elseif (isset($request->cookie['language']) && array_key_exists($request->cookie['language'], $languages)) { $code = $request->cookie['language']; } else { $detect = ''; if (isset($request->server['HTTP_ACCEPT_LANGUAGE']) && $request->server['HTTP_ACCEPT_LANGUAGE']) { $browser_languages = explode(',', $request->server['HTTP_ACCEPT_LANGUAGE']); foreach ($browser_languages as $browser_language) { foreach ($languages as $key => $value) { if ($value['status']) { $locale = explode(',', $value['locale']); if (in_array($browser_language, $locale)) { $detect = $key; break 2; } } } } } $code = $detect ? $detect : $config->get('config_language'); } if (!isset($session->data['language']) || $session->data['language'] != $code) { $session->data['language'] = $code; } if (!isset($request->cookie['language']) || $request->cookie['language'] != $code) { setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $request->server['HTTP_HOST']); } $config->set('config_language_id', $languages[$code]['language_id']); $config->set('config_language', $languages[$code]['code']); // Language $language = new Language($languages[$code]['directory']); $language->load($languages[$code]['directory']); $registry->set('language', $language); }
public function confirm($order_id) { $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); if ($order_info) { $this->load->model('localisation/language'); $language = new Language($order_info['language_directory']); $language->load('mail/voucher'); $voucher_query = $this->db->query("SELECT *, vtd.name AS theme FROM `" . DB_PREFIX . "voucher` v LEFT JOIN " . DB_PREFIX . "voucher_theme vt ON (v.voucher_theme_id = vt.voucher_theme_id) LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) AND vtd.language_id = '" . (int) $order_info['language_id'] . "' WHERE v.order_id = '" . (int) $order_id . "'"); foreach ($voucher_query->rows as $voucher) { $data = array('recip_name' => $voucher['to_name'], 'recip_email' => $voucher['to_email'], 'store_name' => $order_info['store_name'], 'name' => $voucher['from_name'], 'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']), 'message' => nl2br($voucher['message']), 'store_href' => $order_info['store_url'], 'image' => file_exists(DIR_IMAGE . $voucher['image']) ? $voucher['image'] : '', 'code' => $voucher['code']); $subject = $this->emailtemplate->getSubject('Voucher', 'customer_5', $data); $message = $this->emailtemplate->getMessage('Voucher', 'customer_5', $data); $mail = new Mail($this->config->get('config_mail')); $mail->setTo($voucher['to_email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject($subject); $mail->setHtml($message); $mail->send(); } } }
public function sendVoucher($voucher_id) { $voucher_info = $this->getVoucher($voucher_id); if ($voucher_info) { if ($voucher_info['order_id']) { $order_id = $voucher_info['order_id']; } else { $order_id = 0; } $this->load->model('sale/order'); $order_info = $this->model_sale_order->getOrder($order_id); // If voucher belongs to an order if ($order_info) { $this->load->model('localisation/language'); $language = new Language($order_info['language_directory']); $language->load($order_info['language_filename']); $language->load('mail/voucher'); // HTML Mail $template = new Template(); $template->data['title'] = sprintf($language->get('text_subject'), $voucher_info['from_name']); $template->data['text_greeting'] = sprintf($language->get('text_greeting'), $this->currency->format($voucher_info['amount'], $order_info['currency_code'], $order_info['currency_value'])); $template->data['text_from'] = sprintf($language->get('text_from'), $voucher_info['from_name']); $template->data['text_message'] = $language->get('text_message'); $template->data['text_redeem'] = sprintf($language->get('text_redeem'), $voucher_info['code']); $template->data['text_footer'] = $language->get('text_footer'); $this->load->model('sale/voucher_theme'); $voucher_theme_info = $this->model_sale_voucher_theme->getVoucherTheme($voucher_info['voucher_theme_id']); if ($voucher_info && file_exists(DIR_IMAGE . $voucher_theme_info['image'])) { $template->data['image'] = HTTP_CATALOG . 'image/' . $voucher_theme_info['image']; } else { $template->data['image'] = ''; } $template->data['store_name'] = $order_info['store_name']; $template->data['store_url'] = $order_info['store_url']; $template->data['message'] = nl2br($voucher_info['message']); $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($voucher_info['to_email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject(html_entity_decode(sprintf($language->get('text_subject'), $voucher_info['from_name']), ENT_QUOTES, 'UTF-8')); $mail->setHtml($template->fetch('mail/voucher.tpl')); $mail->send(); // If voucher does not belong to an order } else { $this->language->load('mail/voucher'); $template = new Template(); $template->data['title'] = sprintf($this->language->get('text_subject'), $voucher_info['from_name']); $template->data['text_greeting'] = sprintf($this->language->get('text_greeting'), $this->currency->format($voucher_info['amount'], $order_info['currency_code'], $order_info['currency_value'])); $template->data['text_from'] = sprintf($this->language->get('text_from'), $voucher_info['from_name']); $template->data['text_message'] = $this->language->get('text_message'); $template->data['text_redeem'] = sprintf($this->language->get('text_redeem'), $voucher_info['code']); $template->data['text_footer'] = $this->language->get('text_footer'); $this->load->model('sale/voucher_theme'); $voucher_theme_info = $this->model_sale_voucher_theme->getVoucherTheme($voucher_info['voucher_theme_id']); if ($voucher_info && file_exists(DIR_IMAGE . $voucher_theme_info['image'])) { $template->data['image'] = HTTP_CATALOG . 'image/' . $voucher_theme_info['image']; } else { $template->data['image'] = ''; } $template->data['store_name'] = $this->config->get('config_name'); $template->data['store_url'] = HTTP_CATALOG; $template->data['message'] = nl2br($voucher_info['message']); $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($voucher_info['to_email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($this->config->get('config_name')); $mail->setSubject(html_entity_decode(sprintf($this->language->get('text_subject'), $voucher_info['from_name']), ENT_QUOTES, 'UTF-8')); $mail->setHtml($template->fetch('mail/voucher.tpl')); $mail->send(); } } }
// Cache $cache = new Cache('file'); $registry->set('cache', $cache); // Session $session = new Session(); $registry->set('session', $session); // Language $languages = array(); $query = $db->query("SELECT * FROM `" . DB_PREFIX . "language`"); foreach ($query->rows as $result) { $languages[$result['code']] = $result; } $config->set('config_language_id', $languages[$config->get('config_admin_language')]['language_id']); // Language $language = new Language($languages[$config->get('config_admin_language')]['directory']); $language->load($languages[$config->get('config_admin_language')]['directory']); $registry->set('language', $language); // Document $registry->set('document', new Document()); // Currency $registry->set('currency', new Currency($registry)); // Weight $registry->set('weight', new Weight($registry)); // Length $registry->set('length', new Length($registry)); // User $registry->set('user', new User($registry)); // OpenBay Pro $registry->set('openbay', new Openbay($registry)); // Event $event = new Event($registry);
public function sendVoucher($voucher_id) { $voucher_info = $this->getVoucher($voucher_id); if ($voucher_info) { if ($voucher_info['order_id']) { $order_id = $voucher_info['order_id']; } else { $order_id = 0; } $this->load->model('sale/order'); $order_info = $this->model_sale_order->getOrder($order_id); // If voucher belongs to an order if ($order_info) { $this->load->model('localisation/language'); $language = new Language($order_info['language_directory']); $language->load($order_info['language_filename']); $language->load('mail/voucher'); // HTML Mail $data = array(); $data['title'] = sprintf($language->get('text_subject'), $voucher_info['from_name']); $data['text_greeting'] = sprintf($language->get('text_greeting'), $this->currency->format($voucher_info['amount'], $order_info['currency_code'], $order_info['currency_value'])); $data['text_from'] = sprintf($language->get('text_from'), $voucher_info['from_name']); $data['text_message'] = $language->get('text_message'); $data['text_redeem'] = sprintf($language->get('text_redeem'), $voucher_info['code']); $data['text_footer'] = $language->get('text_footer'); $this->load->model('sale/voucher_theme'); $voucher_theme_info = $this->model_sale_voucher_theme->getVoucherTheme($voucher_info['voucher_theme_id']); if ($voucher_theme_info && is_file(DIR_IMAGE . $voucher_theme_info['image'])) { $data['image'] = HTTP_CATALOG . 'image/' . $voucher_theme_info['image']; } else { $data['image'] = ''; } $data['store_name'] = $order_info['store_name']; $data['store_url'] = $order_info['store_url']; $data['message'] = nl2br($voucher_info['message']); $mail = new Mail($this->config->get('config_mail')); $mail->setTo($voucher_info['to_email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject(sprintf($language->get('text_subject'), $voucher_info['from_name'])); $mail->setHtml($this->load->view('mail/voucher.tpl', $data)); $mail->send(); // If voucher does not belong to an order } else { $this->load->language('mail/voucher'); $data = array(); $data['title'] = sprintf($this->language->get('text_subject'), $voucher_info['from_name']); $data['text_greeting'] = sprintf($this->language->get('text_greeting'), $this->currency->format($voucher_info['amount'], $order_info['currency_code'], $order_info['currency_value'])); $data['text_from'] = sprintf($this->language->get('text_from'), $voucher_info['from_name']); $data['text_message'] = $this->language->get('text_message'); $data['text_redeem'] = sprintf($this->language->get('text_redeem'), $voucher_info['code']); $data['text_footer'] = $this->language->get('text_footer'); $this->load->model('sale/voucher_theme'); $voucher_theme_info = $this->model_sale_voucher_theme->getVoucherTheme($voucher_info['voucher_theme_id']); if ($voucher_theme_info && is_file(DIR_IMAGE . $voucher_theme_info['image'])) { $data['image'] = HTTP_CATALOG . 'image/' . $voucher_theme_info['image']; } else { $data['image'] = ''; } $data['store_name'] = $this->config->get('config_name'); $data['store_url'] = HTTP_CATALOG; $data['message'] = nl2br($voucher_info['message']); $mail = new Mail($this->config->get('config_mail')); $mail->setTo($voucher_info['to_email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($this->config->get('config_name')); $mail->setSubject(sprintf($this->language->get('text_subject'), $voucher_info['from_name'])); $mail->setHtml($this->load->view('mail/voucher.tpl', $data)); $mail->send(); } } }
public function addOrderHistory($order_id, $data) { $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $data['order_status_id'] . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $data['order_status_id'] . "', notify = '" . (isset($data['notify']) ? (int) $data['notify'] : 0) . "', comment = '" . $this->db->escape(strip_tags($data['comment'])) . "', date_added = NOW()"); $order_info = $this->getOrder($order_id); // Send out any gift voucher mails if ($this->config->get('config_complete_status_id') == $data['order_status_id']) { $this->load->model('sale/voucher'); $results = $this->getOrderVouchers($order_id); foreach ($results as $result) { $this->model_sale_voucher->sendVoucher($result['voucher_id']); } } if ($data['notify']) { $language = new Language($order_info['language_directory']); $language->load($order_info['language_filename']); $language->load('mail/order'); $subject = sprintf($language->get('text_subject'), $order_info['store_name'], $order_id); $message = $language->get('text_order') . ' ' . $order_id . "\n"; $message .= $language->get('text_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n\n"; $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $data['order_status_id'] . "' AND language_id = '" . (int) $order_info['language_id'] . "'"); if ($order_status_query->num_rows) { $message .= $language->get('text_order_status') . "\n"; $message .= $order_status_query->row['name'] . "\n\n"; } if ($order_info['customer_id']) { $message .= $language->get('text_link') . "\n"; $message .= html_entity_decode($order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id, ENT_QUOTES, 'UTF-8') . "\n\n"; } if ($data['comment']) { $message .= $language->get('text_comment') . "\n\n"; $message .= strip_tags(html_entity_decode($data['comment'], ENT_QUOTES, 'UTF-8')) . "\n\n"; } $message .= $language->get('text_footer'); $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($order_info['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8')); $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $mail->send(); } $this->load->model('payment/amazon_checkout'); $this->model_payment_amazon_checkout->orderStatusChange($order_id, $data); }
public function update($order_id, $order_status_id, $comment = '', $notify = FALSE) { $order_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "language l ON (o.language_id = l.language_id) WHERE o.order_id = '" . (int) $order_id . "' AND o.order_status_id > '0'"); if ($order_query->num_rows) { $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $order_status_id . "', notify = '" . (int) $notify . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()"); if ($notify) { $language = new Language($order_query->row['directory']); $language->load($order_query->row['filename']); $language->load('mail/order_update'); $subject = sprintf($language->get('text_subject'), html_entity_decode($order_query->row['store_name'], ENT_QUOTES, 'UTF-8'), $order_id); $message = $language->get('text_order') . ' ' . $order_id . "\n"; $message .= $language->get('text_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_query->row['date_added'])) . "\n\n"; $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_id . "' AND language_id = '" . (int) $order_query->row['language_id'] . "'"); if ($order_status_query->num_rows) { $message .= $language->get('text_order_status') . "\n\n"; $message .= $order_status_query->row['name'] . "\n\n"; } $message .= $language->get('text_invoice') . "\n"; $message .= $order_query->row['store_url'] . 'index.php?route=account/invoice&order_id=' . $order_id . "\n\n"; if ($comment) { $message .= $language->get('text_comment') . "\n\n"; $message .= $comment . "\n\n"; } $message .= $language->get('text_footer'); $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($order_query->row['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_query->row['store_name']); $mail->setSubject($subject); $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $mail->send(); } } }
public function getOrderText($template_id, $data) { foreach ($data as $dataKey => $dataValue) { ${$dataKey} = $dataValue; } // Load the language for any mails that might be required to be sent out $language = new Language($order_info['language_directory'], $this->registry); $language->load('mail/order'); $text = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n"; $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n"; $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n"; $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n"; if ($comment && $notify) { $text .= $language->get('text_new_instruction') . "\n\n"; $text .= $comment . "\n\n"; } // Products $text .= $language->get('text_new_products') . "\n"; foreach ($getProducts as $product) { $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { if ($option['type'] != 'file') { $value = $option['value']; } else { $upload_info = $this->getUploadByCode($option['value']); if ($upload_info) { $value = $upload_info['name']; } else { $value = ''; } } $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) . "\n"; } } foreach ($getVouchers as $voucher) { $text .= '1x ' . $voucher['description'] . ' ' . $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']); } $text .= "\n"; $text .= $language->get('text_new_order_total') . "\n"; foreach ($getTotal as $total) { $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; } $text .= "\n"; if ($order_info['customer_id']) { $text .= $language->get('text_new_link') . "\n"; $text .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n"; } /* if ($download_status) { $text .= $language->get('text_new_download') . "\n"; $text .= $order_info['store_url'] . 'index.php?route=account/download' . "\n\n"; } */ // Comment if ($order_info['comment']) { $text .= $language->get('text_new_comment') . "\n\n"; $text .= $order_info['comment'] . "\n\n"; } $text .= $language->get('text_new_footer') . "\n\n"; return $text; }
if ($config->get('db_autostart')) { $registry->set('db', new DB($config->get('db_type'), $config->get('db_hostname'), $config->get('db_username'), $config->get('db_password'), $config->get('db_database'), $config->get('db_port'))); } // Session if ($config->get('session_autostart')) { $session = new Session(); $session->start(); $registry->set('session', $session); } // Cache $registry->set('cache', new Cache($config->get('cache_type'), $config->get('cache_expire'))); // Url $registry->set('url', new Url($config->get('site_ssl'))); // Language $language = new Language($config->get('language_default')); $language->load($config->get('language_default')); $registry->set('language', $language); // Document $registry->set('document', new Document()); // Event $event = new Event($registry); $registry->set('event', $event); // Event Register if ($config->has('action_event')) { foreach ($config->get('action_event') as $key => $value) { $event->register($key, new Action($value)); } } // Config Autoload if ($config->has('config_autoload')) { foreach ($config->get('config_autoload') as $value) {
// Loader $loader = new Loader($registry); $registry->set('load', $loader); // Url $url = new Url(HTTP_SERVER); $registry->set('url', $url); // Request $request = new Request(); $registry->set('request', $request); // Response $response = new Response(); $response->addHeader('Content-Type: text/html; charset=UTF-8'); $registry->set('response', $response); // Language $language = new Language('english'); $language->load('english'); $registry->set('language', $language); // Document $document = new Document(); $registry->set('document', $document); // Session $session = new Session(); $registry->set('session', $session); // Upgrade $upgrade = false; if (file_exists('../config.php')) { if (filesize('../config.php') > 0) { $upgrade = true; $lines = file(DIR_OPENCART . 'config.php'); foreach ($lines as $line) { if (strpos(strtoupper($line), 'DB_') !== false) {
public function update($order_id, $order_status_id, $comment = '', $notify = false) { $order_info = $this->getOrder($order_id); if ($order_info && $order_info['order_status_id']) { // Fraud Detection if ($this->config->get('config_fraud_detection')) { $this->load->model('checkout/fraud'); $risk_score = $this->model_checkout_fraud->getFraudScore($order_info); if ($risk_score > $this->config->get('config_fraud_score')) { $order_status_id = $this->config->get('config_fraud_status_id'); } } // Ban IP $status = false; $this->load->model('account/customer'); if ($order_info['customer_id']) { $results = $this->model_account_customer->getIps($order_info['customer_id']); foreach ($results as $result) { if ($this->model_account_customer->isBanIp($result['ip'])) { $status = true; break; } } } else { $status = $this->model_account_customer->isBanIp($order_info['ip']); } if ($status) { $order_status_id = $this->config->get('config_order_status_id'); } $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int)$order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int)$order_id . "'"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int)$order_id . "', order_status_id = '" . (int)$order_status_id . "', notify = '" . (int)$notify . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()"); // Send out any gift voucher mails if ($this->config->get('config_complete_status_id') == $order_status_id) { $this->load->model('checkout/voucher'); $this->model_checkout_voucher->confirm($order_id); } if ($notify) { $language = new Language($order_info['language_directory']); $language->load($order_info['language_filename']); $language->load('mail/order'); $subject = sprintf($language->get('text_update_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id); $message = $language->get('text_update_order') . ' ' . $order_id . "\n"; $message .= $language->get('text_update_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n\n"; $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "' AND language_id = '" . (int)$order_info['language_id'] . "'"); if ($order_status_query->num_rows) { $message .= $language->get('text_update_order_status') . "\n\n"; $message .= $order_status_query->row['name'] . "\n\n"; } if ($order_info['customer_id']) { $message .= $language->get('text_update_link') . "\n"; $message .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n"; } if ($comment) { $message .= $language->get('text_update_comment') . "\n\n"; $message .= $comment . "\n\n"; } $message .= $language->get('text_update_footer'); $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->hostname = $this->config->get('config_smtp_host'); $mail->username = $this->config->get('config_smtp_username'); $mail->password = $this->config->get('config_smtp_password'); $mail->port = $this->config->get('config_smtp_port'); $mail->timeout = $this->config->get('config_smtp_timeout'); $mail->setTo($order_info['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8')); $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $mail->send(); } } }
} elseif ($detect) { $code = $detect; } else { $code = $config->get('config_language'); } if (!isset($session->data['language']) || $session->data['language'] != $code) { $session->data['language'] = $code; } if (!isset($request->cookie['language']) || $request->cookie['language'] != $code) { setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $request->server['HTTP_HOST']); } $config->set('config_language_id', $languages[$code]['language_id']); $config->set('config_language', $languages[$code]['code']); // Language $language = new Language($languages[$code]['directory']); $language->load($languages[$code]['filename']); $registry->set('language', $language); // Customer $registry->set('customer', new Customer($registry)); // Currency $registry->set('currency', new Currency($registry)); // Tax $registry->set('tax', new Tax($registry)); // Weight $registry->set('weight', new Weight($registry)); // Length $registry->set('length', new Length($registry)); // Cart $registry->set('cart', new Cart($registry)); // Front Controller $controller = new Front($registry);
public function addOrderHistory($order_id, $order_status_id, $comment = '', $notify = false) { $this->event->trigger('pre.order.history.add', $order_id); $order_info = $this->getOrder($order_id); if ($order_info) { // Fraud Detection $this->load->model('account/customer'); $customer_info = $this->model_account_customer->getCustomer($order_info['customer_id']); if ($customer_info && $customer_info['safe']) { $safe = true; } else { $safe = false; } if ($this->config->get('config_fraud_detection')) { $this->load->model('checkout/fraud'); $risk_score = $this->model_checkout_fraud->getFraudScore($order_info); if (!$safe && $risk_score > $this->config->get('config_fraud_score')) { $order_status_id = $this->config->get('config_fraud_status_id'); } } // Ban IP if (!$safe) { $status = false; if ($order_info['customer_id']) { $results = $this->model_account_customer->getIps($order_info['customer_id']); foreach ($results as $result) { if ($this->model_account_customer->isBanIp($result['ip'])) { $status = true; break; } } } else { $status = $this->model_account_customer->isBanIp($order_info['ip']); } if ($status) { $order_status_id = $this->config->get('config_order_status_id'); } } $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $order_status_id . "', notify = '" . (int) $notify . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()"); // If current order status is not processing or complete but new status is processing or complete then commence completing the order if (!in_array($order_info['order_status_id'], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status'))) && in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) { // Stock subtraction $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'"); foreach ($order_product_query->rows as $order_product) { $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_id = '" . (int) $order_product['product_id'] . "' AND subtract = '1'"); $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $order_product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int) $order_product['quantity'] . ") WHERE product_option_value_id = '" . (int) $option['product_option_value_id'] . "' AND subtract = '1'"); } } // Redeem coupon, vouchers and reward points $order_total_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC"); foreach ($order_total_query->rows as $order_total) { $this->load->model('total/' . $order_total['code']); if (method_exists($this->{'model_total_' . $order_total['code']}, 'confirm')) { $this->{'model_total_' . $order_total['code']}->confirm($order_info, $order_total); } } // Add commission if sale is linked to affiliate referral. if ($order_info['affiliate_id'] && $this->config->get('config_affiliate_auto')) { $this->load->model('affiliate/affiliate'); $this->model_affiliate_affiliate->addTransaction($order_info['affiliate_id'], $order_info['commission'], $order_id); } } // If old order status is the processing or complete status but new status is not then commence restock, and remove coupon, voucher and reward history if (in_array($order_info['order_status_id'], array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status'))) && !in_array($order_status_id, array_merge($this->config->get('config_processing_status'), $this->config->get('config_complete_status')))) { // Restock $product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'"); foreach ($product_query->rows as $product) { $this->db->query("UPDATE `" . DB_PREFIX . "product` SET quantity = (quantity + " . (int) $product['quantity'] . ") WHERE product_id = '" . (int) $product['product_id'] . "' AND subtract = '1'"); $option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'"); foreach ($option_query->rows as $option) { $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity + " . (int) $product['quantity'] . ") WHERE product_option_value_id = '" . (int) $option['product_option_value_id'] . "' AND subtract = '1'"); } } // Remove coupon, vouchers and reward points history $this->load->model('account/order'); $order_total_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC"); foreach ($order_total_query->rows as $order_total) { $this->load->model('total/' . $order_total['code']); if (method_exists($this->{'model_total_' . $order_total['code']}, 'unconfirm')) { $this->{'model_total_' . $order_total['code']}->unconfirm($order_id); } } // Remove commission if sale is linked to affiliate referral. if ($order_info['affiliate_id']) { $this->load->model('affiliate/affiliate'); $this->model_affiliate_affiliate->deleteTransaction($order_id); } } $this->cache->delete('product'); // If order status is 0 then becomes greater than 0 send main html email if (!$order_info['order_status_id'] && $order_status_id) { // Check for any downloadable products $download_status = false; $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int) $order_id . "'"); foreach ($order_product_query->rows as $order_product) { // Check if there are any linked downloads $product_download_query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "product_to_download` WHERE product_id = '" . (int) $order_product['product_id'] . "'"); if ($product_download_query->row['total']) { $download_status = true; } } // Load the language for any mails that might be required to be sent out $language = new Language($order_info['language_directory']); $language->load('default'); $language->load('mail/order'); $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_id . "' AND language_id = '" . (int) $order_info['language_id'] . "'"); if ($order_status_query->num_rows) { $order_status = $order_status_query->row['name']; } else { $order_status = ''; } $subject = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id); // HTML Mail $data = array(); $data['title'] = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id); $data['text_greeting'] = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')); $data['text_link'] = $language->get('text_new_link'); $data['text_download'] = $language->get('text_new_download'); $data['text_order_detail'] = $language->get('text_new_order_detail'); $data['text_instruction'] = $language->get('text_new_instruction'); $data['text_order_id'] = $language->get('text_new_order_id'); $data['text_date_added'] = $language->get('text_new_date_added'); $data['text_payment_method'] = $language->get('text_new_payment_method'); $data['text_shipping_method'] = $language->get('text_new_shipping_method'); $data['text_email'] = $language->get('text_new_email'); $data['text_telephone'] = $language->get('text_new_telephone'); $data['text_ip'] = $language->get('text_new_ip'); $data['text_order_status'] = $language->get('text_new_order_status'); $data['text_payment_address'] = $language->get('text_new_payment_address'); $data['text_shipping_address'] = $language->get('text_new_shipping_address'); $data['text_product'] = $language->get('text_new_product'); $data['text_model'] = $language->get('text_new_model'); $data['text_quantity'] = $language->get('text_new_quantity'); $data['text_price'] = $language->get('text_new_price'); $data['text_total'] = $language->get('text_new_total'); $data['text_footer'] = $language->get('text_new_footer'); $data['logo'] = $this->config->get('config_url') . 'image/' . $this->config->get('config_logo'); $data['store_name'] = $order_info['store_name']; $data['store_url'] = $order_info['store_url']; $data['customer_id'] = $order_info['customer_id']; $data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id; if ($download_status) { $data['download'] = $order_info['store_url'] . 'index.php?route=account/download'; } else { $data['download'] = ''; } $data['order_id'] = $order_id; $data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added'])); $data['payment_method'] = $order_info['payment_method']; $data['shipping_method'] = $order_info['shipping_method']; $data['email'] = $order_info['email']; $data['telephone'] = $order_info['telephone']; $data['ip'] = $order_info['ip']; $data['order_status'] = $order_status; if ($comment && $notify) { $data['comment'] = nl2br($comment); } else { $data['comment'] = ''; } if ($order_info['payment_address_format']) { $format = $order_info['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}'); $replace = array('firstname' => $order_info['payment_firstname'], 'lastname' => $order_info['payment_lastname'], 'company' => $order_info['payment_company'], 'address_1' => $order_info['payment_address_1'], 'address_2' => $order_info['payment_address_2'], 'city' => $order_info['payment_city'], 'postcode' => $order_info['payment_postcode'], 'zone' => $order_info['payment_zone'], 'zone_code' => $order_info['payment_zone_code'], 'country' => $order_info['payment_country']); $data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); if ($order_info['shipping_address_format']) { $format = $order_info['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}'); $replace = array('firstname' => $order_info['shipping_firstname'], 'lastname' => $order_info['shipping_lastname'], 'company' => $order_info['shipping_company'], 'address_1' => $order_info['shipping_address_1'], 'address_2' => $order_info['shipping_address_2'], 'city' => $order_info['shipping_city'], 'postcode' => $order_info['shipping_postcode'], 'zone' => $order_info['shipping_zone'], 'zone_code' => $order_info['shipping_zone_code'], 'country' => $order_info['shipping_country']); $data['shipping_address'] = 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->load->model('tool/upload'); // Products $data['products'] = array(); foreach ($order_product_query->rows as $product) { $option_data = array(); $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { 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 = ''; } } $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value); } $data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']), 'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value'])); } // Vouchers $data['vouchers'] = array(); $order_voucher_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_voucher WHERE order_id = '" . (int) $order_id . "'"); foreach ($order_voucher_query->rows as $voucher) { $data['vouchers'][] = array('description' => $voucher['description'], 'amount' => $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value'])); } // Order Totals $order_total_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE order_id = '" . (int) $order_id . "' ORDER BY sort_order ASC"); foreach ($order_total_query->rows as $total) { $data['totals'][] = array('title' => $total['title'], 'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value'])); } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) { $html = $this->load->view($this->config->get('config_template') . '/template/mail/order.tpl', $data); } else { $html = $this->load->view('default/template/mail/order.tpl', $data); } // Can not send confirmation emails for CBA orders as email is unknown $this->load->model('payment/amazon_checkout'); if (!$this->model_payment_amazon_checkout->isAmazonOrder($order_info['order_id'])) { // Text Mail $text = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n"; $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n"; $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n"; $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n"; if ($comment && $notify) { $text .= $language->get('text_new_instruction') . "\n\n"; $text .= $comment . "\n\n"; } // Products $text .= $language->get('text_new_products') . "\n"; foreach ($order_product_query->rows as $product) { $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { 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 = ''; } } $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) . "\n"; } } foreach ($order_voucher_query->rows as $voucher) { $text .= '1x ' . $voucher['description'] . ' ' . $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']); } $text .= "\n"; $text .= $language->get('text_new_order_total') . "\n"; foreach ($order_total_query->rows as $total) { $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; } $text .= "\n"; if ($order_info['customer_id']) { $text .= $language->get('text_new_link') . "\n"; $text .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n"; } if ($download_status) { $text .= $language->get('text_new_download') . "\n"; $text .= $order_info['store_url'] . 'index.php?route=account/download' . "\n\n"; } // Comment if ($order_info['comment']) { $text .= $language->get('text_new_comment') . "\n\n"; $text .= $order_info['comment'] . "\n\n"; } $text .= $language->get('text_new_footer') . "\n\n"; $mail = new Mail($this->config->get('config_mail')); $mail->setTo($order_info['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject($subject); $mail->setHtml($html); $mail->setText($text); $mail->send(); } // Admin Alert Mail if ($this->config->get('config_order_mail')) { $subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id); // HTML Mail $data['text_greeting'] = $language->get('text_new_received'); if ($comment) { if ($order_info['comment']) { $data['comment'] = nl2br($comment) . '<br/><br/>' . $order_info['comment']; } else { $data['comment'] = nl2br($comment); } } else { if ($order_info['comment']) { $data['comment'] = $order_info['comment']; } else { $data['comment'] = ''; } } $data['text_download'] = ''; $data['text_footer'] = ''; $data['text_link'] = ''; $data['link'] = ''; $data['download'] = ''; if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) { $html = $this->load->view($this->config->get('config_template') . '/template/mail/order.tpl', $data); } else { $html = $this->load->view('default/template/mail/order.tpl', $data); } // Text $text = $language->get('text_new_received') . "\n\n"; $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n"; $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n"; $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n"; $text .= $language->get('text_new_products') . "\n"; foreach ($order_product_query->rows as $product) { $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . $product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { if ($option['type'] != 'file') { $value = $option['value']; } else { $value = utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.')); } $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value) . "\n"; } } foreach ($order_voucher_query->rows as $voucher) { $text .= '1x ' . $voucher['description'] . ' ' . $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']); } $text .= "\n"; $text .= $language->get('text_new_order_total') . "\n"; foreach ($order_total_query->rows as $total) { $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; } $text .= "\n"; if ($order_info['comment']) { $text .= $language->get('text_new_comment') . "\n\n"; $text .= $order_info['comment'] . "\n\n"; } $mail = new Mail($this->config->get('config_mail')); $mail->setTo($this->config->get('config_email')); $mail->setFrom($this->config->get('config_email')); $mail->setReplyTo($order_info['email']); $mail->setSender($order_info['store_name']); $mail->setSubject($subject); $mail->setHtml($html); $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8')); $mail->send(); // Send to additional alert emails $emails = explode(',', $this->config->get('config_mail_alert')); foreach ($emails as $email) { if ($email && preg_match('/^[^\\@]+@.*.[a-z]{2,15}$/i', $email)) { $mail->setTo($email); $mail->send(); } } } } // If order status is not 0 then send update text email if ($order_info['order_status_id'] && $order_status_id) { $language = new Language($order_info['language_directory']); $language->load('default'); $language->load('mail/order'); $subject = sprintf($language->get('text_update_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id); $message = $language->get('text_update_order') . ' ' . $order_id . "\n"; $message .= $language->get('text_update_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n\n"; $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_id . "' AND language_id = '" . (int) $order_info['language_id'] . "'"); if ($order_status_query->num_rows) { $message .= $language->get('text_update_order_status') . "\n\n"; $message .= $order_status_query->row['name'] . "\n\n"; } if ($order_info['customer_id']) { $message .= $language->get('text_update_link') . "\n"; $message .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n"; } if ($notify && $comment) { $message .= $language->get('text_update_comment') . "\n\n"; $message .= strip_tags($comment) . "\n\n"; } $message .= $language->get('text_update_footer'); $mail = new Mail($this->config->get('config_mail')); $mail->setTo($order_info['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender($order_info['store_name']); $mail->setSubject($subject); $mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8')); $mail->send(); } // If order status in the complete range create any vouchers that where in the order need to be made available. if (in_array($order_info['order_status_id'], $this->config->get('config_complete_status'))) { // Send out any gift voucher mails $this->load->model('checkout/voucher'); $this->model_checkout_voucher->confirm($order_id); } } $this->event->trigger('post.order.history.add', $order_id); }
public function confirm($order_id, $order_status_id, $comment = '') { $order_info = $this->model_checkout_order->getOrder($order_id); $notify = $this->config->get('ebay_confirm_notify'); if ($order_info && !$order_info['order_status_id']) { $this->db->query("UPDATE `" . DB_PREFIX . "order` SET order_status_id = '" . (int) $order_status_id . "', date_modified = NOW() WHERE order_id = '" . (int) $order_id . "'"); $this->db->query("INSERT INTO " . DB_PREFIX . "order_history SET order_id = '" . (int) $order_id . "', order_status_id = '" . (int) $order_status_id . "', notify = '" . (int) $notify . "', comment = '" . $this->db->escape($comment) . "', date_added = NOW()"); if (isset($order_info['email']) && !empty($order_info['email']) && $notify == 1) { $order_product_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_product` WHERE `order_id` = '" . (int) $order_id . "'"); $this->cache->delete('product'); // Order Totals $order_total_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE `order_id` = '" . (int) $order_id . "' ORDER BY `sort_order` ASC"); foreach ($order_total_query->rows as $order_total) { $this->load->model('extension/total/' . $order_total['code']); if (property_exists($this->{'model_extension_total_' . $order_total['code']}, 'confirm')) { $this->{'model_extension_total_' . $order_total['code']}->confirm($order_info, $order_total); } } // Send out order confirmation mail if (version_compare(VERSION, '2.2', '>') == true) { $language_code = $order_info['language_code']; } else { $language_code = $order_info['language_directory']; } $language = new Language($language_code); $language->load($language_code); $language->load('mail/order'); $order_status_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_status` WHERE `order_status_id` = '" . (int) $order_status_id . "' AND `language_id` = '" . (int) $order_info['language_id'] . "'"); if ($order_status_query->num_rows) { $order_status = $order_status_query->row['name']; } else { $order_status = ''; } $subject = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id); // HTML Mail $data = array(); $data['title'] = sprintf($language->get('text_new_subject'), $order_info['store_name'], $order_id); $data['text_greeting'] = sprintf($language->get('text_new_greeting'), $order_info['store_name']); $data['text_link'] = $language->get('text_new_link'); $data['text_download'] = $language->get('text_new_download'); $data['text_order_detail'] = $language->get('text_new_order_detail'); $data['text_instruction'] = $language->get('text_new_instruction'); $data['text_order_id'] = $language->get('text_new_order_id'); $data['text_date_added'] = $language->get('text_new_date_added'); $data['text_payment_method'] = $language->get('text_new_payment_method'); $data['text_shipping_method'] = $language->get('text_new_shipping_method'); $data['text_email'] = $language->get('text_new_email'); $data['text_telephone'] = $language->get('text_new_telephone'); $data['text_ip'] = $language->get('text_new_ip'); $data['text_order_status'] = $language->get('text_new_order_status'); $data['text_payment_address'] = $language->get('text_new_payment_address'); $data['text_shipping_address'] = $language->get('text_new_shipping_address'); $data['text_product'] = $language->get('text_new_product'); $data['text_model'] = $language->get('text_new_model'); $data['text_quantity'] = $language->get('text_new_quantity'); $data['text_price'] = $language->get('text_new_price'); $data['text_total'] = $language->get('text_new_total'); $data['text_footer'] = $language->get('text_new_footer'); if ($this->config->get('ebay_email_brand_disable') == 1) { $data['text_powered'] = ''; } else { $data['text_powered'] = '<a href="http://www.openbaypro.com/">OpenBay Pro - eBay and Amazon order management for OpenCart</a> . '; } $data['logo'] = $this->config->get('config_url') . 'image/' . $this->config->get('config_logo'); $data['store_name'] = $order_info['store_name']; $data['store_url'] = $order_info['store_url']; $data['customer_id'] = $order_info['customer_id']; $data['link'] = $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id; $data['download'] = ''; $data['order_id'] = $order_id; $data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added'])); $data['payment_method'] = $order_info['payment_method']; $data['shipping_method'] = $order_info['shipping_method']; $data['email'] = $order_info['email']; $data['telephone'] = $order_info['telephone']; $data['ip'] = $order_info['ip']; $data['order_status'] = $order_status; $data['comment'] = ''; if ($comment && $notify) { $data['comment'] = nl2br($comment); } if ($order_info['payment_address_format']) { $format = $order_info['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}'); $replace = array('firstname' => $order_info['payment_firstname'], 'lastname' => $order_info['payment_lastname'], 'company' => $order_info['payment_company'], 'address_1' => $order_info['payment_address_1'], 'address_2' => $order_info['payment_address_2'], 'city' => $order_info['payment_city'], 'postcode' => $order_info['payment_postcode'], 'zone' => $order_info['payment_zone'], 'zone_code' => $order_info['payment_zone_code'], 'country' => $order_info['payment_country']); $data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); if ($order_info['shipping_address_format']) { $format = $order_info['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}'); $replace = array('firstname' => $order_info['shipping_firstname'], 'lastname' => $order_info['shipping_lastname'], 'company' => $order_info['shipping_company'], 'address_1' => $order_info['shipping_address_1'], 'address_2' => $order_info['shipping_address_2'], 'city' => $order_info['shipping_city'], 'postcode' => $order_info['shipping_postcode'], 'zone' => $order_info['shipping_zone'], 'zone_code' => $order_info['shipping_zone_code'], 'country' => $order_info['shipping_country']); $data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\\s\\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format)))); $data['products'] = array(); foreach ($order_product_query->rows as $product) { $option_data = array(); $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { if ($option['type'] != 'file') { $value = $option['value']; } else { $value = utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.')); } $option_data[] = array('name' => $option['name'], 'value' => utf8_strlen($value) > 20 ? utf8_substr($value, 0, 20) . '..' : $value); } $data['products'][] = array('name' => $product['name'], 'model' => $product['model'], 'option' => $option_data, 'quantity' => $product['quantity'], 'price' => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']), 'total' => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value'])); } $data['vouchers'] = array(); foreach ($order_total_query->rows as $total) { $data['totals'][] = array('title' => $total['title'], 'text' => $this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value'])); } // Text Mail $text = sprintf($language->get('text_new_greeting'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')) . "\n\n"; $text .= $language->get('text_new_order_id') . ' ' . $order_id . "\n"; $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n"; $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n"; if ($comment && $notify) { $text .= $language->get('text_new_instruction') . "\n\n"; $text .= $comment . "\n\n"; } // Products $text .= $language->get('text_new_products') . "\n"; foreach ($order_product_query->rows as $product) { $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($option['value']) > 20) ? utf8_substr($option['value'], 0, 20) . '..' : $option['value'] . "\n"; } } $text .= "\n"; $text .= $language->get('text_new_order_total') . "\n"; foreach ($order_total_query->rows as $total) { $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; } $text .= "\n"; if ($order_info['customer_id']) { $text .= $language->get('text_new_link') . "\n"; $text .= $order_info['store_url'] . 'index.php?route=account/order/info&order_id=' . $order_id . "\n\n"; } if ($order_info['comment']) { $text .= $language->get('text_new_comment') . "\n\n"; $text .= $order_info['comment'] . "\n\n"; } $text .= $language->get('text_new_footer') . "\n\n"; if ($notify == 1) { $mail = new Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); $mail->smtp_username = $this->config->get('config_mail_smtp_username'); $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); $mail->smtp_port = $this->config->get('config_mail_smtp_port'); $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); $mail->setTo($order_info['email']); $mail->setFrom($this->config->get('config_email')); $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')); $mail->setSubject($subject); $mail->setHtml($this->load->view('mail/order', $data)); $mail->setText($text); $mail->send(); } } } }
$registry->set('response', $response); // Session $registry->set('session', new Session()); // Cache $registry->set('cache', new Cache()); // Document $registry->set('document', new Document()); // Language $languages = array(); $query = $db->query("SELECT * FROM " . DB_PREFIX . "language"); foreach ($query->rows as $result) { $languages[$result['code']] = array('language_id' => $result['language_id'], 'name' => $result['name'], 'code' => $result['code'], 'locale' => $result['locale'], 'directory' => $result['directory'], 'filename' => $result['filename']); } $config->set('config_language_id', $languages[$config->get('config_admin_language')]['language_id']); $language = new Language($languages[$config->get('config_admin_language')]['directory']); $language->load($languages[$config->get('config_admin_language')]['filename']); $registry->set('language', $language); // Currency $registry->set('currency', new Currency($registry)); // Weight $registry->set('weight', new Weight($registry)); // Length $registry->set('length', new Length($registry)); // User $registry->set('user', new User($registry)); // Front Controller $controller = new Front($registry); // Router if (isset($request->get['mode'])) { if ($request->get['mode'] == 'checkauth') { $action = new Action('dataexchange/exchange1c/modeCheckauth');
/** * @covers FormHandler\Language::reset */ public function testReset() { //check when nothing is loaded it is empty $this->assertEmpty(Language::get(1)); //load language Language::load('en'); //check if a result comes back $this->assertNotEmpty(Language::get(1)); //reset language Language::reset(); //check $this->assertEmpty(Language::get(1)); $this->assertNull(Language::active()); }
} } } $code = $detect ? $detect : $config->get('config_language'); } if (!isset($session->data['language']) || $session->data['language'] != $code) { $session->data['language'] = $code; } if (!isset($request->cookie['language']) || $request->cookie['language'] != $code) { setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $request->server['HTTP_HOST']); } $config->set('config_language_id', $languages[$code]['language_id']); $config->set('config_language', $languages[$code]['code']); // Language $language = new Language($languages[$code]['directory']); $language->load('default'); $registry->set('language', $language); // Document $registry->set('document', new Document()); // Customer $customer = new Customer($registry); $registry->set('customer', $customer); // Customer Group if ($customer->isLogged()) { $config->set('config_customer_group_id', $customer->getGroupId()); } elseif (isset($session->data['customer']) && isset($session->data['customer']['customer_group_id'])) { // For API calls $config->set('config_customer_group_id', $session->data['customer']['customer_group_id']); } elseif (isset($session->data['guest']) && isset($session->data['guest']['customer_group_id'])) { $config->set('config_customer_group_id', $session->data['guest']['customer_group_id']); }
public function newOrderAdminNotify($order_id, $order_status_id) { $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); $language = new Language($order_info['language_code']); $language->load($order_info['language_code']); $language->load('mail/order'); $order_status = $this->db->query("SELECT `name` FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int) $order_status_id . "' AND language_id = '" . (int) $this->config->get('config_language_id') . "' LIMIT 1")->row['name']; // Order Totals $order_total_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_total` WHERE `order_id` = '" . (int) $order_id . "' ORDER BY `sort_order` ASC"); //Order contents $order_product_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_product` WHERE `order_id` = '" . (int) $order_id . "'"); $subject = sprintf($language->get('text_new_subject'), html_entity_decode($this->config->get('config_name'), ENT_QUOTES, 'UTF-8'), $order_id); // Text $text = $language->get('text_new_received') . "\n\n"; $text .= $language->get('text_new_order_id') . ' ' . $order_info['order_id'] . "\n"; $text .= $language->get('text_new_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_info['date_added'])) . "\n"; $text .= $language->get('text_new_order_status') . ' ' . $order_status . "\n\n"; $text .= $language->get('text_new_products') . "\n"; foreach ($order_product_query->rows as $product) { $text .= $product['quantity'] . 'x ' . $product['name'] . ' (' . $product['model'] . ') ' . html_entity_decode($this->currency->format($product['total'] + ($this->config->get('config_tax') ? $product['tax'] * $product['quantity'] : 0), $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int) $order_id . "' AND order_product_id = '" . (int) $product['order_product_id'] . "'"); foreach ($order_option_query->rows as $option) { if ($option['type'] != 'file') { $value = $option['value']; } else { $value = utf8_substr($option['value'], 0, utf8_strrpos($option['value'], '.')); } $text .= chr(9) . '-' . $option['name'] . ' ' . (utf8_strlen($value) > 20) ? utf8_substr($value, 0, 20) . '..' : $value . "\n"; } } if (isset($order_voucher_query) && is_array($order_voucher_query)) { foreach ($order_voucher_query->rows as $voucher) { $text .= '1x ' . $voucher['description'] . ' ' . $this->currency->format($voucher['amount'], $order_info['currency_code'], $order_info['currency_value']); } } $text .= "\n"; $text .= $language->get('text_new_order_total') . "\n"; foreach ($order_total_query->rows as $total) { $text .= $total['title'] . ': ' . html_entity_decode($this->currency->format($total['value'], $order_info['currency_code'], $order_info['currency_value']), ENT_NOQUOTES, 'UTF-8') . "\n"; } $text .= "\n"; if ($order_info['comment']) { $text .= $language->get('text_new_comment') . "\n\n"; $text .= $order_info['comment'] . "\n\n"; } $mail = new \Mail(); $mail->protocol = $this->config->get('config_mail_protocol'); $mail->parameter = $this->config->get('config_mail_parameter'); $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname'); $mail->smtp_username = $this->config->get('config_mail_smtp_username'); $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8'); $mail->smtp_port = $this->config->get('config_mail_smtp_port'); $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout'); $mail->setTo($this->config->get('config_email')); $mail->setFrom($this->config->get('config_email')); $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8')); $mail->setSubject($subject); $mail->setText($text); $mail->send(); // Send to additional alert emails $emails = explode(',', $this->config->get('config_alert_emails')); foreach ($emails as $email) { if ($email && filter_var($email, FILTER_VALIDATE_EMAIL)) { $mail->setTo($email); $mail->send(); } } }