Send To A Friend Mod

Hello,



I want to add the main thumbnail of the product in the email sent by the “Send to a friend” tab.

I did the following without a result:

I added in the customer/addons/send_to_friend/blocks/send_to_friend.tpl







then I added some php code in the customer/mail/addons/send_to_friend/mail.tpl


<?php
$img = db_get_field("SELECT l.image_path FROM $db_tables[cscart_images_links] i, $db_tables[cscart_images] l WHERE i.image_id = l.image_id AND i.object_id= {$send_data.productid} AND i.type='M'");
?>

But I dont know how to assign the $img variable outside the php code to use it with a tag.
I also do not know if the php code works in mail.tpl

please give me a hint !!

Hi,



All i know is that data is sent throught $send_data array

in skins[current_skin]\customer\addons\send_to_friend\blocks\product_tabs\send_to_friend.tpl you can pass hidden data



And in skins[current_skin]\mail\addons\send_to_friend\mail.tpl you can update the layout design for email



this code can be added in mail.tpl



id="det_img_{$send_data.obj_id}" src="{$config.full_host_name}{$send_data.absolute_path|default:$config.no_image_path}"
{if $send_data.image_width}width="{$send_data.image_width}"{/if}
{if $send_data.image_height}height="{$send_data.image_height}"{/if}
alt="{$images.icon.alt|default:$images.detailed.alt}" border="0" />







and this one in send_to_friend.tpl





} />
} />





But I have the same problem in viewing the image in email …maybe is something else too, from send_to_friend.php controller …

So, i have make it work like this:



we have skins/…/mail/addons/send_to_friend/mail.tpl


<br />
{$lang.hello} {$send_data.to_name},<br /><br /><br />
<br />
{$lang.text_recommendation_notes}<br /><br />
<a href="{$link|fn_url:'C'}">{$link|fn_url:'C'}</a><br /><br /><br />
<br />
<img class="border-img" <br />
	id="det_img_{$send_data.obj_id}" src="{$config.full_host_name}{$send_data.absolute_path|default:$config.no_image_path}" <br />
	{if $send_data.image_width}width="{$send_data.image_width}"{/if} <br />
	{if $send_data.image_height}height="{$send_data.image_height}"{/if} <br />
	alt="{$images.icon.alt|default:$images.detailed.alt}" border="0" /><br />
<br />
<br /><br />
<b>{$lang.notes}:</b><br /><br />
{$send_data.notes|replace:"\n":"<br />"}<br />
<br />
<br />
{include file="letter_footer.tpl"}<br />

```<br />
<br />
then, we have also, skins/.../customer/addons/send_to_friend/blocks/product_tabs/send_to_friend.tpl<br />
<br />
```php
<br />
{** block-description:send_to_friend **}<br />
<br />
<br />
<br />
{if $product.main_pair.icon || $product.main_pair.detailed}<br />
	{assign var="image_pair_var" value=$product.main_pair}<br />
{elseif $product.option_image_pairs}<br />
	{assign var="image_pair_var" value=$product.option_image_pairs|reset}<br />
{/if}<br />
<br />
{if $image_pair_var.image_id == 0}<br />
	{assign var="image_id" value=$image_pair_var.detailed_id}<br />
{else}<br />
	{assign var="image_id" value=$image_pair_var.image_id}<br />
{/if}<br />
{* main big image *}<br />
<br />
<br />
<br />
<div id="content_send_to_friend"><br />
<br />
<form name="send_to_friend_form" action="{""|fn_url}" method="post"><br />
<br />
<input type="hidden" name="selected_section" value="send_to_friend" /><br />
<br />
<input type="hidden" name="redirect_url" value="{$config.current_url}" /><br />
<br />
<input type="hidden" name="send_data[product_title]" value="{$product.product|unescape}" /><br />
<br />
<input type="hidden" name="send_data[object_id]" value="{$product.product_id}" /><br />
<br />
<br />
{* for image section *}<br />
<br />
<input type="hidden" name="send_data[obj_id]" value={$product.product_id}_{$image_id} /><br />
<input type="hidden" name="send_data[absolute_path]" value={$image_pair_var.detailed.image_path} /><br />
<input type="hidden" name="send_data[image_width]" value={$settings.Thumbnails.product_lists_thumbnail_width<br />
} /><br />
<input type="hidden" name="send_data[image_height]" value={$settings.Thumbnails.product_lists_thumbnail_height<br />
} /><br />
<br />
<br />
<br />
<div class="form-field"><br />
	<br />
	<label for="send_name">{$lang.name_of_friend}:</label><br />
