I think I found the solution for the first part, add order reference to of emails sent to customers to inform them that was changed their order status. I created an override for /classes/order/OrderHistory.php and I put it in /override/classes/order/OrderHistory.php. This is the code:
<?php /* modified class in order to add Order Reference of order to subject of emails sent when order status has changed */ class OrderHistory extends OrderHistoryCore { 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']; $carrierUrl = ''; if (Validate::isLoadedObject($carrier = new Carrier((int) $order->id_carrier, $order->id_lang))) { $carrierUrl = $carrier->url; } $data = [ '{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int) $this->id_order, '{order_name}' => $order->getUniqReference(), '{followup}' => str_replace('@', $order->getWsShippingNumber(), $carrierUrl), '{shipping_number}' => $order->getWsShippingNumber(), ]; 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 (is_array($template_vars)) { $data = array_merge($data, $template_vars); } $context = Context::getContext(); $data['{total_paid}'] = Tools::getContextLocale($context)->formatPrice((float) $order->total_paid, Currency::getIsoCodeById((int) $order->id_currency)); 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'])) { $currentLanguage = $context->language; $orderLanguage = new Language((int) $order->id_lang); $context->language = $orderLanguage; $context->getTranslator()->setLocale($orderLanguage->locale); $invoice = $order->getInvoicesCollection(); $file_attachement = []; if ($result['pdf_invoice'] && (int) Configuration::get('PS_INVOICE') && $order->invoice_number) { Hook::exec('actionPDFInvoiceRender', ['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', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->delivery_number) . '.pdf'; $file_attachement['delivery']['mime'] = 'application/pdf'; } $context->language = $currentLanguage; $context->getTranslator()->setLocale($currentLanguage->locale); } else { $file_attachement = null; } if (!Mail::Send( (int) $order->id_lang, $result['template'], $topic.' # '.$order->getUniqReference(), $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; } }
After this, I deleted the file "/var/cahace/prod/class_index.php" in order to be re-created and to be taken into account your new overwritten class.
I found a solution for the confirmation order too. I created a copy of /classes/PaymentModule.php and changed class header into:
abstract class PaymentModule extends PaymentModuleCore
I replaced:
Mail::Send( (int) $order->id_lang, 'order_conf', $this->context->getTranslator()->trans( 'Order confirmation', [], 'Emails.Subject', $orderLanguage->locale ), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop );
with:
Mail::Send( (int) $order->id_lang, 'order_conf', $this->context->getTranslator()->trans( ''Order confirmation # %s', [ $order->reference, ], 'Emails.Subject', $orderLanguage->locale ), $data, $this->context->customer->email, $this->context->customer->firstname . ' ' . $this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int) $order->id_shop );
Then I put it in /override/classes/PaymentModule.php I deleted the file "/var/cahace/prod/class_index.php" in order to be re-created and to be taken into account your new overwritten class.