diff --git a/classes/order/OrderHistory.php b/classes/order/OrderHistory.php
index 1aa520304..21a24b148 100644
--- a/classes/order/OrderHistory.php
+++ b/classes/order/OrderHistory.php
@@ -310,7 +310,7 @@ class OrderHistoryCore extends ObjectModel
return false;
$result = Db::getInstance()->getRow('
- SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`
+ SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`
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`
@@ -328,6 +328,14 @@ class OrderHistoryCore extends ObjectModel
);
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((float)$order->total_paid, new Currency((int)$order->id_currency), false);
$data['{order_name}'] = $order->getUniqReference();
diff --git a/classes/order/OrderState.php b/classes/order/OrderState.php
index b6764091b..192cc7b80 100644
--- a/classes/order/OrderState.php
+++ b/classes/order/OrderState.php
@@ -36,6 +36,8 @@ class OrderStateCore extends ObjectModel
/** @var boolean Send an e-mail to customer ? */
public $send_email;
+ public $module_name;
+
/** @var boolean Allow customer to view and download invoice when order is at this state */
public $invoice;
@@ -71,6 +73,7 @@ class OrderStateCore extends ObjectModel
'multilang' => true,
'fields' => array(
'send_email' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
+ 'module_name' => array('type' => self::TYPE_STRING, 'validate' => 'isModuleName'),
'invoice' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'),
'logable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
diff --git a/install-dev/data/db_structure.sql b/install-dev/data/db_structure.sql
index 52059508d..1600cf294 100644
--- a/install-dev/data/db_structure.sql
+++ b/install-dev/data/db_structure.sql
@@ -1264,7 +1264,8 @@ CREATE TABLE `PREFIX_order_slip_detail` (
CREATE TABLE `PREFIX_order_state` (
`id_order_state` int(10) UNSIGNED NOT NULL auto_increment,
`invoice` tinyint(1) UNSIGNED default '0',
- `send_email` tinyint(1) UNSIGNED NOT NULL default '0',
+ `send_email` tinyint(1) UNSIGNED NOT NULL default '0',
+ `module_name` VARCHAR(255) NULL DEFAULT NULL,
`color` varchar(32) default NULL,
`unremovable` tinyint(1) UNSIGNED NOT NULL,
`hidden` tinyint(1) UNSIGNED NOT NULL default '0',
@@ -1273,7 +1274,8 @@ CREATE TABLE `PREFIX_order_state` (
`shipped` tinyint(1) UNSIGNED NOT NULL default '0',
`paid` tinyint(1) UNSIGNED NOT NULL default '0',
`deleted` tinyint(1) UNSIGNED NOT NULL default '0',
- PRIMARY KEY (`id_order_state`)
+ PRIMARY KEY (`id_order_state`),
+ KEY `module_name` (`module_name`)
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
CREATE TABLE `PREFIX_order_state_lang` (
diff --git a/install-dev/data/xml/order_state.xml b/install-dev/data/xml/order_state.xml
index 77b2eaefd..770e9178e 100644
--- a/install-dev/data/xml/order_state.xml
+++ b/install-dev/data/xml/order_state.xml
@@ -3,6 +3,7 @@
+
@@ -12,7 +13,7 @@
-
+
@@ -21,7 +22,7 @@
-
+
diff --git a/install-dev/upgrade/sql/1.5.0.15.sql b/install-dev/upgrade/sql/1.5.0.15.sql
index ec7f8de82..da34b51c9 100644
--- a/install-dev/upgrade/sql/1.5.0.15.sql
+++ b/install-dev/upgrade/sql/1.5.0.15.sql
@@ -2,4 +2,9 @@ SET NAMES 'utf8';
/* PHP:p15015_blockadvertising_extension(); */;
+ALTER TABLE `PREFIX_order_state` ADD `module_name` VARCHAR(255) NULL DEFAULT NULL AFTER `send_email`;
+
+UPDATE `PREFIX_order_state` SET `module_name`='cheque' WHERE `id_order_state`=(SELECT `value` FROM `PREFIX_configuration` WHERE `name`='PS_OS_CHEQUE' LIMIT 1);
+
+UPDATE `PREFIX_order_state` SET `module_name`='bankwire' WHERE `id_order_state`=(SELECT `value` FROM `PREFIX_configuration` WHERE `name`='PS_OS_BANKWIRE' LIMIT 1);
diff --git a/modules/bankwire/bankwire.php b/modules/bankwire/bankwire.php
index 8e6e6a810..ed4231532 100644
--- a/modules/bankwire/bankwire.php
+++ b/modules/bankwire/bankwire.php
@@ -36,7 +36,7 @@ class BankWire extends PaymentModule
public $details;
public $owner;
public $address;
-
+ public $extra_mail_vars;
public function __construct()
{
$this->name = 'bankwire';
@@ -64,6 +64,12 @@ class BankWire extends PaymentModule
$this->warning = $this->l('Account owner and details must be configured in order to use this module correctly.');
if (!count(Currency::checkPaymentCurrencies($this->id)))
$this->warning = $this->l('No currency set for this module');
+
+ $this->extra_mail_vars = array(
+ '{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'),
+ '{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')),
+ '{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS'))
+ );
}
public function install()
diff --git a/modules/bankwire/validation.php b/modules/bankwire/validation.php
index 71cc3b308..bc72bf88c 100644
--- a/modules/bankwire/validation.php
+++ b/modules/bankwire/validation.php
@@ -58,12 +58,8 @@ if (!Validate::isLoadedObject($customer))
$currency = $context->currency;
$total = (float)($cart->getOrderTotal(true, Cart::BOTH));
-$mailVars = array(
- '{bankwire_owner}' => Configuration::get('BANK_WIRE_OWNER'),
- '{bankwire_details}' => nl2br(Configuration::get('BANK_WIRE_DETAILS')),
- '{bankwire_address}' => nl2br(Configuration::get('BANK_WIRE_ADDRESS'))
-);
-$bankwire->validateOrder($cart->id, Configuration::get('PS_OS_BANKWIRE'), $total, $bankwire->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key);
+$bankwire->validateOrder($cart->id, Configuration::get('PS_OS_BANKWIRE'), $total, $bankwire->displayName, NULL, array(), (int)$currency->id, false, $customer->secure_key);
+
$order = new Order($bankwire->currentOrder);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$bankwire->id.'&id_order='.$bankwire->currentOrder.'&key='.$customer->secure_key);
diff --git a/modules/cheque/cheque.php b/modules/cheque/cheque.php
index 665ba491e..df9103704 100644
--- a/modules/cheque/cheque.php
+++ b/modules/cheque/cheque.php
@@ -35,6 +35,7 @@ class Cheque extends PaymentModule
public $chequeName;
public $address;
+ public $extra_mail_vars;
public function __construct()
{
@@ -62,6 +63,12 @@ class Cheque extends PaymentModule
$this->warning = $this->l('\'To the order of\' and address must be configured in order to use this module correctly.');
if (!count(Currency::checkPaymentCurrencies($this->id)))
$this->warning = $this->l('No currency set for this module');
+
+ $this->extra_mail_vars = array(
+ '{cheque_name}' => Configuration::get('CHEQUE_NAME'),
+ '{cheque_address}' => Configuration::get('CHEQUE_ADDRESS'),
+ '{cheque_address_html}' => str_replace("\n", '
', Configuration::get('CHEQUE_ADDRESS'))
+ );
}
public function install()
diff --git a/modules/cheque/validation.php b/modules/cheque/validation.php
index 1971bb250..8033bb5de 100644
--- a/modules/cheque/validation.php
+++ b/modules/cheque/validation.php
@@ -61,12 +61,7 @@ if (!Validate::isLoadedObject($customer))
$currency = $context->currency;
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
-$mailVars = array(
- '{cheque_name}' => Configuration::get('CHEQUE_NAME'),
- '{cheque_address}' => Configuration::get('CHEQUE_ADDRESS'),
- '{cheque_address_html}' => str_replace("\n", '
', Configuration::get('CHEQUE_ADDRESS')));
-
-$cheque->validateOrder((int)$cart->id, Configuration::get('PS_OS_CHEQUE'), $total, $cheque->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key);
+$cheque->validateOrder((int)$cart->id, Configuration::get('PS_OS_CHEQUE'), $total, $cheque->displayName, NULL, array(), (int)$currency->id, false, $customer->secure_key);
Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)($cart->id).'&id_module='.(int)($cheque->id).'&id_order='.$cheque->currentOrder.'&key='.$customer->secure_key);