klubas Posted January 6, 2015 Share Posted January 6, 2015 (edited) 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 January 6, 2015 by klubas (see edit history) Link to comment Share on other sites More sharing options...
Richard S Posted January 6, 2015 Share Posted January 6, 2015 You might use the same lines, just change $friendEmail variable with your administrator email or administrator's email variable. You will get an indentical copy of an email. Link to comment Share on other sites More sharing options...
klubas Posted January 6, 2015 Author Share Posted January 6, 2015 Hello Richard, Thank you for replay but I need example I'm just at the begining of programing. Link to comment Share on other sites More sharing options...
Richard S Posted January 7, 2015 Share Posted January 7, 2015 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 More sharing options...
CartExpert.net Posted January 7, 2015 Share Posted January 7, 2015 Instead of '[email protected]' you should use Configuration::get('PS_SHOP_EMAIL') Regards.Robin.The CartExpert Team Link to comment Share on other sites More sharing options...
klubas Posted January 7, 2015 Author Share Posted January 7, 2015 (edited) 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 January 7, 2015 by klubas (see edit history) Link to comment Share on other sites More sharing options...
Richard S Posted January 7, 2015 Share Posted January 7, 2015 You are handling the params of function wrong. It should be "[email protected], [email protected]" instead of two separate strings separated by comma Link to comment Share on other sites More sharing options...
klubas Posted January 7, 2015 Author Share Posted January 7, 2015 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 More sharing options...
Richard S Posted January 9, 2015 Share Posted January 9, 2015 Then call the same function two times, and pass one admin email on first call, and second admin email on second call. Link to comment Share on other sites More sharing options...
esteruelas Posted January 27, 2015 Share Posted January 27, 2015 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 More sharing options...
esteruelas Posted January 28, 2015 Share Posted January 28, 2015 (edited) 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 January 28, 2015 by esteruelas (see edit history) Link to comment Share on other sites More sharing options...
esteruelas Posted January 28, 2015 Share Posted January 28, 2015 Yes, I know, anyway I ´ll tell to my boss again. That´s life. Thank again Enrique I hope find you or read your post here soon. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now