Editing Order E-Mail

I know that you go to app/design/backend/mail/templates to edit the E-mail that is sent out, however I am having a problem figuring out how to attach a CSV to that. I want to have it so that when a customer orders, the "options" are attached in a CSV file. I tried inserting the following code

<?php
/*
 * Smarty Plugin
 *--------------------------------------------------------------
 *File: CSVoutput.php
 *Type: function
 *Name: CSV
 *Purpose: To Output a CSV File on Order
 *--------------------------------------------------------------
 */
function smarty_insert_CSV($params, &$Smarty)
{
header("Content-Type: text/csv");
header("Content-Disposition: attachment; filename=file.csv");
// Disable caching
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1
header("Pragma: no-cache"); // HTTP 1.0
header("Expires: 0"); // Proxies

$emailed = outputCSV($this->get_template_vars(‘$oi.product_options’);

$fp = fopen()
int fputcsv ($fp)
$fileat_type = “text/csv”;
$myfile = “myfile.csv”;

$to = “jarrod@hltlasers.com”;
$subject = ‘Order’;
$headers = ‘MIME-Version: 1.0’. “\r\n”;
$headers .= ‘Content-type :text/html; charset = iso-8859-1’ . “\r\n”;
mail($to, $subject, $emailed, $header);}
}
function outputCSV($data) {
$output = fopen(“php://output”, “w”);
foreach ($data as $row) {
fputcsv($output, $row); // here you can change delimiter/enclosure
}
fclose($output);
}

?>

and then doing an include script on the invoice.tpl but that did not work. Any ideas?

You can download our free PDF invoice module to check how to attach files to e-mails

You can download our free PDF invoice module to check how to attach files to e-mails

Thank you for the reply and the Addon, but dumb question. After I installed it how do I use it?

You can enable attachment on each Order status settings page. If this feature is enabled for the current order status, PDF invoice will be attached to each order notification

Is there a way to attach a PAID INVOICE the shows $0 since it has been paid and there is $0 due?

Is there a way to attach a PAID INVOICE the shows $0 since it has been paid and there is $0 due?

Unfortunately your request is not clear enough to us. Could you please clarify what you mean?

Thank you.