Jump to content

Email attachment based on product reference


SanderT

Recommended Posts

I'm trying to add a code snippet to the mailer class (classes/mail.php), but somehow can't get the code to work. The basic idea is to add (extra) attachments to the order confirmation e-mail, based on the products ordered.

 


if (strpos($template, "account")){
foreach ($cart->getProducts() as $value) {
if($value['reference'] == "T45L1202"){ $message->attach(new Swift_Message_Attachment(file_get_contents("http://domain.com/file.pdf"), "Filename.pdf", "application/pdf")); }
if($value['reference'] == "T45P1202"){ $message->attach(new Swift_Message_Attachment(file_get_contents("http://domain.com/file.pdf"), "Filename.pdf", "application/pdf")); }
if($value['reference'] == "T45W1202"){ $message->attach(new Swift_Message_Attachment(file_get_contents("http://domain.com/file.pdf"), "Filename.pdf", "application/pdf")); }
}
}

 

Update:

It looks like you can't fetch current cart information with the code: $cart->getProducts(); Altough not within the mail.php class. The question remains, how is it possible to fetch the current cart info/content and send based on the product reference, different e-mail attachments with the order confirmation e-mail.

Edited by SanderT (see edit history)
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...