faqts : Computers : Software : FreeTrade : Customization

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

30 of 87 people (34%) answered Yes

Entry

How can I customize the emails sent to users by Item or SKU?

Feb 11th, 2001 14:53
Mike Potter,


//get a list of all the SKU's in the basket
			$Query = "SELECT SKU, Item from invoice_sku, 
sku WHERE Invoice = ".$UserInfo['Invoice']." AND sku.ID = SKU";
			$DatabaseResult = mysql_query($Query, 
$DatabaseLink);
			while ($Row = mysql_fetch_array
($DatabaseResult))
			{
				$SKU = $Row["SKU"];
				$Item = $Row["Item"];
				if (file_exists
(APPLICATION_ROOT."/modules/email/sku/".$SKU))
				{
					$fp = fopen
(APPLICATION_ROOT."/modules/email/sku/".$SKU, "r");
					$FileContents = fread($fp, 
filesize(APPLICATION_ROOT."/modules/email/sku/".$SKU));
					$mail_body .= "\n---------------
---------------------------------------\n";
					$mail_body .= $FileContents;
					$mail_body .= "\n---------------
---------------------------------------\n";
				} 
				else if (file_exists
(APPLICATION_ROOT."/modules/email/items/".$Item))
				{
					$fp = fopen
(APPLICATION_ROOT."/modules/email/items/".$Item, "r");
					$FileContents = fread($fp, 
filesize(APPLICATION_ROOT."/modules/email/items/".$Item));
					$mail_body .= "\n---------------
---------------------------------------\n";
					$mail_body .= $FileContents;
					$mail_body .= "\n---------------
---------------------------------------\n";
				}
			}
This goes through all the SKU’s in the basket, and then adds items to 
the email being sent to the user.

I made two extra directories under modules.  First, I made a directory 
called email, and under that two subdirectories named sku and items  If 
you want to send an email based on a SKU, just add a file with the name 
being the SKU id to match.  (ie for an email regarding SKU 12, add a 
file called “12” under email/sku  You can do the same thing for items, 
but put the  email under items