Kristian Toldy Posted December 13, 2021 Share Posted December 13, 2021 Hi, I'm new to PrestaShop and I'm not sure how to do this the best. We're trying to add 2 specific PDF files to the order confirmation email. We have a working code which adds these files and is working correctly by putting it in the classes/Mail.php file: if ($template == 'order_conf'){ $file = _PS_ROOT_DIR_ . '/terms.pdf'; $message->attach(Swift_Attachment::fromPath($file)); $file2 = _PS_ROOT_DIR_ . '/return_money.pdf'; $message->attach(Swift_Attachment::fromPath($file2)); } This is however a temporary solution as whenever Prestashop would get upgraded, this code would disappear as being part of a core. How else could this be done so it's protected from updating and the attachments are properly included in the send function. Thanks for any tips! Link to comment Share on other sites More sharing options...
endriu107 Posted December 13, 2021 Share Posted December 13, 2021 You can do this by override: https://devdocs.prestashop.com/1.7/modules/concepts/overrides/ Link to comment Share on other sites More sharing options...
Kristian Toldy Posted December 13, 2021 Author Share Posted December 13, 2021 22 minutes ago, endriu107 said: You can do this by override: https://devdocs.prestashop.com/1.7/modules/concepts/overrides/ Thanks, we did override it by copying the send function into an override class but this does not help with the updating problem as we copied the whole function. What if in the future there is an update to this function, because the overridden function will be always in use it won't be updated. Thanks Link to comment Share on other sites More sharing options...
endriu107 Posted December 13, 2021 Share Posted December 13, 2021 There is no easy way if you want to do this by changes in core file, the best solution is creating own module and send email from it. Link to comment Share on other sites More sharing options...
Knowband Plugins Posted December 14, 2021 Share Posted December 14, 2021 We suggest to use ActionEmailAddAfterContent hook to modify the email content. For reference: public function hookActionEmailAddAfterContent(&$params) { $content = ''; if ($params['template'] == 'order_conf') { // Let's edit content of Order's Confirmation email $params['template_html'] = str_replace("order", "order_new" . $content, $params['template_html']); } } 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