Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[TIP / TRICK] Tell A Friend Reporting


mattice

Recommended Posts

Tell A Friend Reporting

 

The Tell a Friend feature on osCommerce is a popular feature.

Is it? You don't really know, do you? And who is sending what?

And what are they saying?

Might be your competitor telling his buddies to adapt their price to 90% of yours?

 

A very simple but sufficient hack in /catalog/tell_a_friend.php will give the answers to all above questions.

And ofcoarse silently.. so the customer never knows, just like we SysGods like it ;)

 

Changes to make

 

In /catalog/tell_a_friend.php (around line 139) where the tep_mail() function is called you add the following AFTER the tep_mail() line:

 

// Mail a (silent) report to the web owner:



// get ip

 if (getenv('HTTP_X_FORWARDED_FOR')) {

     $ip=getenv('HTTP_X_FORWARDED_FOR');

   } else {

     $ip=getenv('REMOTE_ADDR');

 }



// build report

   $report  = 'Here are the details of the T.A.F. submission by ' . $from_name . ' on ' . date("D M j G:i:s Y") . ':';

   $report .= "nn" . 'Recipient details: ' . $HTTP_POST_VARS['friendname'] . ' - ' . $HTTP_POST_VARS['friendemail'];

   $report .= "n" . 'Sender details: ' . $from_name . ' - ' . $from_email_address;

   $report .= "n" . 'Sender ip address: ' . $ip;

   $report .= "n" . 'Personal message: ' . "nn" . $HTTP_POST_VARS['yourmessage'];

   $report .= "nn" . 'Product link: ' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?products_id=' . $HTTP_GET_VARS['products_id'];



// mail report

   tep_mail('Tell A Friend', '[email protected]', '[ REPORT ] Tell a Friend Usage', stripslashes($report), '', $from_email_address);

 

Things to remember

Note that if you use MIME e-mail you should change all occurances of "n" to "<br>".

Furthermore you should obviously change the e-mail address used to reflect your own.

 

Regards,

 

Mattice

 

 

 

PS:

// mail report - NOTE THE BLUE ADDITION!

   tep_mail('Tell A Friend', '[email protected]', '[ REPORT ] Tell a Friend Usage', stripslashes($report), '', $from_email_address, '');

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

  • Replies 61
  • Created
  • Last Reply

I am running MS1 loaded, and cannot seem to find the correct place to insert this code. Every natural break after TEP MAIL results in email going to receiver, but not a copy to my shop, and you never a "email sent" message on the store.

 

Could you show me the full phrase you need to insert this code after?

 

Thanks for any assistance - this sounds like a wonderful idea!!

Link to comment
Share on other sites

I am running MS1 loaded, and cannot seem to find the correct place to insert this code. Every natural break after TEP MAIL results in email going to receiver, but not a copy to my shop, and you never a "email sent" message on the store.

 

Could you show me the full phrase you need to insert this code after?

 

Thanks for any assistance - this sounds like a wonderful idea!!

 

Okay, here's the snippet from the latest (v 1.35 ) /catalog/tell_a_friend.php which is in MS1,

