[*] Core: you can now associate modules to order states in order to add extra mail vars
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@16618 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -310,7 +310,7 @@ class OrderHistoryCore extends ObjectModel
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
$result = Db::getInstance()->getRow('
|
$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
|
FROM `'._DB_PREFIX_.'order_history` oh
|
||||||
LEFT JOIN `'._DB_PREFIX_.'orders` o ON oh.`id_order` = o.`id_order`
|
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_.'customer` c ON o.`id_customer` = c.`id_customer`
|
||||||
@@ -328,6 +328,14 @@ class OrderHistoryCore extends ObjectModel
|
|||||||
);
|
);
|
||||||
if ($template_vars)
|
if ($template_vars)
|
||||||
$data = array_merge($data, $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['{total_paid}'] = Tools::displayPrice((float)$order->total_paid, new Currency((int)$order->id_currency), false);
|
||||||
$data['{order_name}'] = $order->getUniqReference();
|
$data['{order_name}'] = $order->getUniqReference();
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ class OrderStateCore extends ObjectModel
|
|||||||
/** @var boolean Send an e-mail to customer ? */
|
/** @var boolean Send an e-mail to customer ? */
|
||||||
public $send_email;
|
public $send_email;
|
||||||
|
|
||||||
|
public $module_name;
|
||||||
|
|
||||||
/** @var boolean Allow customer to view and download invoice when order is at this state */
|
/** @var boolean Allow customer to view and download invoice when order is at this state */
|
||||||
public $invoice;
|
public $invoice;
|
||||||
|
|
||||||
@@ -71,6 +73,7 @@ class OrderStateCore extends ObjectModel
|
|||||||
'multilang' => true,
|
'multilang' => true,
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
'send_email' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
'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'),
|
'invoice' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'),
|
'color' => array('type' => self::TYPE_STRING, 'validate' => 'isColor'),
|
||||||
'logable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
'logable' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
||||||
|
|||||||
@@ -1264,7 +1264,8 @@ CREATE TABLE `PREFIX_order_slip_detail` (
|
|||||||
CREATE TABLE `PREFIX_order_state` (
|
CREATE TABLE `PREFIX_order_state` (
|
||||||
`id_order_state` int(10) UNSIGNED NOT NULL auto_increment,
|
`id_order_state` int(10) UNSIGNED NOT NULL auto_increment,
|
||||||
`invoice` tinyint(1) UNSIGNED default '0',
|
`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,
|
`color` varchar(32) default NULL,
|
||||||
`unremovable` tinyint(1) UNSIGNED NOT NULL,
|
`unremovable` tinyint(1) UNSIGNED NOT NULL,
|
||||||
`hidden` tinyint(1) UNSIGNED NOT NULL default '0',
|
`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',
|
`shipped` tinyint(1) UNSIGNED NOT NULL default '0',
|
||||||
`paid` tinyint(1) UNSIGNED NOT NULL default '0',
|
`paid` tinyint(1) UNSIGNED NOT NULL default '0',
|
||||||
`deleted` 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;
|
) ENGINE=ENGINE_TYPE DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
CREATE TABLE `PREFIX_order_state_lang` (
|
CREATE TABLE `PREFIX_order_state_lang` (
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<fields id="name" class="OrderState" image="os">
|
<fields id="name" class="OrderState" image="os">
|
||||||
<field name="invoice"/>
|
<field name="invoice"/>
|
||||||
<field name="send_email"/>
|
<field name="send_email"/>
|
||||||
|
<field name="module_name"/>
|
||||||
<field name="color"/>
|
<field name="color"/>
|
||||||
<field name="unremovable"/>
|
<field name="unremovable"/>
|
||||||
<field name="hidden"/>
|
<field name="hidden"/>
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
<field name="paid"/>
|
<field name="paid"/>
|
||||||
</fields>
|
</fields>
|
||||||
<entities>
|
<entities>
|
||||||
<order_state id="Awaiting_cheque_payment" invoice="0" send_email="1" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
|
<order_state id="Awaiting_cheque_payment" invoice="0" send_email="1" module_name="cheque" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
|
||||||
<order_state id="Payment_accepted" invoice="1" send_email="1" color="LimeGreen" unremovable="1" hidden="0" logable="1" delivery="0" shipped="0" paid="1"/>
|
<order_state id="Payment_accepted" invoice="1" send_email="1" color="LimeGreen" unremovable="1" hidden="0" logable="1" delivery="0" shipped="0" paid="1"/>
|
||||||
<order_state id="Preparation_in_progress" invoice="1" send_email="1" color="DarkOrange" unremovable="1" hidden="0" logable="1" delivery="1" shipped="0" paid="1"/>
|
<order_state id="Preparation_in_progress" invoice="1" send_email="1" color="DarkOrange" unremovable="1" hidden="0" logable="1" delivery="1" shipped="0" paid="1"/>
|
||||||
<order_state id="Shipped" invoice="1" send_email="1" color="BlueViolet" unremovable="1" hidden="0" logable="1" delivery="1" shipped="1" paid="1"/>
|
<order_state id="Shipped" invoice="1" send_email="1" color="BlueViolet" unremovable="1" hidden="0" logable="1" delivery="1" shipped="1" paid="1"/>
|
||||||
@@ -21,7 +22,7 @@
|
|||||||
<order_state id="Refund" invoice="1" send_email="1" color="#ec2e15" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
|
<order_state id="Refund" invoice="1" send_email="1" color="#ec2e15" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
|
||||||
<order_state id="Payment_error" invoice="0" send_email="1" color="#8f0621" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
|
<order_state id="Payment_error" invoice="0" send_email="1" color="#8f0621" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
|
||||||
<order_state id="On_backorder" invoice="1" send_email="1" color="HotPink" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="1"/>
|
<order_state id="On_backorder" invoice="1" send_email="1" color="HotPink" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="1"/>
|
||||||
<order_state id="Awaiting_bank_wire_payment" invoice="0" send_email="1" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
|
<order_state id="Awaiting_bank_wire_payment" invoice="0" send_email="1" module_name="bankwire" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
|
||||||
<order_state id="Awaiting_PayPal_payment" invoice="0" send_email="0" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
|
<order_state id="Awaiting_PayPal_payment" invoice="0" send_email="0" color="RoyalBlue" unremovable="1" hidden="0" logable="0" delivery="0" shipped="0" paid="0"/>
|
||||||
<order_state id="Payment_remotely_accepted" invoice="1" send_email="0" color="LimeGreen" unremovable="1" hidden="0" logable="1" delivery="0" shipped="0" paid="1"/>
|
<order_state id="Payment_remotely_accepted" invoice="1" send_email="0" color="LimeGreen" unremovable="1" hidden="0" logable="1" delivery="0" shipped="0" paid="1"/>
|
||||||
</entities>
|
</entities>
|
||||||
|
|||||||
@@ -2,4 +2,9 @@ SET NAMES 'utf8';
|
|||||||
|
|
||||||
/* PHP:p15015_blockadvertising_extension(); */;
|
/* 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);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class BankWire extends PaymentModule
|
|||||||
public $details;
|
public $details;
|
||||||
public $owner;
|
public $owner;
|
||||||
public $address;
|
public $address;
|
||||||
|
public $extra_mail_vars;
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->name = 'bankwire';
|
$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.');
|
$this->warning = $this->l('Account owner and details must be configured in order to use this module correctly.');
|
||||||
if (!count(Currency::checkPaymentCurrencies($this->id)))
|
if (!count(Currency::checkPaymentCurrencies($this->id)))
|
||||||
$this->warning = $this->l('No currency set for this module');
|
$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()
|
public function install()
|
||||||
|
|||||||
@@ -58,12 +58,8 @@ if (!Validate::isLoadedObject($customer))
|
|||||||
|
|
||||||
$currency = $context->currency;
|
$currency = $context->currency;
|
||||||
$total = (float)($cart->getOrderTotal(true, Cart::BOTH));
|
$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);
|
$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);
|
Tools::redirect('index.php?controller=order-confirmation&id_cart='.$cart->id.'&id_module='.$bankwire->id.'&id_order='.$bankwire->currentOrder.'&key='.$customer->secure_key);
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ class Cheque extends PaymentModule
|
|||||||
|
|
||||||
public $chequeName;
|
public $chequeName;
|
||||||
public $address;
|
public $address;
|
||||||
|
public $extra_mail_vars;
|
||||||
|
|
||||||
public function __construct()
|
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.');
|
$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)))
|
if (!count(Currency::checkPaymentCurrencies($this->id)))
|
||||||
$this->warning = $this->l('No currency set for this module');
|
$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", '<br />', Configuration::get('CHEQUE_ADDRESS'))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function install()
|
public function install()
|
||||||
|
|||||||
@@ -61,12 +61,7 @@ if (!Validate::isLoadedObject($customer))
|
|||||||
$currency = $context->currency;
|
$currency = $context->currency;
|
||||||
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
|
$total = (float)$cart->getOrderTotal(true, Cart::BOTH);
|
||||||
|
|
||||||
$mailVars = array(
|
$cheque->validateOrder((int)$cart->id, Configuration::get('PS_OS_CHEQUE'), $total, $cheque->displayName, NULL, array(), (int)$currency->id, false, $customer->secure_key);
|
||||||
'{cheque_name}' => Configuration::get('CHEQUE_NAME'),
|
|
||||||
'{cheque_address}' => Configuration::get('CHEQUE_ADDRESS'),
|
|
||||||
'{cheque_address_html}' => str_replace("\n", '<br />', 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);
|
|
||||||
|
|
||||||
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);
|
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);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user