connectcase Posted January 16, 2014 Share Posted January 16, 2014 Hi there, I'd like to know if the following is possible: I created a custom orderstatus and the email that goes with. That part all works fine. But what I would really like is to add the invoice (PDF) to the email as an attachment. Is that possible and if so, how? Been look through modules for ages, but no luck finding a suitable one yet. Cheers, Cees Link to comment Share on other sites More sharing options...
connectcase Posted January 20, 2014 Author Share Posted January 20, 2014 No one?? Link to comment Share on other sites More sharing options...
Strky Posted February 26, 2015 Share Posted February 26, 2015 Hi, I found some solutions... In /classes/order/OrderHistory.php Around line 410, is a function that sends mail with pdf only on "payment accepted" if ((int)$result['id_order_state'] === 2 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) { $context = Context::getContext(); $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $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->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } It takes order status by ID. So, under this, add code. elseif ((int)$result['id_order_state'] === 23 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) { $context = Context::getContext(); $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $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->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } And in "elseif ((int)$result['id_order_state'] === 23" -> instead of 23 add your status one ID. So it will look like: (red is old code and green is new) // Join PDF invoice if order state is "payment accepted" if ((int)$result['id_order_state'] === 2 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) { $context = Context::getContext(); $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $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->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } elseif ((int)$result['id_order_state'] === 23 && (int)Configuration::get('PS_INVOICE') && $order->invoice_number) { $context = Context::getContext(); $pdf = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $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->id).'.pdf'; $file_attachement['mime'] = 'application/pdf'; } else $file_attachement = null; Link to comment Share on other sites More sharing options...
JordanESSystems Posted April 16, 2015 Share Posted April 16, 2015 Hi Strky,Did that work for you? I'm trying to achieve the same result as connectcase, but upon placing the order with those changes implemented, my screen goes blank? Link to comment Share on other sites More sharing options...
Strky Posted July 27, 2015 Share Posted July 27, 2015 Hi,maybe you forgot for any tag or something. Try to turn on debug mod and maybe you see error.. 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