本文整理汇总了PHP中ShopUrl::cacheMainDomainForShop方法的典型用法代码示例。如果您正苦于以下问题:PHP ShopUrl::cacheMainDomainForShop方法的具体用法?PHP ShopUrl::cacheMainDomainForShop怎么用?PHP ShopUrl::cacheMainDomainForShop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShopUrl
的用法示例。
在下文中一共展示了ShopUrl::cacheMainDomainForShop方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
public function postProcess()
{
if ($id_customer_thread = (int) Tools::getValue('id_customer_thread')) {
if ($id_contact = (int) Tools::getValue('id_contact')) {
Db::getInstance()->execute('
UPDATE ' . _DB_PREFIX_ . 'customer_thread
SET id_contact = ' . (int) $id_contact . '
WHERE id_customer_thread = ' . (int) $id_customer_thread);
}
if ($id_status = (int) Tools::getValue('setstatus')) {
$status_array = array(1 => 'open', 2 => 'closed', 3 => 'pending1', 4 => 'pending2');
Db::getInstance()->execute('
UPDATE ' . _DB_PREFIX_ . 'customer_thread
SET status = "' . $status_array[$id_status] . '"
WHERE id_customer_thread = ' . (int) $id_customer_thread . ' LIMIT 1
');
}
if (isset($_POST['id_employee_forward'])) {
$messages = Db::getInstance()->getRow('
SELECT ct.*, cm.*, cl.name subject, CONCAT(e.firstname, \' \', e.lastname) employee_name,
CONCAT(c.firstname, \' \', c.lastname) customer_name, c.firstname
FROM ' . _DB_PREFIX_ . 'customer_thread ct
LEFT JOIN ' . _DB_PREFIX_ . 'customer_message cm
ON (ct.id_customer_thread = cm.id_customer_thread)
LEFT JOIN ' . _DB_PREFIX_ . 'contact_lang cl
ON (cl.id_contact = ct.id_contact AND cl.id_lang = ' . (int) $this->context->language->id . ')
LEFT OUTER JOIN ' . _DB_PREFIX_ . 'employee e
ON e.id_employee = cm.id_employee
LEFT OUTER JOIN ' . _DB_PREFIX_ . 'customer c
ON (c.email = ct.email)
WHERE ct.id_customer_thread = ' . (int) Tools::getValue('id_customer_thread') . '
ORDER BY cm.date_add DESC
');
$output = $this->displayMessage($messages, true, (int) Tools::getValue('id_employee_forward'));
$cm = new CustomerMessage();
$cm->id_employee = (int) $this->context->employee->id;
$cm->id_customer_thread = (int) Tools::getValue('id_customer_thread');
$cm->ip_address = (int) ip2long(Tools::getRemoteAddr());
$current_employee = $this->context->employee;
$id_employee = (int) Tools::getValue('id_employee_forward');
$employee = new Employee($id_employee);
$email = Tools::getValue('email');
$message = Tools::getValue('message_forward');
if (($error = $cm->validateField('message', $message, null, array(), true)) !== true) {
$this->errors[] = $error;
} elseif ($id_employee && $employee && Validate::isLoadedObject($employee)) {
$params = array('{messages}' => stripslashes($output), '{employee}' => $current_employee->firstname . ' ' . $current_employee->lastname, '{comment}' => stripslashes(Tools::nl2br($_POST['message_forward'])), '{firstname}' => $employee->firstname, '{lastname}' => $employee->lastname);
if (Mail::Send($this->context->language->id, 'forward_msg', Mail::l('Fwd: Customer message', $this->context->language->id), $params, $employee->email, $employee->firstname . ' ' . $employee->lastname, $current_employee->email, $current_employee->firstname . ' ' . $current_employee->lastname, null, null, _PS_MAIL_DIR_, true)) {
$cm->private = 1;
$cm->message = $this->l('Message forwarded to') . ' ' . $employee->firstname . ' ' . $employee->lastname . "\n" . $this->l('Comment:') . ' ' . $message;
$cm->add();
}
} elseif ($email && Validate::isEmail($email)) {
$params = array('{messages}' => Tools::nl2br(stripslashes($output)), '{employee}' => $current_employee->firstname . ' ' . $current_employee->lastname, '{comment}' => stripslashes($_POST['message_forward']));
if (Mail::Send($this->context->language->id, 'forward_msg', Mail::l('Fwd: Customer message', $this->context->language->id), $params, $email, null, $current_employee->email, $current_employee->firstname . ' ' . $current_employee->lastname, null, null, _PS_MAIL_DIR_, true)) {
$cm->message = $this->l('Message forwarded to') . ' ' . $email . "\n" . $this->l('Comment:') . ' ' . $message;
$cm->add();
}
} else {
$this->errors[] = '<div class="alert error">' . Tools::displayError('The email address is invalid.') . '</div>';
}
}
if (Tools::isSubmit('submitReply')) {
$ct = new CustomerThread($id_customer_thread);
ShopUrl::cacheMainDomainForShop((int) $ct->id_shop);
$cm = new CustomerMessage();
$cm->id_employee = (int) $this->context->employee->id;
$cm->id_customer_thread = $ct->id;
$cm->ip_address = (int) ip2long(Tools::getRemoteAddr());
$cm->message = Tools::getValue('reply_message');
if (($error = $cm->validateField('message', $cm->message, null, array(), true)) !== true) {
$this->errors[] = $error;
} elseif (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0) {
$this->errors[] = Tools::displayError('An error occurred during the file upload process.');
} elseif ($cm->add()) {
$file_attachment = null;
if (!empty($_FILES['joinFile']['name'])) {
$file_attachment['content'] = file_get_contents($_FILES['joinFile']['tmp_name']);
$file_attachment['name'] = $_FILES['joinFile']['name'];
$file_attachment['mime'] = $_FILES['joinFile']['type'];
}
$customer = new Customer($ct->id_customer);
$params = array('{reply}' => Tools::nl2br(Tools::getValue('reply_message')), '{link}' => Tools::url($this->context->link->getPageLink('contact', true), 'id_customer_thread=' . (int) $ct->id . '&token=' . $ct->token), '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname);
//#ct == id_customer_thread #tc == token of thread <== used in the synchronization imap
$contact = new Contact((int) $ct->id_contact, (int) $ct->id_lang);
if (Validate::isLoadedObject($contact)) {
$from_name = $contact->name;
$from_email = $contact->email;
} else {
$from_name = null;
$from_email = null;
}
if (Mail::Send((int) $ct->id_lang, 'reply_msg', sprintf(Mail::l('An answer to your message is available #ct%1$s #tc%2$s', $ct->id_lang), $ct->id, $ct->token), $params, Tools::getValue('msg_email'), null, $from_email, $from_name, $file_attachment, null, _PS_MAIL_DIR_, true)) {
$ct->status = 'closed';
$ct->update();
}
Tools::redirectAdmin(self::$currentIndex . '&id_customer_thread=' . (int) $id_customer_thread . '&viewcustomer_thread&token=' . Tools::getValue('token'));
} else {
$this->errors[] = Tools::displayError('An error occurred. Your message was not sent. Please contact your system administrator.');
}
//.........这里部分代码省略.........
示例2: getMainShopDomainSSL
public static function getMainShopDomainSSL($id_shop = null)
{
ShopUrl::cacheMainDomainForShop($id_shop);
return self::$main_domain_ssl[(int) $id_shop];
}
示例3: addWithemail
/**
* @param bool $autodate Optional
* @param array $template_vars Optional
* @param Context $context Optional
* @return bool
*/
public function addWithemail($autodate = true, $template_vars = false, Context $context = null)
{
if (!$context) {
$context = Context::getContext();
}
$order = new Order($this->id_order);
if (!$this->add($autodate)) {
return false;
}
$result = Db::getInstance()->getRow('
SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`
FROM `' . _DB_PREFIX_ . 'order_history` oh
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1');
if (isset($result['template']) && Validate::isEmail($result['email'])) {
ShopUrl::cacheMainDomainForShop($order->id_shop);
$topic = $result['osname'];
$data = array('{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int) $this->id_order, '{order_name}' => $order->getUniqReference());
if ($template_vars) {
$data = array_merge($data, $template_vars);
}
if ($result['module_name']) {
$module = Module::getInstanceByName($result['module_name']);
if (Validate::isLoadedObject($module) && isset($module->extra_mail_vars) && is_array($module->extra_mail_vars)) {
$data = array_merge($data, $module->extra_mail_vars);
}
}
$data['{total_paid}'] = Tools::displayPrice((double) $order->total_paid, new Currency((int) $order->id_currency), false);
$data['{order_name}'] = $order->getUniqReference();
if (Validate::isLoadedObject($order)) {
// Join PDF invoice if order state is "payment accepted"
if ((int) $result['id_order_state'] === 2 && (int) Configuration::get('PS_INVOICE') && $order->invoice_number) {
$context = Context::getContext();
$pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
$file_attachement['content'] = $pdf->render(false);
$file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['mime'] = 'application/pdf';
} else {
$file_attachement = null;
}
Mail::Send((int) $order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'] . ' ' . $result['lastname'], null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop);
}
ShopUrl::resetMainDomainCache();
}
return true;
}
示例4: postProcess
public function postProcess()
{
// If id_order is sent, we instanciate a new Order object
if (Tools::isSubmit('id_order') && Tools::getValue('id_order') > 0) {
$order = new Order(Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
$this->errors[] = Tools::displayError('The order cannot be found within your database.');
}
ShopUrl::cacheMainDomainForShop((int) $order->id_shop);
}
/* Update shipping number */
if (Tools::isSubmit('submitAddOrder') && ($id_cart = Tools::getValue('id_cart')) && ($module_name = Tools::getValue('payment_module_name')) && ($id_order_state = Tools::getValue('id_order_state')) && Validate::isModuleName($module_name)) {
if ($this->tabAccess['edit'] === '1') {
if (!Configuration::get('PS_CATALOG_MODE')) {
$payment_module = Module::getInstanceByName($module_name);
} else {
$payment_module = new BoOrder();
}
$cart = new Cart((int) $id_cart);
Context::getContext()->currency = new Currency((int) $cart->id_currency);
Context::getContext()->customer = new Customer((int) $cart->id_customer);
$bad_delivery = false;
if (($bad_delivery = (bool) (!Address::isCountryActiveById((int) $cart->id_address_delivery))) || !Address::isCountryActiveById((int) $cart->id_address_invoice)) {
if ($bad_delivery) {
$this->errors[] = Tools::displayError('This delivery address country is not active.');
} else {
$this->errors[] = Tools::displayError('This invoice address country is not active.');
}
} else {
$employee = new Employee((int) Context::getContext()->cookie->id_employee);
$payment_module->validateOrder((int) $cart->id, (int) $id_order_state, $cart->getOrderTotal(true, Cart::BOTH), $payment_module->displayName, $this->l('Manual order -- Employee:') . ' ' . substr($employee->firstname, 0, 1) . '. ' . $employee->lastname, array(), null, false, $cart->secure_key);
if ($payment_module->currentOrder) {
Tools::redirectAdmin(self::$currentIndex . '&id_order=' . $payment_module->currentOrder . '&vieworder' . '&token=' . $this->token);
}
}
} else {
$this->errors[] = Tools::displayError('You do not have permission to add this.');
}
} else {
parent::postProcess();
}
}
示例5: sendEmail
public function sendEmail($order, $template_vars = false)
{
$result = Db::getInstance()->getRow('
SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`
FROM `' . _DB_PREFIX_ . 'order_history` oh
LEFT JOIN `' . _DB_PREFIX_ . 'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON o.`id_customer` = c.`id_customer`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state` os ON oh.`id_order_state` = os.`id_order_state`
LEFT JOIN `' . _DB_PREFIX_ . 'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
WHERE oh.`id_order_history` = ' . (int) $this->id . ' AND os.`send_email` = 1');
if (isset($result['template']) && Validate::isEmail($result['email'])) {
ShopUrl::cacheMainDomainForShop($order->id_shop);
$topic = $result['osname'];
$data = array('{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int) $this->id_order, '{order_name}' => $order->getUniqReference());
if ($result['module_name']) {
$module = Module::getInstanceByName($result['module_name']);
if (Validate::isLoadedObject($module) && isset($module->extra_mail_vars) && is_array($module->extra_mail_vars)) {
$data = array_merge($data, $module->extra_mail_vars);
}
}
if ($template_vars) {
$data = array_merge($data, $template_vars);
}
$data['{total_paid}'] = Tools::displayPrice((double) $order->total_paid, new Currency((int) $order->id_currency), false);
if (Validate::isLoadedObject($order)) {
// Attach invoice and / or delivery-slip if they exists and status is set to attach them
if ($result['pdf_invoice'] || $result['pdf_delivery']) {
$context = Context::getContext();
$invoice = $order->getInvoicesCollection();
$file_attachement = array();
if ($result['pdf_invoice'] && (int) Configuration::get('PS_INVOICE') && $order->invoice_number) {
Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $invoice));
$pdf = new PDF($invoice, PDF::TEMPLATE_INVOICE, $context->smarty);
$file_attachement['invoice']['content'] = $pdf->render(false);
$file_attachement['invoice']['name'] = Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number) . '.pdf';
$file_attachement['invoice']['mime'] = 'application/pdf';
}
if ($result['pdf_delivery'] && $order->delivery_number) {
$pdf = new PDF($invoice, PDF::TEMPLATE_DELIVERY_SLIP, $context->smarty);
$file_attachement['delivery']['content'] = $pdf->render(false);
$file_attachement['delivery']['name'] = Configuration::get('PS_DELIVERY_PREFIX', Context::getContext()->language->id, null, $order->id_shop) . sprintf('%06d', $order->delivery_number) . '.pdf';
$file_attachement['delivery']['mime'] = 'application/pdf';
}
} else {
$file_attachement = null;
}
if (!Mail::Send((int) $order->id_lang, $result['template'], $topic, $data, $result['email'], $result['firstname'] . ' ' . $result['lastname'], null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop)) {
return false;
}
}
ShopUrl::resetMainDomainCache();
}
return true;
}
示例6: Send
//.........这里部分代码省略.........
/* Get templates content */
$iso = Language::getIsoById((int) $id_lang);
if (!$iso) {
Tools::dieOrLog(Tools::displayError('Error - No ISO code for email'), $die);
return false;
}
$template = $iso . '/' . $template;
$module_name = false;
$override_mail = false;
// get templatePath
if (preg_match('#' . __PS_BASE_URI__ . 'modules/#', str_replace(DIRECTORY_SEPARATOR, '/', $template_path)) && preg_match('#modules/([a-z0-9_-]+)/#ui', str_replace(DIRECTORY_SEPARATOR, '/', $template_path), $res)) {
$module_name = $res[1];
}
if ($module_name !== false && (file_exists($theme_path . 'modules/' . $module_name . '/mails/' . $template . '.txt') || file_exists($theme_path . 'modules/' . $module_name . '/mails/' . $template . '.html'))) {
$template_path = $theme_path . 'modules/' . $module_name . '/mails/';
} elseif (file_exists($theme_path . 'mails/' . $template . '.txt') || file_exists($theme_path . 'mails/' . $template . '.html')) {
$template_path = $theme_path . 'mails/';
$override_mail = true;
}
if (!file_exists($template_path . $template . '.txt') && ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT)) {
Tools::dieOrLog(Tools::displayError('Error - The following e-mail template is missing:') . ' ' . $template_path . $template . '.txt', $die);
return false;
} else {
if (!file_exists($template_path . $template . '.html') && ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_HTML)) {
Tools::dieOrLog(Tools::displayError('Error - The following e-mail template is missing:') . ' ' . $template_path . $template . '.html', $die);
return false;
}
}
$template_html = file_get_contents($template_path . $template . '.html');
$template_txt = strip_tags(html_entity_decode(file_get_contents($template_path . $template . '.txt'), null, 'utf-8'));
if ($override_mail && file_exists($template_path . $iso . '/lang.php')) {
include_once $template_path . $iso . '/lang.php';
} else {
if ($module_name && file_exists($theme_path . 'mails/' . $iso . '/lang.php')) {
include_once $theme_path . 'mails/' . $iso . '/lang.php';
} else {
if (file_exists(_PS_MAIL_DIR_ . $iso . '/lang.php')) {
include_once _PS_MAIL_DIR_ . $iso . '/lang.php';
} else {
Tools::dieOrLog(Tools::displayError('Error - The lang file is missing for :') . ' ' . $iso, $die);
return false;
}
}
}
/* Create mail and attach differents parts */
$message = new Swift_Message('[' . Configuration::get('PS_SHOP_NAME', null, null, $id_shop) . '] ' . $subject);
$message->setCharset('utf-8');
/* Set Message-ID - getmypid() is blocked on some hosting */
$message->setId(Mail::generateId());
$message->headers->setEncoding('Q');
if (Configuration::get('PS_LOGO_MAIL') !== false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_MAIL', null, null, $id_shop))) {
$logo = _PS_IMG_DIR_ . Configuration::get('PS_LOGO_MAIL', null, null, $id_shop);
} else {
if (file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO', null, null, $id_shop))) {
$logo = _PS_IMG_DIR_ . Configuration::get('PS_LOGO', null, null, $id_shop);
} else {
$template_vars['{shop_logo}'] = '';
}
}
ShopUrl::cacheMainDomainForShop((int) $id_shop);
/* don't attach the logo as */
if (isset($logo)) {
$template_vars['{shop_logo}'] = $message->attach(new Swift_Message_EmbeddedFile(new Swift_File($logo), null, ImageManager::getMimeTypeByExtension($logo)));
}
if (Context::getContext()->link instanceof Link === false) {
Context::getContext()->link = new Link();
}
$template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
$template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id);
$template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id);
$template_vars['{guest_tracking_url}'] = Context::getContext()->link->getPageLink('guest-tracking', true, Context::getContext()->language->id);
$template_vars['{history_url}'] = Context::getContext()->link->getPageLink('history', true, Context::getContext()->language->id);
$template_vars['{color}'] = Tools::safeOutput(Configuration::get('PS_MAIL_COLOR', null, null, $id_shop));
$swift->attachPlugin(new Swift_Plugin_Decorator(array($to_plugin => $template_vars)), 'decorator');
if ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT) {
$message->attach(new Swift_Message_Part($template_txt, 'text/plain', '8bit', 'utf-8'));
}
if ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_HTML) {
$message->attach(new Swift_Message_Part($template_html, 'text/html', '8bit', 'utf-8'));
}
if ($file_attachment && !empty($file_attachment)) {
// Multiple attachments?
if (!is_array(current($file_attachment))) {
$file_attachment = array($file_attachment);
}
foreach ($file_attachment as $attachment) {
if (isset($attachment['content']) && isset($attachment['name']) && isset($attachment['mime'])) {
$message->attach(new Swift_Message_Attachment($attachment['content'], $attachment['name'], $attachment['mime']));
}
}
}
/* Send mail */
$send = $swift->send($message, $to, new Swift_Address($from, $from_name));
$swift->disconnect();
ShopUrl::resetMainDomainCache();
return $send;
} catch (Swift_Exception $e) {
return false;
}
}
示例7: Send
//.........这里部分代码省略.........
if ($override_mail && file_exists($template_path . $iso . '/lang.php')) {
include_once $template_path . $iso . '/lang.php';
} elseif ($module_name && file_exists($theme_path . 'mails/' . $iso . '/lang.php')) {
include_once $theme_path . 'mails/' . $iso . '/lang.php';
} elseif (file_exists(_PS_MAIL_DIR_ . $iso . '/lang.php')) {
include_once _PS_MAIL_DIR_ . $iso . '/lang.php';
} else {
Tools::dieOrLog(Tools::displayError('Error - The language file is missing for:') . ' ' . $iso, $die);
return false;
}
/* Create mail and attach differents parts */
$subject = '[' . Configuration::get('PS_SHOP_NAME', null, null, $id_shop) . '] ' . $subject;
$message->setSubject($subject);
$message->setCharset('utf-8');
/* Set Message-ID - getmypid() is blocked on some hosting */
$message->setId(Mail::generateId());
if (!($reply_to && Validate::isEmail($reply_to))) {
$reply_to = $from;
}
if (isset($reply_to) && $reply_to) {
$message->setReplyTo($reply_to);
}
$template_vars = array_map(array('Tools', 'htmlentitiesDecodeUTF8'), $template_vars);
$template_vars = array_map(array('Tools', 'stripslashes'), $template_vars);
if (Configuration::get('PS_LOGO_MAIL') !== false && file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO_MAIL', null, null, $id_shop))) {
$logo = _PS_IMG_DIR_ . Configuration::get('PS_LOGO_MAIL', null, null, $id_shop);
} else {
if (file_exists(_PS_IMG_DIR_ . Configuration::get('PS_LOGO', null, null, $id_shop))) {
$logo = _PS_IMG_DIR_ . Configuration::get('PS_LOGO', null, null, $id_shop);
} else {
$template_vars['{shop_logo}'] = '';
}
}
ShopUrl::cacheMainDomainForShop((int) $id_shop);
/* don't attach the logo as */
if (isset($logo)) {
$template_vars['{shop_logo}'] = $message->embed(Swift_Image::fromPath($logo));
}
if (Context::getContext()->link instanceof Link === false) {
Context::getContext()->link = new Link();
}
$template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop));
$template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id, null, false, $id_shop);
$template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id, null, false, $id_shop);
$template_vars['{guest_tracking_url}'] = Context::getContext()->link->getPageLink('guest-tracking', true, Context::getContext()->language->id, null, false, $id_shop);
$template_vars['{history_url}'] = Context::getContext()->link->getPageLink('history', true, Context::getContext()->language->id, null, false, $id_shop);
$template_vars['{color}'] = Tools::safeOutput(Configuration::get('PS_MAIL_COLOR', null, null, $id_shop));
// Get extra template_vars
$extra_template_vars = array();
Hook::exec('actionGetExtraMailTemplateVars', array('template' => $template, 'template_vars' => $template_vars, 'extra_template_vars' => &$extra_template_vars, 'id_lang' => (int) $id_lang), null, true);
$template_vars = array_merge($template_vars, $extra_template_vars);
$swift->registerPlugin(new Swift_Plugins_DecoratorPlugin(array($to_plugin => $template_vars)));
if ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_TEXT) {
$message->addPart($template_txt, 'text/plain', 'utf-8');
}
if ($configuration['PS_MAIL_TYPE'] == Mail::TYPE_BOTH || $configuration['PS_MAIL_TYPE'] == Mail::TYPE_HTML) {
$message->addPart($template_html, 'text/html', 'utf-8');
}
if ($file_attachment && !empty($file_attachment)) {
// Multiple attachments?
if (!is_array(current($file_attachment))) {
$file_attachment = array($file_attachment);
}
foreach ($file_attachment as $attachment) {
if (isset($attachment['content']) && isset($attachment['name']) && isset($attachment['mime'])) {
$message->attach(Swift_Attachment::newInstance()->setFilename($attachment['name'])->setContentType($attachment['mime'])->setBody($attachment['content']));
示例8: execCapture
public function execCapture()
{
$context = Context::getContext();
$hipay = new HiPay_Tpp();
$hipay_redirect_status = 'ok';
// If id_order is sent, we instanciate a new Order object
if (Tools::isSubmit('id_order') && Tools::getValue('id_order') > 0) {
$order = new Order(Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
throw new PrestaShopException('Can\'t load Order object');
}
if (version_compare(_PS_VERSION_, '1.5.6', '>')) {
ShopUrl::cacheMainDomainForShop((int) $order->id_shop);
}
if (Tools::isSubmit('id_emp') && Tools::getValue('id_emp') > 0) {
$id_employee = Tools::getValue('id_emp');
} else {
$id_employee = '1';
}
}
if (Tools::isSubmit('hipay_capture_type')) {
$refund_type = Tools::getValue('hipay_capture_type');
$refund_amount = Tools::getValue('hipay_capture_amount');
$refund_amount = str_replace(' ', '', $refund_amount);
$refund_amount = floatval(str_replace(',', '.', $refund_amount));
}
// First check
if (Tools::isSubmit('hipay_capture_submit') && $refund_type == 'partial') {
$hipay_redirect_status = false;
$hipay = new HiPay_Tpp();
$orderLoaded = new OrderCore(Tools::getValue('id_order'));
// v1.5 // $orderTotal = $orderLoaded->total_products_wt + $orderLoaded->total_shipping_tax_incl + $orderLoaded->total_wrapping_tax_incl;
$orderTotal = $orderLoaded->total_products_wt + $orderLoaded->total_shipping + $orderLoaded->total_wrapping;
$totalEncaissement = $hipay->getOrderTotalAmountCaptured($orderLoaded->id);
$stillToCapture = floatval($orderTotal - $totalEncaissement);
if (!$refund_amount) {
$hipay_redirect_status = $hipay->l('Please enter an amount', 'capture');
Tools::redirectAdmin('../../' . Tools::getValue('adminDir') . '/index.php?tab=AdminOrders' . '&id_order=' . (int) $order->id . '&vieworder&token=' . Tools::getValue('token') . '&hipay_err=' . $hipay_redirect_status . '#hipay');
die('');
}
if ($refund_amount < 0) {
$hipay_redirect_status = $hipay->l('Please enter an amount greater than zero', 'capture');
Tools::redirectAdmin('../../' . Tools::getValue('adminDir') . '/index.php?tab=AdminOrders' . '&id_order=' . (int) $order->id . '&vieworder&token=' . Tools::getValue('token') . '&hipay_err=' . $hipay_redirect_status . '#hipay');
die('');
}
if ($refund_amount > $stillToCapture) {
$hipay_redirect_status = $hipay->l('Amount exceeding authorized amount', 'capture');
Tools::redirectAdmin('../../' . Tools::getValue('adminDir') . '/index.php?tab=AdminOrders' . '&id_order=' . (int) $order->id . '&vieworder&token=' . Tools::getValue('token') . '&hipay_err=' . $hipay_redirect_status . '#hipay');
die('');
}
}
if (Tools::isSubmit('hipay_capture_submit') && isset($order)) {
$sql = "SELECT * FROM `" . _DB_PREFIX_ . "hipay_transactions` WHERE `cart_id`='" . (int) $order->id_cart . "'";
$result = Db::getInstance()->getRow($sql);
$reference = $result['transaction_reference'];
if ($refund_type == 'complete') {
// Appel HiPay
$data = HipayMaintenance::getMaintenanceData('capture', '0');
$response = HipayMaintenance::restMaintenanceApi($reference, $data);
// Ajout commentaire
$msg = new Message();
$message = 'HIPAY_CAPTURE_REQUESTED ' . $orderTotal;
$message = strip_tags($message, '<br>');
if (Validate::isCleanHtml($message)) {
$msg->message = $message;
$msg->id_order = intval($order->id);
$msg->private = 1;
$msg->add();
}
} else {
// 'partial';
// Appel HiPay
/**
* VERIFICATION
*/
// v1.5 // $orderTotal = $order->total_products_wt + $order->total_shipping_tax_incl + $order->total_wrapping_tax_incl;
$orderTotal = $order->total_products_wt + $order->total_shipping + $order->total_wrapping;
$totalEncaissement = $this->getOrderTotalAmountCaptured($order->id);
$stillToCapture = $orderTotal - $totalEncaissement;
$orderLoaded = new OrderCore(Tools::getValue('id_order'));
$currentState = $orderLoaded->getCurrentState();
$stateLoaded = new OrderState($currentState);
if (round($stillToCapture, 2) < round($refund_amount, 2)) {
$hipay_redirect_status = $hipay->l('Error, you are trying to capture more than the amount remaining', 'capture');
} else {
$data = HipayMaintenance::getMaintenanceData('capture', $refund_amount);
$response = HipayMaintenance::restMaintenanceApi($reference, $data);
// Ajout commentaire
$msg = new Message();
$message = 'HIPAY_CAPTURE_REQUESTED ' . $refund_amount;
$message = strip_tags($message, '<br>');
if (Validate::isCleanHtml($message)) {
$msg->message = $message;
$msg->id_order = intval($order->id);
$msg->private = 1;
$msg->add();
}
$hipay_redirect_status = 'ok';
}
}
//.........这里部分代码省略.........
示例9: postProcess
public function postProcess()
{
if (isset($_GET['dobirkaorder']) && Tools::getValue('id_order') > 0) {
return $this->processDobirka();
}
if (isset($_GET['exportedorder']) && Tools::getValue('id_order') > 0) {
return $this->processExported();
}
if (Tools::isSubmit('updateorder') && Tools::getValue('id_order')) {
$link = Context::getContext()->link->getAdminLink('AdminOrders');
$link .= '&id_order=' . Tools::getValue('id_order') . '&vieworder';
Tools::redirectAdmin($link);
}
// If id_order is sent, we instanciate a new Order object
if (Tools::isSubmit('id_order') && Tools::getValue('id_order') > 0) {
$order = new Order(Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
throw new PrestaShopException('Can\'t load Order object');
}
ShopUrl::cacheMainDomainForShop((int) $order->id_shop);
}
parent::postProcess();
}
示例10: postProcess
/**
*
* @see FrontController::postProcess()
*/
public function postProcess()
{
$this->HipayLog('####################################################');
$this->HipayLog('# Début demande de remboursement partiel ou complète');
$this->HipayLog('####################################################');
$context = Context::getContext();
$hipay = new HiPay_Tpp();
$hipay_redirect_status = 'ok';
$this->HipayLog('-- context et hipay sont init');
// If id_order is sent, we instanciate a new Order object
if (Tools::isSubmit('id_order') && Tools::getValue('id_order') > 0) {
$this->HipayLog('--------------------------------------------------');
$this->HipayLog('-- init de la commande = ' . Tools::getValue('id_order'));
$order = new Order(Tools::getValue('id_order'));
if (!Validate::isLoadedObject($order)) {
throw new PrestaShopException('Can\'t load Order object');
}
if (version_compare(_PS_VERSION_, '1.5.6', '>')) {
$this->HipayLog('---- init du shop si version > à la 1.5.6 = ' . $order->id_shop);
ShopUrl::cacheMainDomainForShop((int) $order->id_shop);
}
if (Tools::isSubmit('id_emp') && Tools::getValue('id_emp') > 0) {
$id_employee = Tools::getValue('id_emp');
} else {
$id_employee = '1';
}
$this->HipayLog('---- init id_emp = ' . $id_employee);
$this->HipayLog('--------------------------------------------------');
}
if (Tools::isSubmit('hipay_refund_type')) {
$this->HipayLog('--------------------------------------------------');
$refund_type = Tools::getValue('hipay_refund_type');
$refund_amount = Tools::getValue('hipay_refund_amount');
$refund_amount = str_replace(' ', '', $refund_amount);
$refund_amount = floatval(str_replace(',', '.', $refund_amount));
$this->HipayLog('-- init refund_type = ' . $refund_type);
$this->HipayLog('-- init refund_amount = ' . $refund_amount);
$this->HipayLog('--------------------------------------------------');
}
// First check
if (Tools::isSubmit('hipay_refund_submit') && $refund_type == 'partial') {
$this->HipayLog('--------------------------------------------------');
$this->HipayLog('-- Début Refund_submit & partiel');
$hipay_redirect_status = false;
$hipay = new HiPay_Tpp();
$orderLoaded = new OrderCore(Tools::getValue('id_order'));
$orderTotal = $orderLoaded->total_products_wt + $orderLoaded->total_shipping_tax_incl + $orderLoaded->total_wrapping_tax_incl;
$this->HipayLog('---- Init id_order = ' . Tools::getValue('id_order'));
$this->HipayLog('---- Init orderTotal => ' . $orderTotal . ' = ' . $orderLoaded->total_products_wt . ' + ' . $orderLoaded->total_shipping_tax_incl . ' + ' . $orderLoaded->total_wrapping_tax_incl);
// patch de compatibilité
if (_PS_VERSION_ < '1.5') {
$id_or_reference = $orderLoaded->id;
} else {
$id_or_reference = $orderLoaded->reference;
}
$this->HipayLog('---- PS_VERSION = ' . _PS_VERSION_);
$this->HipayLog('---- id_or_reference = ' . $id_or_reference);
$totalEncaissement = $hipay->getOrderTotalAmountCaptured($id_or_reference);
$this->HipayLog('---- totalEncaissement = ' . $totalEncaissement);
// -----------------------
if (!$refund_amount) {
$hipay_redirect_status = $hipay->l('Please enter an amount', 'refund');
$url = Tools::getValue('adminDir') . '/index.php?controller=AdminOrders' . '&id_order=' . (int) $orderLoaded->id . '&vieworder&token=' . Tools::getValue('token') . '&hipay_refund_err=' . $hipay_redirect_status . '#hipay';
$this->HipayLog('---- Init URL pour redirectAdmin - refund_amount = ' . $url);
$this->HipayLog('--------------------------------------------------');
Tools::redirectAdmin($url);
die('');
}
if ($refund_amount < 0) {
$hipay_redirect_status = $hipay->l('Please enter an amount greater than zero', 'refund');
$url = Tools::getValue('adminDir') . '/index.php?controller=AdminOrders' . '&id_order=' . (int) $orderLoaded->id . '&vieworder&token=' . Tools::getValue('token') . '&hipay_refund_err=' . $hipay_redirect_status . '#hipay';
$this->HipayLog('---- Init URL pour redirectAdmin - refund_amount = ' . $url);
$this->HipayLog('--------------------------------------------------');
Tools::redirectAdmin($url);
die('');
}
if ($refund_amount > $totalEncaissement) {
$hipay_redirect_status = $hipay->l('Amount exceeding authorized amount', 'refund');
$url = Tools::getValue('adminDir') . '/index.php?controller=AdminOrders' . '&id_order=' . (int) $orderLoaded->id . '&vieworder&token=' . Tools::getValue('token') . '&hipay_refund_err=' . $hipay_redirect_status . '#hipay';
$this->HipayLog('---- Init URL pour redirectAdmin - refund_amount = ' . $url);
$this->HipayLog('--------------------------------------------------');
Tools::redirectAdmin($url);
die('');
}
if (!is_numeric($refund_amount)) {
$hipay_redirect_status = $hipay->l('Please enter an amount', 'refund');
$url = Tools::getValue('adminDir') . '/index.php?controller=AdminOrders' . '&id_order=' . (int) $orderLoaded->id . '&vieworder&token=' . Tools::getValue('token') . '&hipay_refund_err=' . $hipay_redirect_status . '#hipay';
$this->HipayLog('---- Init URL pour redirectAdmin - refund_amount = ' . $url);
$this->HipayLog('--------------------------------------------------');
Tools::redirectAdmin($url);
die('');
}
$this->HipayLog('--------------------------------------------------');
}
if (Tools::isSubmit('hipay_refund_submit') && isset($order)) {
$this->HipayLog('--------------------------------------------------');
//.........这里部分代码省略.........