Adding Product Names To File Download Notification Email

Posts: 6
Joined: 03/21/2008

Is it possible to precede the download links with the corresponding product name in the file download notification email that are generated from Ubercart? This would allow customers to know which product they are about to download instead of just seeing a list of arbitrary links.

I cannot find a way to do this - any suggestions?

Posts: 1290
Joined: 08/14/2007
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.

Easy.

You can override the theme_uc_file_downloads_token function, which is found in uc_file.module.

So in your template.php file do something like this. (This is mine from our live site):

<?php
/**
* Theme file download links token
*/
function phptemplate_uc_file_downloads_token($file_downloads) {
 
$output = '';
  foreach (
$file_downloads as $file_download) {
   
$filename = basename(db_result(db_query("SELECT filename FROM {uc_files} WHERE fid = %d",$file_download->fid)));
   
$download_url = url('download/'.$file_download->fid.'/'.$file_download->key,NULL,NULL,TRUE);
   
$description = t(db_result(db_query("SELECT description FROM uc_file_products WHERE pfid = %d AND fid = %d", $file_download->pfid, $file_download->fid)));
   
$output .= '<a href="'.$download_url.'">'. $filename .'</a> - '.$description."<br />";
  }
  return
$output;
}
?>

That will make the link itself the filename (and include the description which is also helpful). Please reference my original Issue for more info.

--

"Pain don't hurt." - Dalton

Mike Nelson's RiffTrax! www.rifftrax.com

Posts: 51
Joined: 10/20/2007

Thanks! I was just wondering how to do this same thing.

Posts: 6
Joined: 03/21/2008

Thanks Mike - that's perfect and such a quick response. The only thing I noticed is the last line of code
?>
causes the white screen of "Drupal" death !!! - once removed it was exactly what I wanted.

Much appreciated.

Darren

Posts: 924
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

The <?php and ?> tags that you find in any of these forum posts are needed to make PHP code in the post highlight and format properly. The tags are not meant to be part of the code snippet.

--

<tr>.