Jump to content

Recommended Posts

Hi

  I have been searching in vain on how to attach the invoice pdf to the email generated when the product is shipped.

I see a lot of suggestions on Prestashop1.4, but no working suggestions on how is it possible for 1.6

 

I would like the invoice to be sent every time the order status is set to "shipped" at the backoffice.

I understand that I can have the customer download the invoice pdf from the order history, (based on what I configure in the order status) but my requirement is to ATTACH the pdf to the mail that is generated.

 

Thanks

 

Uma

Link to comment
Share on other sites

First, your orders must go through the Payment accepted status. I think this is the only one status when the invoice is attached to the confirmation email. For me, it is still a little magic, but the default settings work well.

Link to comment
Share on other sites

Hi

 Thanks !

Yes I figured out this magic, or may be I am not understanding what you are suggesting..

 

1. Yes when the Order status moves to "Payment Accepted" from the BO, I see the invoice pdf is attached to the mail.

2. I would like to attach the invoice pdf to the mail, when the order status moves to "Shipped" also. I do see a lot of suggestions on this forum on changes to mail.php and some more classes, none of those seem to work..

 

 

 

BTW, I use Prestashop 1.6

 

regards

Uma

Link to comment
Share on other sites

  • 3 months later...

Hi umadevi.s,

 

Did you find a solution yet? I have the exact same problem; custom order status that needs a attached invoice when mailed to the customer. 

 

I also use PS 1.6. 

 

Regards,

 

Jeroen.

Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
  • 1 month later...
  • 1 year later...
  • 2 weeks later...
  • 6 months later...
  • 2 weeks later...

Hi everyone,

 

I've got an similar issue. When a new order is created, the customer gets the mail with the invoice attached (works well). But how can i manage to get me and another mail adress the same mail with the invoice & shippinglist? Just like a copy of the sent mail for the customer.

 

I know, I can download them in the BO, but my Boss (the other mail adress) wants to have all orders, with invoice and shippinglist directly in the Outlook to manage everything...

 

Does anyone have a idea? :)

 

Thanks a lot for you help, best regards

Peace

Lui

Link to comment
Share on other sites

You can simply override the class/Mail.php and use bcc as parameter. However this approach would send you mails from all kinds of stuff. Also customer welcome mail with their passwords (if password is part of the email template which is the case for prestashop default).

Link to comment
Share on other sites

If have acces to FTP, can do somethink like this.

(work fine for 1.6, i think 1.5, but idk 1.7)

 

It's not 100% clean, because I'm not sure if any of the call function bcc already used.

 

in shop_root/override/classes/ create if not exist: Mail.php

 

insert this code: (bcc is hidden copy so normal recipient don't see it in header)

class Mail extends MailCore
{

    /**
     * Send Email
     *
     * @param int $id_lang Language ID of the email (to translate the template)
     * @param string $template Template: the name of template not be a var but a string !
     * @param string $subject Subject of the email
     * @param string $template_vars Template variables for the email
     * @param string $to To email
     * @param string $to_name To name
     * @param string $from From email
     * @param string $from_name To email
     * @param array $file_attachment Array with three parameters (content, mime and name). You can use an array of array to attach multiple files
     * @param bool $mode_smtp SMTP mode (deprecated)
     * @param string $template_path Template path
     * @param bool $die Die after error
     * @param string $bcc Bcc recipient
     * @return bool|int Whether sending was successful. If not at all, false, otherwise amount of recipients succeeded.
     */
    public static function Send($id_lang, $template, $subject, $template_vars, $to,
                                $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
                                $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
    {
        if($template == 'new_order'){  //set the name of the template you want to send a copy 
            $second_email = '[email protected]'; //email for copy send
            $bcc = $second_email;
        }

        return parent::Send($id_lang, $template, $subject, $template_vars, $to,
            $to_name, $from, $from_name, $file_attachment, $mode_smtp,
            $template_path, $die, $id_shop, $bcc, $reply_to);
    }

}
Edited by misenec (see edit history)
Link to comment
Share on other sites

Hi guys,

 

Thanks for the fast reply. I tried it and it worked, but the customer doesn't get an email now. The bcc mail gets all the mails now. :)

Here is my code. Do i have to place the code at another place?

class Mail extends MailCore
{
    /*
    * module: gwadvancedinvoice
    * date: 2017-06-12 15:49:45
    * version: 1.2.0
    */
    public static function Send($id_lang, $template, $subject, $template_vars, $to,
        $to_name = null, $from = null, $from_name = null, $file_attachment = null, $mode_smtp = null,
        $template_path = _PS_MAIL_DIR_, $die = false, $id_shop = null, $bcc = null, $reply_to = null)
    {
        if(Module::isInstalled('gwadvancedinvoice') && Module::isEnabled('gwadvancedinvoice')){
            if (!empty($file_attachment)) {
                if ($template === 'order_conf' || $template === 'payment') {
                    if (isset($file_attachment['invoice']) && isset($file_attachment['invoice']['name'])) {
                        $invoiceObj = Module::getInstanceByName('gwadvancedinvoice');
                        $id_order_invoice = (int)Tools::substr($file_attachment['invoice']['name'], Tools::strlen($file_attachment['invoice']['name'])-10,6);
                        if($id_order_invoice > 0){
                            $OrderInvoiceObj =  new OrderInvoice((int)$id_order_invoice);
                            if(Validate::isLoadedObject($OrderInvoiceObj)){
                                $file_attachment['invoice']['name'] = $invoiceObj->formatNumber('I',$OrderInvoiceObj->number,$OrderInvoiceObj). '.pdf';
                                if (isset($file_attachment['delivery']) && isset($file_attachment['delivery']['name'])) {
                                    $file_attachment['delivery']['name'] = $invoiceObj->formatNumber('D',$OrderInvoiceObj->delivery_number,$OrderInvoiceObj). '.pdf';
                                }
                            }
                        }
                    }
                    
                }
            }
			
        }
		if($template == 'order_conf'){ 
			$bcc = "[email protected]";
		}
		
        return  parent::Send($id_lang, $template, $subject, $template_vars, $to,
        $to_name, $from, $from_name, $file_attachment, $mode_smtp,
        $template_path, $die, $id_shop, $bcc, $reply_to);
    }
}

Sorry, I just received the message (I am the customer) but 10 minutes later. Was it maybee just an server connection issue?

So the code works thanks again guys. But it takes around 10 minutes until the customer gets the mail...(tried it again)

Any ideas?

 

 

Thanks and best regards

Lui

Edited by poletti.lucio (see edit history)
Link to comment
Share on other sites

Nothing that I would be aware of. If you consider this as problem you could start debugging Mail.php. For example log to the datatbase at the beginning with a timestamp and log at the end of the send:: function again to compare if the dalay occures there. But my guess is rather than the dalay ise caused outside of prestashop. So it would be more related to a hosting issue.

Link to comment
Share on other sites

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...