Fille au pluriel Posted September 27, 2015 Share Posted September 27, 2015 Bonjour à tous ! Je cherche à customiser le module natif BO de prestashop, Mail alert (pour l'envoi de mail au commerçant) En effet, lorsqu'un client valide une commande, je souhaiterai ajouter en pièce jointe la facture et le bon de livraison de la commande, dans le mail que reçoit le commerçant. Je me suis intéressé à la fonction Mail() mais ca ne marche pas (je dois mal m'y prendre aussi...) Quelqu'un a t il une idée d'où cela peut venir ? Merci de vos réponses ! Link to comment Share on other sites More sharing options...
Eolia Posted September 28, 2015 Share Posted September 28, 2015 Pour l'envoi de la facture, modifier mailalert.php comme ceci (vers la ligne 433) $order_status = new OrderState((int)$invoice->id_state, (int)$this->context->language->id); if ((int)Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) { $order_invoice_list = $order->getInvoicesCollection(); Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list)); $pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } else { $file_attachement = null; } $dir_mail = false; if (file_exists(dirname(__FILE__).'/mails/'.$mail_iso.'/new_order.txt') && file_exists(dirname(__FILE__).'/mails/'.$mail_iso.'/new_order.html')) $dir_mail = dirname(__FILE__).'/mails/'; if (file_exists(_PS_MAIL_DIR_.$mail_iso.'/new_order.txt') && file_exists(_PS_MAIL_DIR_.$mail_iso.'/new_order.html')) $dir_mail = _PS_MAIL_DIR_; if ($dir_mail) Mail::Send( $mail_id_lang, 'new_order', sprintf(Mail::l('New order : #%d - %s', $mail_id_lang), $order->id, $order->reference), $template_vars, $merchant_mail, null, $configuration['PS_SHOP_EMAIL'], $configuration['PS_SHOP_NAME'], $file_attachement, null, $dir_mail, null, $id_shop ); 1 Link to comment Share on other sites More sharing options...
Fille au pluriel Posted September 28, 2015 Author Share Posted September 28, 2015 Merci beaucoup Eolia, Je vais tester ce soir !! Link to comment Share on other sites More sharing options...
[email protected] Posted September 28, 2015 Share Posted September 28, 2015 salve ragazzi, dopo l'aggiornamento di prestashop 1.6 non ricevo più le e-mail degli ordini e non invia nemmeno le e-mail al cliente, ho provato a disistallare e reistallare il modulo mail allert ma niente; chiedo di inviare l'email di prova mi dice che è stata inviata ma non arriva.sto impazzendo c'è qualcuno che sa aiutarmi? Link to comment Share on other sites More sharing options...
coeos.pro Posted September 29, 2015 Share Posted September 29, 2015 salve ragazzi, dopo l'aggiornamento di prestashop 1.6 non ricevo più le e-mail degli ordini e non invia nemmeno le e-mail al cliente, ho provato a disistallare e reistallare il modulo mail allert ma niente; chiedo di inviare l'email di prova mi dice che è stata inviata ma non arriva.sto impazzendo c'è qualcuno che sa aiutarmi? you should create a new post, giving all the details (versions of PrestaShop, update ...) and French in the French forum, or else in another language but in the same language forum Link to comment Share on other sites More sharing options...
Fille au pluriel Posted September 30, 2015 Author Share Posted September 30, 2015 Bonjour à tous, J'ai fait la modif sur le fichier mailalert.php mais j'ai pas de facture en PJ et j'arrive au même problème qu'avec ma config... Vous avez une idée d'où cela peut venir ?? Merci encore à vous ! Pour l'envoi de la facture, modifier mailalert.php comme ceci (vers la ligne 433) $order_status = new OrderState((int)$invoice->id_state, (int)$this->context->language->id); if ((int)Configuration::get('PS_INVOICE') && $order_status->invoice && $order->invoice_number) { $order_invoice_list = $order->getInvoicesCollection(); Hook::exec('actionPDFInvoiceRender', array('order_invoice_list' => $order_invoice_list)); $pdf = new PDF($order_invoice_list, PDF::TEMPLATE_INVOICE, $this->context->smarty); $file_attachement['content'] = $pdf->render(false); $file_attachement['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } else { $file_attachement = null; } $dir_mail = false; if (file_exists(dirname(__FILE__).'/mails/'.$mail_iso.'/new_order.txt') && file_exists(dirname(__FILE__).'/mails/'.$mail_iso.'/new_order.html')) $dir_mail = dirname(__FILE__).'/mails/'; if (file_exists(_PS_MAIL_DIR_.$mail_iso.'/new_order.txt') && file_exists(_PS_MAIL_DIR_.$mail_iso.'/new_order.html')) $dir_mail = _PS_MAIL_DIR_; if ($dir_mail) Mail::Send( $mail_id_lang, 'new_order', sprintf(Mail::l('New order : #%d - %s', $mail_id_lang), $order->id, $order->reference), $template_vars, $merchant_mail, null, $configuration['PS_SHOP_EMAIL'], $configuration['PS_SHOP_NAME'], $file_attachement, null, $dir_mail, null, $id_shop ); Link to comment Share on other sites More sharing options...
Eolia Posted September 30, 2015 Share Posted September 30, 2015 Ouep, logique, le module est hooké avant que l'id_state ne soit défini... Donc, rajoutez, juste avant le bloc que je vous ai fait remplacer, ceci: if(!$invoice->id_state) $invoice->id_state = (int)Configuration::get('PS_OS_PAYMENT'); Ce qui force un état "payé" juste pour générer la facture. Le mode de paiement sera vide sur celle-ci mais ce n'est peut-être pas trop grave dans votre cas ? Link to comment Share on other sites More sharing options...
Fille au pluriel Posted September 30, 2015 Author Share Posted September 30, 2015 Rien à faire, la PJ ne se rajoute pas au mail... Ouep, logique, le module est hooké avant que l'id_state ne soit défini... Donc, rajoutez, juste avant le bloc que je vous ai fait remplacer, ceci: if(!$invoice->id_state) $invoice->id_state = (int)Configuration::get('PS_OS_PAYMENT'); Ce qui force un état "payé" juste pour générer la facture. Le mode de paiement sera vide sur celle-ci mais ce n'est peut-être pas trop grave dans votre cas ? Link to comment Share on other sites More sharing options...
Eolia Posted September 30, 2015 Share Posted September 30, 2015 hum... chez moi ça marche Quelle version PS ? Un accès à votre BO serait-il possible ? (par MP) Link to comment Share on other sites More sharing options...
Fille au pluriel Posted September 30, 2015 Author Share Posted September 30, 2015 J'ai la version 1.6.1.1 Je vous ai envoyé un MP Encore merci ! Link to comment Share on other sites More sharing options...
DRIKORE Posted October 27, 2016 Share Posted October 27, 2016 Bonjour, Pareil pour moi, aucune pièce jointe, pourtant j'ai bien appliqué les modifications. Link to comment Share on other sites More sharing options...
rachel01 Posted March 30, 2020 Share Posted March 30, 2020 Bonjour Ce code est-il toujours valable pour Prestashop 1.7 ? Merci Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now