Jump to content

Recommended Posts

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

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
				);
  • Like 1
Link to comment
Share on other sites

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

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

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

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

  • 1 year later...
  • 3 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...