Всем привет. У меня на сайте при покупке генерируются ключи для программ. Нанимал фрилансера и он мне сделал, чтобы в письмо, отправляемое покупателю, вкладывался xml-файл. У меня была версия ЖШ 4.6. Недавно пришлось делать обновление до версии ЖШ 4.16 и естественно файл к письму перестал прикладываться.
Я проштудировал файлы старой версии и нашел это решение в файле /com_jshopping/models/checkout.php. В методе sendOrderEmail было добавлено следующее:
//send mail client
if ($order->email){
$mailer = JFactory::getMailer();
$mailer->setSender(array($mailfrom, $fromname));
$mailer->addRecipient($order->email);
$mailer->setSubject( sprintf(_JSHOP_NEW_ORDER, $order->order_number, $order->f_name." ".$order->l_name));
$mailer->setBody($message_client);
$user = JFactory::getUser();
$file = tempnam(sys_get_temp_dir(), '');
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
$root = $doc->createElement('ActiveKeys');
$root->setAttribute('UserLogin', $user->username);
$root->setAttribute('check', 'mpak');
foreach ($order->products as $prod) {
$el = $doc->createElement('key');
$el->setAttribute('Name', $prod->attributes_values[2]);
$el->setAttribute('AvailCad', $prod->attributes_values[1]);
$el->setAttribute('ActiveKey', $prod->product_hash);
$root->appendChild($el);
}
$doc->appendChild($root);
$xmlData = $doc->saveXML();
file_put_contents($file, $xmlData);
if ($order->order_status == 6) {
error_reporting(E_ALL);
$mailer->addAttachment($file, "{$user->username}_ModPlus ActiveKeys.xml");
}
if ($pdfsend && $jshopConfig->order_send_pdf_client){
$mailer->addAttachment($jshopConfig->pdf_orders_path."/".$order->pdf_file);
}
$mailer->isHTML(true);
$send = $mailer->Send();
}
После обновления ЖШ многое было "разнесено" по методам и разным файлам. Полазив по ним я нашел вроде то, что нужно в файле /com_jshopping/models/ordermail.php и перенес туда добавление файла:
public function sendMail($type, $recipient, $message, $vendor = null){
$app = JFactory::getApplication();
$jshopConfig = JSFactory::getConfig();
$dispatcher = JDispatcher::getInstance();
$mailfrom = $app->getCfg('mailfrom');
$fromname = $app->getCfg('fromname');
$pdfsend = $this->getPdfSend();
$manuallysend = $this->getManuallysend();
$subject = $this->getSubjectMail($type, $this->order);
$pdfsendtype = $this->getPdfSendType($type);
$mailer = JFactory::getMailer();
$mailer->setSender(array($mailfrom, $fromname));
$mailer->addRecipient($recipient);
$mailer->setSubject($subject);
$mailer->setBody($message);
/* for attach file*/
$user = JFactory::getUser();
$file = tempnam(sys_get_temp_dir(), '');
$doc = new DOMDocument('1.0', 'utf-8');
$doc->formatOutput = true;
$root = $doc->createElement('ActiveKeys');
$root->setAttribute('UserLogin', $user->username);
foreach ($order->products as $prod) {
$el = $doc->createElement('key');
$el->setAttribute('Name', $prod->attributes_values[2]);
$el->setAttribute('AvailProductExternalVersion', $prod->attributes_values[1]);
$el->setAttribute('ActiveKey', $prod->product_hash);
$root->appendChild($el);
}
$doc->appendChild($root);
$xmlData = $doc->saveXML();
file_put_contents($file, $xmlData);
if ($order->order_status == 6) {
error_reporting(E_ALL);
$mailer->addAttachment($file, "{$user->username}_ModPlus ActiveKeys.xml");
}
/*end of attach file*/
if ($pdfsendtype){
$mailer->addAttachment($jshopConfig->pdf_orders_path."/".$this->order->pdf_file);
}
$mailer->isHTML(true);
$dispatcher->trigger($this->getSendMailTriggerType($type),
array(&$mailer, &$this->order, &$manuallysend, &$pdfsend, &$vendor, &$this->vendors_send_message, &$this->vendor_send_order));
return $mailer->Send();
}
Думаю, понятно к чему я клоню - ничего не работает )) На мой взгляд все верно сделано, но могу ошибаться. Может кто заметит в чем проблема?