Fixed:Super admin profile id is used instead of Superadmin employees ids while sending Order-Confirmation and Refund emails

This commit is contained in:
Sumit Panwar
2024-03-07 14:46:05 +05:30
parent ce93a9826f
commit 42bb3f52b8
2 changed files with 47 additions and 43 deletions

View File

@@ -1237,25 +1237,27 @@ abstract class PaymentModuleCore extends Module
}
if (Configuration::get('PS_ORDER_CONF_MAIL_TO_SUPERADMIN')){
// send superadmin information
if (Validate::isLoadedObject($superAdmin = new Employee(_PS_ADMIN_PROFILE_))) {
if (Validate::isEmail($superAdmin->email)) {
$data['{customer_name}'] = $this->context->customer->firstname.' '.$this->context->customer->lastname;
$data['{customer_email}'] = $this->context->customer->email;
$data['{firstname}'] = $superAdmin->firstname;
$data['{lastname}'] = $superAdmin->lastname;
$data['{email}'] = $superAdmin->email;
Mail::Send(
(int)$order->id_lang,
'order_conf_admin',
Mail::l('Order confirmation', (int)$order->id_lang),
$data,
$superAdmin->email,
$superAdmin->firstname.' '.$superAdmin->lastname,
null,
null,
$file_attachement,
null, _PS_MAIL_DIR_, false, (int)$order->id_shop
);
if ($superAdminEmployees = Employee::getEmployeesByProfile(_PS_ADMIN_PROFILE_, true)) {
foreach ($superAdminEmployees as $superAdminEmployee) {
if (Validate::isEmail($superAdminEmployee['email'])) {
$data['{customer_name}'] = $this->context->customer->firstname.' '.$this->context->customer->lastname;
$data['{customer_email}'] = $this->context->customer->email;
$data['{firstname}'] = $superAdminEmployee['firstname'];
$data['{lastname}'] = $superAdminEmployee['lastname'];
$data['{email}'] = $superAdminEmployee['email'];
Mail::Send(
(int)$order->id_lang,
'order_conf_admin',
Mail::l('Order confirmation', (int)$order->id_lang),
$data,
$superAdminEmployee['email'],
$superAdminEmployee['firstname'].' '.$superAdminEmployee['lastname'],
null,
null,
$file_attachement,
null, _PS_MAIL_DIR_, false, (int)$order->id_shop
);
}
}
}
}
@@ -1289,7 +1291,7 @@ abstract class PaymentModuleCore extends Module
$data['{customer_name}'] = $this->context->customer->firstname.' '.$this->context->customer->lastname;
$data['{customer_email}'] = $this->context->customer->email;
foreach ($htlAccesses as $access) {
if ($access['id_profile'] != _PS_ADMIN_PROFILE_) {
if ($access['access'] && $access['id_profile'] != _PS_ADMIN_PROFILE_) {
if ($htlEmployees = Employee::getEmployeesByProfile($access['id_profile'])) {
foreach ($htlEmployees as $empl) {
if (Validate::isEmail($empl['email'])) {