Jump to content

Edit History

redrum

redrum

Thanks for the input @Pandal.

I did some digging, searching and merging and this seems fine to attach both invoice and delivery slip in a mail;

 

            $context = Context::getContext();

            $pdf_inv = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
            $attachment_invoice['content'] = $pdf_inv->render(false);
            $attachment_invoice['name']    = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';
            $attachment_invoice['mime']    = 'application/pdf';            
            
            $pdf_del = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_DELIVERY_SLIP, $context->smarty);
            $attachement_delivery['content'] = $pdf_del->render(false);
            $attachement_delivery['name']    = Configuration::get('PS_DELIVERY_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->delivery_number).'.pdf';
            $attachement_delivery['mime']    = 'application/pdf';

            $attachement_inv_del             = array($attachment_invoice, $attachement_delivery);
            

            $templateVars = array(
                '{firstname}' => $customer->firstname,
                '{lastname}' => $customer->lastname,
                '{id_order}' => $order->id,
                '{order_name}' => $order->getUniqReference(),
                '{invoice_number}' => Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number),
                '{delivery_number}' => Configuration::get('PS_DELIVERY_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->delivery_number),
            );              


if (Tools::isSubmit('submitSendInvoice')) {                        
            Mail::Send(
                (int)$order->id_lang, 
                'order_conf', 
                Mail::l('Invoice for your order', 
                (int)$order->id_lang), 
                $templateVars,
                $customer->email, 
                $customer->firstname.' '.$customer->lastname, 
                null, 
                null, 
                $attachement_inv_del, 
                null,
                _PS_MAIL_DIR_, 
                true, 
                (int)$order->id_shop
                );
}

 

redrum

redrum

Thanks for the input @Pandal.

I did some digging, searching and merging and this seems fine to attach both invoice and delivery slip in a mail;

 

            $context = Context::getContext();

            $pdf_inv = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_INVOICE, $context->smarty);
            $attachment_invoice['content'] = $pdf_inv->render(false);
            $attachment_invoice['name']    = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';
            $attachment_invoice['mime']    = 'application/pdf';            
            
            $pdf_del = new PDF($order->getInvoicesCollection(), PDF::TEMPLATE_DELIVERY_SLIP, $context->smarty);
            $attachement_delivery['content'] = $pdf_del->render(false);
            $attachement_delivery['name']    = Configuration::get('PS_DELIVERY_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->delivery_number).'.pdf';
            $attachement_delivery['mime']    = 'application/pdf';

            $attachement_inv_del             = array($attachment_invoice, $attachement_delivery);
            

            $templateVars = array(
                '{firstname}' => $customer->firstname,
                '{lastname}' => $customer->lastname,
                '{id_order}' => $order->id,
                '{order_name}' => $order->getUniqReference(),
                '{invoice_number}' => Configuration::get('PS_INVOICE_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->invoice_number),
                '{delivery_number}' => Configuration::get('PS_DELIVERY_PREFIX', (int) $order->id_lang, null, $order->id_shop) . sprintf('%06d', $order->delivery_number),
            );              


if (Tools::isSubmit('submitSendInvoice')) {                        
            Mail::Send(
                (int)$order->id_lang, 
                'order_conf', 
                Mail::l('Invoice for your order', 
                (int)$order->id_lang), 
                $templateVars,
                $customer->email, 
                $customer->firstname.' '.$customer->lastname, 
                null, 
                null, 
                $attachement_inv_del, 
                null,
                _PS_MAIL_DIR_, 
                true, 
                (int)$order->id_shop
                );

 

×
×
  • Create New...