Jump to content

Attach terms and conditions to order confirmation mail


Recommended Posts

Hello,

 

in the Czech Republic we have to send terms and conditions to customers in confirmation e-mail.

 

I have found these lines in classes/PaymentModule.php:340

// Join PDF invoice
if (intval(Configuration::get('PS_INVOICE')) AND Validate::isLoadedObject($orderStatus) AND $orderStatus->invoice AND $order->invoice_number)
{
	$fileAttachment['content'] = PDF::invoice($order, 'S');
	$fileAttachment['name'] = Configuration::get('PS_INVOICE_PREFIX', intval($order->id_lang)).sprintf('%06d', $order->invoice_number).'.pdf';
	$fileAttachment['mime'] = 'application/pdf';
}

and I have file terms_and_conditions.pdf. How can I attach it? Can you please help me?

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

  • 1 month later...

I asked my friend who has kinda big shop (20 orders a day) and he's not sending it and nobody cares. So I haven't implemented this. Maybe it would be easier in new versions of presta, I'm not sure. Will check it and let you know.

Link to comment
Share on other sites

  • 6 months later...

Although it is a pretty old topic, I'll still post a possible solution, because this threat appears high in google search, and it is quite frustrating to find something like this unanswered. 

 

The Send method of Mail class can accept as argument an "array of array" (see the Send method comment). So you can replace the code above with something like:

$file_attachement[0]['content'] = $pdf->render(false);
$file_attachement[0]['name'] = Configuration::get('PS_INVOICE_PREFIX', (int)$order->id_lang, null, $order->id_shop).sprintf('%06d', $order->invoice_number).'.pdf';
$file_attachement[0]['mime'] = 'application/pdf';

// Your terms of service pdf                    
$file_attachement[1]['content'] = file_get_contents(_PS_ROOT_DIR_.'/folder/terms_and_conditions.pdf');
$file_attachement[1]['name'] = 'terms-and-conditions.pdf';
$file_attachement[1]['mime'] = 'application/pdf';

Where file_get_contents requires the path to your pdf.

And just don't forget to do this as overload class, instead of modifying the original one :)

Link to comment
Share on other sites

  • 2 months later...
  • 7 months later...
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...