Okay, here's the goods... I didn't know if I should chew up bandwidth unless people actually wanted to see it, but it looks like there's some interest...
First add a table into your shop DB, with the following SQL (this is made easy if you have phpMyAdmin.
Code:
CREATE TABLE `tellafriend` (
`tafid` int(10) unsigned NOT NULL auto_increment,
`link` varchar(255) NOT NULL default '',
`send_name` varchar(255) NOT NULL default '',
`send_email` varchar(255) NOT NULL default '',
`rec_name` varchar(255) NOT NULL default '',
`rec_email` varchar(255) NOT NULL default '',
`subject` varchar(255) NOT NULL default '',
`body` text,
`timestamp` int(10) NOT NULL default '0',
KEY `tafid` (`tafid`)
) TYPE=MyISAM AUTO_INCREMENT=161 ;
Copy this code into a file called connect.php and put it in the xcart/include directory. Be sure to replace all variables properly for the DB name, username and password:
Code:
<?php
#
# SQL database details
#
$sql_host ='localhost';
$sql_user ='user';
$sql_db ='db';
$sql_password ='pw';
db_connect($sql_host, $sql_user, $sql_password);
db_select_db($sql_db);
?>
Next, add a directory under your root called /tellafriend. In this directory include the following index.php file. Be sure to replace all instances of my site-specific stuff with yours (URLs, image locations, etc.)
Code:
<?php
include ("../shop/include/func.php");
include ("../shop/include/connect.php");
?>
<head>
<title> Tell a Friend about Fine Art Photo Gifts</title>
<style>
td {font-family: Verdana; font-size: 12px; padding-left: 5px; padding-right: 5px; padding-top: 2px; padding-bottom: 3px;}
</style>
</head>
<body>
<?php
if($submit) {
# make sure all fields have data
if($_SERVER['HTTP_HOST']=="www.fineartphotogifts.com") {
if($rec_name!=""&&$rec_email!=""&&$send_name!=""&&$send_email!=""&&$subject!="") {
# send email
$message="Hello " . ucfirst("$rec_name") . "! \n\nYour friend $send_name at $send_email asked us to send you a brief note. \nPlease visit this page on fineartphotogifts.com at \n\n $link\n\n for more details.\n\n";
if($body!="") {
$message.= ucfirst("$send_name") . " sends the following note to you:\n\n" .stripslashes($body)."\n\n\n";
$body="'$body'";
} else {
$body="NULL";
}
$message.="Hope to see you soon at Fine Art Photo Gifts!\n\nSincerely,\nWeb Team at www.fineartphotogifts.com,\n\"Affordable photographic art for home and office\"\n";
mail($rec_email,$subject,$message,"From: \"$send_email\" <$send_name>");
echo "<table><tr><td><img src=\"http://fineartphotogifts.com/images/graphics/fineartphotogifts_logo.gif\">
The following was sent to $rec_email ...</p><table width=\"98%\" bgcolor=\"#FFFFCC\"><tr><td>
".nl2br($message)."</p></td></tr></table><p align=\"center\"><a href=\"javascript:window.close();\">CLOSE WINDOW</a></p>";
# log to database
$log=db_query("INSERT INTO tellafriend (tafid,link,send_name,send_email,rec_name,rec_email,subject,body,timestamp) VALUES (NULL,'$link','$send_name','$send_email','$rec_name','$rec_email','$subject',$body,".time().")");
} else {
echo "All bolded fields are mandatory. Please use the back button on your browser and make sure all fields are filled in!\n";
}
} else {
echo "Not from fineartphotogifts.com!\n";
}
} else {
if($link =="") {
$link = "www.fineartphotogifts.com";
}
?>
<form action="<?php echo $PHP_SELF ?>" method="post">
<table width="400" cellpadding="0" cellspacing="0" border="0" style="background: #F0F0F0; border: 1px #6F6F6F solid;">
<tr><td colspan="2" style="background-color:#990000; color: #FFFFFF; font-weight: bold;">Tell a friend about Fine Art Photo Gifts!</td></tr>
<tr><td colspan="2" style="padding: 10px; background-color: #FFFFFF; border-bottom: 1px #000 solid;">Send a brief note to a friend or colleague using this form. The note will be sent by Fine Art Photo Gifts on your behalf, and will reference this page:
<span style="font-size:10px; color:red;"><?php echo $link ?></span>
You may also add a personal note if you wish.</td></tr>
<tr>
<td nowrap>Your Name:</td>
<td style="padding-top: 5px;" width="70%"><input type="text" name="send_name" style="width: 100%;"></td>
</tr>
<tr>
<td nowrap style="border-bottom: 1px black solid;">Your E-Mail:</td>
<td width="70%" style="border-bottom: 1px black solid;"><input type="text" name="send_email" style="width: 100%;"></td>
</tr>
<tr>
<td nowrap>Friend's Name:</td>
<td width="70%"><input type="text" name="rec_name" style="width: 100%;"></td>
</tr>
<tr>
<td nowrap style="border-bottom: 1px black solid;">Friend's E-Mail:</td>
<td width="70%" style="border-bottom: 1px black solid;"><input type="text" name="rec_email" style="width: 100%;"></td>
</tr>
<tr>
<td style="padding-top:6px;">Subject:</td>
<td width="70%" style="padding-top:6px;"><input type="text" name="subject" style="width: 100%;"></td>
</tr>
<tr><td colspan="2">Add your personal note below:
<textarea name="body" style="width: 100%" rows="10"></textarea></td></tr>
<tr><td colspan="2" align="right"><input type="submit" name="submit" value="Send"></td></tr>
</table>
<input type="hidden" name="link" value="<?php echo $link ?>">
</form>
<?php
}
?>
</body>
</html>
Create a template under /modules/upselling_products/tellafriend.tpl and fill it with this code. You may wish to get rid of the "width={$product.image_x}" portion if you are not putting Tellafriend under the thumbnail:
Code:
<table width={$product.image_x} style="border:1px silver solid;">
<tr><td align=left>
<table width=90% cellpadding=0 cellspacing=0 border=0>
<tr><td class="ProductDetailsTitle">
Tell Your Friends[img]../skin1/images/tellafriend.gif[/img]</td></tr>
<tr><td class=Line height="1">[img]{$ImagesDir}/spacer.gif[/img]</td></tr>
<tr><td style="font-size:10px;"><ul>[*]
Send your friends a link to this page![*]
Print this page[/list]</td></tr>
</table>
</td>
</tr>
</table>
At the proper place in your /customer/main/product.tpl place this line:
Code:
{include file="modules/Upselling_Products/tellafriend.tpl}
to call the code onto the page.
That should be it. I think you have it all now. If you have questions, I'll try to help, but since I'm no guru like Shan, or Boomer, or some others I may fumble a bit. Let us know how well this works for you.