Jump to content

Send to a friend module - sending copy to another email


klubas

Recommended Posts

Hello,
 
What to change in the code of module "Send to a Friend 1.7.2" that it could also send a copy of same email to the shop administrator.
 
in the file sendtoafriend_ajax.php I found part that propably responsible for email sending..but I  dont what to change there...
 

...
/* Email sending */
if (!Mail::Send((int)$module->context->cookie->id_lang,
'send_to_a_friend',
sprintf(Mail::l('%1$s sent you a link to %2$s', (int)$module->context->cookie->id_lang), $customer, $product->name),
$templateVars, $friendMail,
null,
...

Thank you.

Edited by klubas (see edit history)
Link to comment
Share on other sites

I've outlined everything.... 

/* Email sending */
if (!Mail::Send((int)$module->context->cookie->id_lang,
'send_to_a_friend',
sprintf(Mail::l('%1$s sent you a link to %2$s', (int)$module->context->cookie->id_lang), $customer, $product->name),
$templateVars, $friendMail,
null,
...


/* Admin email sending - modified */
if (!Mail::Send((int)$module->context->cookie->id_lang,
'send_to_a_friend',
sprintf(Mail::l('%1$s sent you a link to %2$s', (int)$module->context->cookie->id_lang), $customer, $product->name),
$templateVars, "[email protected]",
null,
...
Link to comment
Share on other sites

Hello,

 

this solution works with one email address

/* Admin email sending - modified */
if (!Mail::Send((int)$module->context->cookie->id_lang,
'send_to_a_friend',
sprintf(Mail::l('%1$s sent you a link to %2$s', (int)$module->context->cookie->id_lang), $customer, $product->name),
$templateVars, "[email protected]",
null,
...

if I want to send copy to another email, it doesnt work, something is missing in the code I think

/* Admin email sending - modified */
if (!Mail::Send((int)$module->context->cookie->id_lang,
'send_to_a_friend',
sprintf(Mail::l('%1$s sent you a link to %2$s', (int)$module->context->cookie->id_lang), $customer, $product->name),
$templateVars, "[email protected]", "[email protected]",
null,
null,
($module->context->cookie->email ? $module->context->cookie->email : null),
($module->context->cookie->customer_firstname ? $module->context->cookie->customer_firstname.' '.$module->context->cookie->customer_lastname : null),
null,
null,
dirname(__FILE__).'/mails/'))
die('0');
die('1');
}
die('0');
Edited by klubas (see edit history)
Link to comment
Share on other sites

Hello Richard,

 

If I do like you say "[email protected], [email protected]

l got popup with error at front-end:

Your e-mail could not be sent. Please check the e-mail address and try again.

 

I found that this error coming from sendtoafriend-extra.tpl. What is the next step to make it work?

<script type="text/javascript">
{literal}
$('document').ready(function(){
$('#send_friend_button').fancybox({
'hideOnContentClick': false
});


$('#sendEmail').click(function(){
        
        var name = $('#friend_name').val();
        var email = $('#friend_email').val();
        var id_product = $('#id_product_comment_send').val();
if (name && email && !isNaN(id_product))
{
$.ajax({
{/literal}url: "{$module_dir}sendtoafriend_ajax.php",{literal}
type: "POST",
headers: {"cache-control": "no-cache"},
data: {action: 'sendToMyFriend', secure_key: '{/literal}{$stf_secure_key}{literal}', name: name, email: email, id_product: id_product},{/literal}{literal}
dataType: "json",
success: function(result) {
$.fancybox.close();
                    var msg = result ? "{/literal}{l s='Your e-mail has been sent successfully' mod='sendtoafriend'}{literal}" : "{/literal}{l s='Your e-mail could not be sent. Please check the e-mail address and try again.' mod='sendtoafriend'}{literal}";
                    var title = "{/literal}{l s='Send to a friend' mod='sendtoafriend'}{literal}";
                    fancyMsgBox(msg, title);
}
});
}else
Link to comment
Share on other sites

  • 3 weeks later...

Hi from Spain.

I´m trying to make the same thing in PS 1.6.0.9, "send to a friend module", multistore,  bootstrap theme.

I´m trying to send the $friendMail to the mail template too.

My code is:

$templateVars = array(
'{product}' => $product->name,
'{product_link}' => $productLink,
'{customer}' => $customer,
'{friend_mail}' => Tools::safeOutput($friendMail),
'{name}' => Tools::safeOutput($friendName)
);

/* Email sending */
if (!Mail::Send((int)$module->context->cookie->id_lang,
'send_to_a_friend',
sprintf(Mail::l('%1$s sent you a link to %2$s', (int)$module->context->cookie->id_lang), $customer, $product->name),
$templateVars, $friendMail,
null,
($module->context->cookie->email ? $module->context->cookie->email : null),
($module->context->cookie->customer_firstname ? $module->context->cookie->customer_firstname.' '.$module->context->cookie->customer_lastname : null),
null,
null,
dirname(__FILE__).'/mails/'))
die('0');
die('1');
/* Email copy sending */
if (!Mail::Send((int)$module->context->cookie->id_lang,
'send_to_a_friend',
sprintf(Mail::l('%1$s momomi %2$s', (int)$module->context->cookie->id_lang), $customer, $product->name),
$templateVars, "[email protected]",
null,
($module->context->cookie->email ? $module->context->cookie->email : null),
($module->context->cookie->customer_firstname ? $module->context->cookie->customer_firstname.' '.$module->context->cookie->customer_lastname : null),
null,
null,
dirname(__FILE__).'/mails/'))
die('0');
die('1');
 


I´m not able to rescue the frienMail var and send the copy of the mail .
 
Could someone help me, please?
Thanks

Link to comment
Share on other sites

Hi,

Thanks Enrique,

Your code works fine.

I see your changes and my mistakes.

 

What do you think about my other problem: rescue on mail template the $friendMail send by sendtoafriend_ajax.php?

$templateVars = array(
    '{product}' => $product->name,
    '{product_link}' => $productLink,
    '{customer}' => $customer,
    '{friend_mail}' => Tools::safeOutput($friendMail), /* rescatando la variable mail del amigo */
    '{name}' => Tools::safeOutput($friendName)

Regards

Edited by esteruelas (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...