Отправка счета на оплату при оформлении заказа

В версии HostCMS 6.8.7 от 22.03.2019 г. появился новый модуль "Шаблоны документов", позволяющий формировать word документ с различными данными, например, счет на оплату.

В код нужной платежной системы (например, "Безналичная оплата от юридического лица") вставляется либо заменяется метод sendInvoice.

В коде указывается идентификатор шаблона документа из раздела Контент → Шаблоны документов и драйвер обработчика.

Copy
/*** Отправка клиенту письма со счетом.*/function sendInvoice() {	$sInvoice = $this->getInvoice();	$sInvoice = str_replace(">", ">\n", $sInvoice);	$subject = 'Банковский счет';	$oCore_Mail_Driver = Core_Mail::instance();	$oCore_Mail_Driver		->to($this->_shopOrder->email) 		->from($this->_shopOrder->Shop->getFirstEmail()) 		->subject($subject)		->message($sInvoice)		->contentType('text/html')		->header('X-HostCMS-Reason', 'OrderInvoice')		->header('Precedence', 'bulk');	$oPrintlayout = Core_Entity::factory('Printlayout', 10); // ID шаблона документа	$oPrintlayout_Controller = new Printlayout_Controller($oPrintlayout);	$oPrintlayout_Driver = Core_Entity::factory('Printlayout_Driver', 2); // ID драйвера обработчика шаблона документа	$oPrintlayout_Controller		->replace($this->_shopOrder->getPrintlayoutReplaces())		->driver($oPrintlayout_Driver)		->entity($this->_shopOrder)		->execute();	$oCore_Mail_Driver->attach(array(		'filepath' => $oPrintlayout_Controller->getFilePath(),		'filename' => $oPrintlayout_Controller->getFileName(),		'Content-ID' => str_pad($this->_shopOrder->id, 10, "0", STR_PAD_LEFT), // attachment or inline		'Content-Disposition' => 'attachment',		'Content-Type' => 'application/octet-stream' ));	$oCore_Mail_Driver->send();	$oPrintlayout_Controller->deleteFile();	return $this;}

16.02.2021