<br />
	<input id="send_name" class="input-text" size="50" type="text" name="send_data[to_name]" value="{$send_data.to_name}" /><br />
<br />
</div><br />
<br />
<br />
<br />
<div class="form-field"><br />
<br />
	<label for="send_email" class="cm-required cm-email">{$lang.email_of_friend}:</label><br />
<br />
	<input id="send_email" class="input-text" size="50" type="text" name="send_data[to_email]" value="{$send_data.to_email}" /><br />
<br />
</div><br />
<br />
<br />
<br />
<div class="form-field"><br />
<br />
	<label for="send_yourname">{$lang.your_name}:</label><br />
<br />
	<input id="send_yourname" size="50" class="input-text" type="text" name="send_data[from_name]" value="{if $send_data.from_name}{$send_data.from_name}{elseif $auth.user_id}{$user_info.firstname} {$user_info.lastname}{/if}" /><br />
<br />
</div><br />
<br />
<br />
<br />
<div class="form-field"><br />
<br />
	<label for="send_youremail" class="cm-email">{$lang.your_email}:</label><br />
<br />
	<input id="send_youremail" class="input-text" size="50" type="text" name="send_data[from_email]" value="{if $send_data.from_email}{$send_data.from_email}{elseif $auth.user_id}{$user_info.email}{/if}" /><br />
<br />
</div><br />
<br />
<br />
<br />
<div class="form-field"><br />
<br />
	<label for="send_notes" class="cm-required">{$lang.your_message}:</label><br />
<br />
	<textarea id="send_notes"  class="input-textarea" rows="5" cols="72" name="send_data[notes]">{if $send_data.notes}{$send_data.notes}{else}{$product.product|unescape}{/if}</textarea><br />
<br />
</div><br />
<br />
<br />
<br />
{if $settings.Image_verification.use_for_send_to_friend == "Y"}<br />
<br />
	{include file="common_templates/image_verification.tpl" id="send_to_friend" align="left"}<br />
<br />
{/if}<br />
<br />
<br />
<br />
<div class="buttons-container"><br />
<br />
	{include file="buttons/button.tpl" but_text=$lang.send but_name="dispatch[send_to_friend.send]"}<br />
<br />
</div><br />
<br />
<br />
<br />
</form><br />
<br />
</div><br />

```<br />
<br />
<br />
and finally, i have updated the send_mail function (located in root rolder of cs-cart, addons/send_to_friend/controllers/common/send_to_friend.php) with 2 more parameters, somewhere around line 50, like this:<br />
<br />
```php
<br />
..<br />
if (fn_send_mail($_REQUEST['send_data']['to_email'], $from, 'addons/send_to_friend/mail_subj.tpl', 'addons/send_to_friend/mail.tpl', '', CART_LANGUAGE, 'no-reply@domain.com', $is_html=true)) {<br />
				fn_set_notification('N', fn_get_lang_var('notice'), fn_get_lang_var('text_email_sent'));<br />
			}<br />
...<br />

```<br />
<br />
and that will be all.enjoy using it! <img src="upload://yGrKuhdxbbf2nIFvV2XDJuEFQb7.gif" class="bbc_emoticon" alt=":)">