this is line number 136 to 140:

 

 $email_body .= sprintf(TEXT_EMAIL_LINK, tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'])) . "nn" .

sprintf(TEXT_EMAIL_SIGNATURE, STORE_NAME . "n" . HTTP_SERVER . DIR_WS_CATALOG . "n");

                 



 tep_mail($HTTP_POST_VARS['friendname'], $HTTP_POST_VARS['friendemail'], $email_subject, stripslashes($email_body), '', $from_email_address);



/*----------------------------

INSERT MATTICE CODE 

HERE, MAKE SURE IT HAS

NO LINE BREAKS IN IT !

-----------------------------*/



?>

 

Mattice

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

Now we just need to feed the data in mysql and get some stats report out of it from the admin!

 

Why? Personally I do not see the benefit of storing the tell-a-friend copies in the database, I prefer to have them e-mailed, like any 'semi-security' report. But by all means feel free to write it! :D

 

Mattice

"Politics is the art of preventing people from taking part in affairs which properly concern them"

Link to comment
Share on other sites

Mattice...

 

Well getting these email everyday is nice to have immediate info and as you said make sure no one abuse the system.

 

But would not it be nice to see a report over a few months period with how may tell-a-friends/month, which items are the most suggested, ups and downs, etc.

 

I have a simillar system using a Perl based tell-a-friend, and I could not live without! At some point I will get used to PHP... for now I will probably interface it with a log file and a perl script...

 

Again thanks for your contrib. It's very motivating to get small snippet of codes and try to understand vs. going through the all oscommerce scripts!

 

Jean.

Link to comment
Share on other sites

In /catalog/tell_a_friend.php (around line 139) where the tep_mail() function is called you add the following AFTER the tep_mail() line:

 

// Mail a (silent) report to the web owner:

if (CONFIG_SEND_TO_A_FRIEND == 'true') {

 

// get ip

if (getenv('HTTP_X_FORWARDED_FOR')) {

$ip=getenv('HTTP_X_FORWARDED_FOR');

} else {

$ip=getenv('REMOTE_ADDR');

}

 

// build report

$report = 'Here are the details of the T.A.F. submission by ' . $from_name . ' on ' . date("D M j G:i:s Y") . ':';

$report .= "nn" . 'Recipient details: ' . $HTTP_POST_VARS['friendname'] . ' - ' . $HTTP_POST_VARS['friendemail'];

$report .= "n" . 'Sender details: ' . $from_name . ' - ' . $from_email_address;

$report .= "n" . 'Sender ip address: ' . $ip;

$report .= "n" . 'Personal message: ' . "nn" . $HTTP_POST_VARS['yourmessage'];

$report .= "nn" . 'Product link: ' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?products_id=' . $HTTP_GET_VARS['products_id'];

 

// mail report

tep_mail('Tell A Friend', EMAIL_SEND_TO_A_FRIEND, '[ REPORT ] Tell a Friend Usage', stripslashes($report), '', $from_email_address);

}

 

 

insert into your MySQL database:

 

INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('', 'Send To A Friend - Control ON/OFF', 'CONFIG_SEND_TO_A_FRIEND', 'true', 'Would you like to get an email when a visitor uses Send To A Friend ?', 12, 800, '2003-03-14 12:20:07', '2003-03-14 12:20:07', NULL, 'tep_cfg_select_option(array('true', 'false'),');

INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('', 'Send To A Friend - Email', 'EMAIL_SEND_TO_A_FRIEND', 'your email', 'Send an Email to this address when someone uses Send to a friend option', 12, 801, '2003-03-14 12:20:07', '2003-03-14 12:20:07', NULL, NULL);

 

In /catalog/tell_a_friend.php (around line 139) where the tep_mail() function is called you add the following AFTER the tep_mail() line:



// Mail a (silent) report to the web owner: 

if (CONFIG_SEND_TO_A_FRIEND == 'true') {



// get ip 

 if (getenv('HTTP_X_FORWARDED_FOR')) { 

     $ip=getenv('HTTP_X_FORWARDED_FOR'); 

   } else { 

     $ip=getenv('REMOTE_ADDR'); 

 } 



// build report 

   $report  = 'Here are the details of the T.A.F. submission by ' . $from_name . ' on ' . date("D M j G:i:s Y") . ':'; 

   $report .= "nn" . 'Recipient details: ' . $HTTP_POST_VARS['friendname'] . ' - ' . $HTTP_POST_VARS['friendemail']; 

   $report .= "n" . 'Sender details: ' . $from_name . ' - ' . $from_email_address; 

   $report .= "n" . 'Sender ip address: ' . $ip; 

   $report .= "n" . 'Personal message: ' . "nn" . $HTTP_POST_VARS['yourmessage']; 

   $report .= "nn" . 'Product link: ' . HTTP_SERVER . DIR_WS_CATALOG . FILENAME_PRODUCT_INFO . '?products_id=' . $HTTP_GET_VARS['products_id']; 



// mail report 

   tep_mail('Tell A Friend', EMAIL_SEND_TO_A_FRIEND, '[ REPORT ] Tell a Friend Usage', stripslashes($report), '', $from_email_address);

}

 

insert into your MySQL database:

this will put the config options in Admin > Configuration > E-mail options

INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('', 'Send To A Friend - Control ON/OFF', 'CONFIG_SEND_TO_A_FRIEND', 'true', 'Would you like to get an email when a visitor uses Send To A Friend ?', 12, 800, '2003-03-14 12:20:07', '2003-03-14 12:20:07', NULL, 'tep_cfg_select_option(array('true', 'false'),');

INSERT INTO configuration (configuration_id, configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('', 'Send To A Friend - Email', 'EMAIL_SEND_TO_A_FRIEND', 'your email', 'Send an Email to this address when someone uses Send to a friend option', 12, 801, '2003-03-14 12:20:07', '2003-03-14 12:20:07', NULL, NULL);

 

thanks Mattice

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

oops

 

my mistake double posting

 

start at the

Code:

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

  • 2 weeks later...

<td class="main"><?php echo FORM_FIELD_FRIEND_NAME; ?></td>

<td class="main"><?php echo tep_draw_input_field('friendname');?></td>

</tr>

<tr>

<td class="main"><?php echo FORM_FIELD_FRIEND_EMAIL; ?></td>

live long and prosper

Link to comment
Share on other sites

I tried this on tell_a_friend.php,v 1.28 2002/10/08 and I had to stop my server.

 

It sent me one correct email and then it kept on creating emails from "Apache" and sending them to me without any information:

 

Here are the details of the T.A.F. submission by on Tue Apr 1 15:05:55 2003:

 

Recipient details: -

Sender details: -

Sender ip address: 66.82.9.32

Personal message:

 

Don't this code work with ver 1.28 or did I mess something up?

Link to comment
Share on other sites

that must have been an April Fools joke from you or Apache

Robert

 

We all need to learn it once, how hard it may seem when you look at it, also you will master it someday ;)

Link to comment
Share on other sites

  • 3 weeks later...

Sorry, but when I paste the code ?

 

This is my code from 129 to 159 line

            <td class="formAreaTitle"><br><?php echo FORM_TITLE_FRIEND_DETAILS; ?></td>

         </tr>

         <tr>

           <td class="main"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="formArea">

             <tr>

               <td class="main"><table border="0" cellspacing="0" cellpadding="2">

                 <tr>

                   <td class="main"><?php echo FORM_FIELD_FRIEND_NAME; ?></td>

                   <td class="main"><?php echo tep_draw_input_field('friendname');?></td>

                 </tr>

                 <tr>

                   <td class="main"><?php echo FORM_FIELD_FRIEND_EMAIL; ?></td>

                   <td class="main"><?php echo tep_draw_input_field('friendemail', $HTTP_GET_VARS['send_to']);?></td>

                 </tr>

               </table></td>

             </tr>

           </table></td>

         </tr>

         <tr>

           <td class="formAreaTitle"><br><?php echo FORM_TITLE_FRIEND_MESSAGE; ?></td>

         </tr>

         <tr>

           <td class="main"><table border="0" width="100%" cellspacing="0" cellpadding="2" class="formArea">

             <tr>

               <td><?php echo tep_draw_textarea_field('yourmessage', 'soft', 40, 8);?></td>

             </tr>

           </table></td>

         </tr>

       </table></td>

     </tr>

     <tr>

Link to comment
Share on other sites

You've gone past the relevant lines...

 

Do a search for the 'tep_mail' statement.

tep_mail($HTTP_POST_VARS['friendname'], $HTTP_POST_VARS['friendemail'], $email_subject, stripslashes($email_body), '', $from_email_address);

 

There should only be the one (two after you've complete the mod) 'tep_mail' in the file.

Once you find it, follow the instructions from there.

 

HTH,

Tony

"The price of success is perseverance. The price of failure comes much cheaper."

Link to comment
Share on other sites

I've pasted the code after this

 

tep_mail($HTTP_POST_VARS['friendname'], $HTTP_POST_VARS['friendemail'], $email_subject, stripslashes($email_body), '', $from_email_address);

 

But I've error in process page :cry:

Link to comment
Share on other sites

  • 2 months later...

i removed the tell-a-friend box from my store to make room for other things; is it really that popular?

 

for anyone who has made the silent email modification, any feedback on whether customers use it and how useful it is in generating leads?

 

Ben Daughtry

Dachitech Software

www.dtechsoftware.com

--B

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...