Jump to content

Changing Email Subject Names


ruaridhc

Recommended Posts

Hi, I'm trying to figure out how to change the default subject name of the emails that go out but am having trouble finding where or what I need to change.

I'd like to remove the [shop name] from the start of the email subject, since this info is in the 'from' part of the email.

I'd assumed it would be somewhere in the email template, for example, newletter would be in blocknewsletter/mails/en/newsletter_conf.html - but i can't seem to find it. I'm I missing it there?

Thanks for any help

Link to comment
Share on other sites

To remove the [sHOP NAME] from the email subject, change line 93 of classes/Mail.php (in PrestaShop v1.3.1) from:

$message = new Swift_Message('['.Configuration::get('PS_SHOP_NAME').'] '.((is_array($_LANGMAIL) AND key_exists($subject, $_LANGMAIL)) ? $_LANGMAIL[$subject] : $subject));



to:

$message = new Swift_Message(((is_array($_LANGMAIL) AND key_exists($subject, $_LANGMAIL)) ? $_LANGMAIL[$subject] : $subject));



The subject lines are translated in lang.php in the language's directory in mails.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 weeks later...
My post here might help.


Spot on... Thank you.

You don't also happen to know how to change the name field on the received email from the shop name to the name that the customer inputs and so that when you click reply it will reply to the customers email and not the shops email?

Many thanks

Mark
Link to comment
Share on other sites

I don't understand. My version of PrestaShop already does this. What version of PrestaShop are you using? I know older versions used to act the way you describe. Here's what I have in my contact-form.php:

<?php

$useSSL = true;

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/header.php');

$errors = array();

$smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang)));

if (Tools::isSubmit('submitMessage'))
{
   if (!($from = Tools::getValue('from')) OR !Validate::isEmail($from))
       $errors[] = Tools::displayError('invalid e-mail address');
   elseif (!($message = nl2br2(Tools::getValue('message'))))
       $errors[] = Tools::displayError('message cannot be blank');
   elseif (!Validate::isMessage($message))
       $errors[] = Tools::displayError('invalid message');
   elseif (!($id_contact = intval(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact(intval($id_contact), intval($cookie->id_lang)))))
       $errors[] = Tools::displayError('please select a contact in the list');
   else
   {
       if (intval($cookie->id_customer))
           $customer = new Customer(intval($cookie->id_customer));
       if (Mail::Send(intval($cookie->id_lang), 'contact', 'Message from contact form', array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))
           $smarty->assign('confirmation', 1);
       else
           $errors[] = Tools::displayError('an error occurred while sending message');
   }
}

$email = Tools::safeOutput(Tools::getValue('from', ((isset($cookie) AND isset($cookie->email) AND Validate::isEmail($cookie->email)) ? $cookie->email : '')));
$smarty->assign(array(
   'errors' => $errors,
   'email' => $email
));

$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
include(dirname(__FILE__).'/footer.php');

?>

Link to comment
Share on other sites

Thanks for your reply, this is the code I have in my contact-form.php ... I'm using v1.31 of Prestashop and then i click reply it replies to the shop email, the one setup in the back office.

<?php

include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/header.php');

$errors = array();

$smarty->assign('contacts', Contact::getContacts(intval($cookie->id_lang)));

if (Tools::isSubmit('submitMessage'))
{
   if (!($from = Tools::getValue('from')) OR !Validate::isEmail($from))
       $errors[] = Tools::displayError('Invalid e-mail address');

       elseif (!($name = nl2br2(Tools::getValue('name'))))
       $errors[] = Tools::displayError('Name cannot be blank');
   elseif (!($message = nl2br2(Tools::getValue('message'))))
       $errors[] = Tools::displayError('Message cannot be blank');
   elseif (!Validate::isMessage($message))
       $errors[] = Tools::displayError('Invalid message');
   elseif (!($id_contact = intval(Tools::getValue('id_contact'))) OR !(Validate::isLoadedObject($contact = new Contact(intval($id_contact), intval($cookie->id_lang)))))
       $errors[] = Tools::displayError('Please select a contact in the list');
   else
   {
if ( Mail :: Send ( intval ( $cookie -> id_lang ), 'contact' , $contact->name , array( '{email}' => $_POST[ 'from' ] , '{message}' => stripslashes ( $message ), '{name}' => stripslashes ( $name ) ), $contact -> email )) 
$smarty -> assign ( 'confirmation' , 1 ); 
       else
           $errors[] = Tools::displayError('An error occurred while sending message');
   }
}

$email = Tools::safeOutput(Tools::getValue('from', ((isset($cookie) AND isset($cookie->email) AND Validate::isEmail($cookie->email)) ? $cookie->email : '')));
$smarty->assign(array(
   'errors' => $errors,
   'email' => $email
));

Tools::safePostVars();
$smarty->display(_PS_THEME_DIR_.'contact-form.tpl');
include(dirname(__FILE__).'/footer.php');

?> 

Link to comment
Share on other sites

The code you copied from my post was for PrestaShop v1.1, which replied to the shop email instead of the customer email. Try the following instead:

if (Mail::Send(intval($cookie->id_lang), 'contact', $contact->name, array('{email}' => $from, '{message}' => stripslashes($message)), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from)))

Link to comment
Share on other sites

Thank you once again, you have solved in about 5 minutes what I have been trying for ages...

I had to add '{name}' => stripslashes ( $name ) as the name field within the contact form wasn't sending.

So the code i used was this,

if (Mail::Send(intval($cookie->id_lang), 'contact', $contact->name, array('{email}' => $from, '{message}' => stripslashes($message),'{name}' => stripslashes ( $name )), $contact->email, $contact->name, $from, (intval($cookie->id_customer) ? $customer->firstname.' '.$customer->lastname : $from))) 



Many thanks

Mark

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...