muksu Posted July 30, 2024 Share Posted July 30, 2024 Add PDF file in ORDER CONFIRMATION EMAIL in PS 8.1X Hello I need to ADD my TERMS AND CONDITIONS in PDF file to the EMAIL of ORDER CONFIRMATION. I had done that on PRESTASHOP 1.7X by adding this below snipet to the Mail.php file (in classes/mail.php) : if ($template == 'order_conf'){ $message->attach(\Swift_Attachment::newInstance(file_get_contents('CGV.pdf'), 'CGV.pdf', 'application/pdf')); } BEFORE THAT if (!empty($fileAttachment)) { // Multiple attachments? if (!is_array(current($fileAttachment))) { ..... But it is not working for PRESTASHOP V8.1X with PHP 8.2 Can you give me the correct snipet to use in PRESTASHOP 8.1X ? Waiting for your help Best regards Link to comment Share on other sites More sharing options...
Andrei H Posted August 1, 2024 Share Posted August 1, 2024 (edited) Hello, The below code should do the trick for you: if ($template === 'order_conf') { $message->attach( (new Swift_Attachment())->setFilename('CGV.pdf') ->setContentType('application/pdf') ->setBody(file_get_contents(__DIR__ . '/CGV.pdf')) ); } The attached screenshot highlights where the code should be placed. Let me know if it works for you. PS: This will pick up the CGV.pdf file from the current directory (classes) Edited August 1, 2024 by Andrei H (see edit history) 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