Skip to content
This repository has been archived by the owner on Feb 3, 2021. It is now read-only.

[*] MO : Allow more customer attributes to be used in templates of MailAlert module #29

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions mailalerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,13 @@ public function hookActionValidateOrder($params)
'{message}' => $message
);

foreach(Customer::$definition['fields'] as $key => $value) {
if(!isset($customer->$key)) {
continue;
}
$template_vars['{customer_'.$key.'}'] = $customer->$key;
}

// Shop iso
$iso = Language::getIsoById((int)Configuration::get('PS_LANG_DEFAULT'));

Expand Down Expand Up @@ -785,6 +792,13 @@ public function hookActionOrderReturn($params)
'{message}' => Tools::purifyHTML($params['orderReturn']->question),
);

foreach(Customer::$definition['fields'] as $key => $value) {
if(!isset($customer->$key)) {
continue;
}
$template_vars['{customer_'.$key.'}'] = $customer->$key;
}

// Send 1 email by merchant mail, because Mail::Send doesn't work with an array of recipients
$merchant_mails = explode(self::__MA_MAIL_DELIMITOR__, $this->merchant_mails);
foreach ($merchant_mails as $merchant_mail)
Expand Down Expand Up @@ -856,6 +870,14 @@ public function hookActionOrderEdited($params)
'{order_name}' => $order->getUniqReference()
);

$customer = $order->getCustomer();
foreach(Customer::$definition['fields'] as $key => $value) {
if(!isset($customer->$key)) {
continue;
}
$data['{customer_'.$key.'}'] = $customer->$key;
}

Mail::Send(
(int)$order->id_lang,
'order_changed',
Expand Down