Jump to content

[SOLVED] change email subject "Welcome!" and "Order confirmation"


Recommended Posts

Hi guys, i have a big problem.

 

The email subjects of the emails welcome and order confirmation are still in englisch, but they should be in dutch. I use prestashop

1.3.7.0

so maybe there is a bug i need to fix..

 

/mails/nl/lang.php :

 

 

<?php

 

global $_LANGMAIL;

$_LANGMAIL = array();

$_LANGMAIL['Your new admin password'] = 'Uw nieuwe Administrator wachtwoord';

$_LANGMAIL['Your password'] = 'Uw nieuwe wachtwoord';

$_LANGMAIL['Welcome!'] = 'Welkom!';

$_LANGMAIL['Order confirmation'] = 'Bestelbevestiging';

$_LANGMAIL['Message from contact form'] = 'Bericht via het contactformulier';

$_LANGMAIL['My personal informations'] = 'Uw persoonlijke informatie';

$_LANGMAIL['Message from a customer'] = 'Bericht van een klant';

$_LANGMAIL['Virtual product to download'] = 'Download uw virtuele product';

$_LANGMAIL['Referral Program'] = 'Referentieprogramma';

$_LANGMAIL['Package in transit'] = 'Uw bestelling is verzonden';

 

?>

 

The iso code of my webshop is 'nl'

 

What must I do to fix this problem.. I need to fix it today, is there somebody who has time for me?

 

Thanks in advance!!

Link to comment
Share on other sites

Of course, this is my authentication.php from the rootmap:

 

<?php
/* SSL Management */
$useSSL = true;
include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');
if ($cookie->isLogged())
Tools::redirect('my-account.php');
//CSS ans JS file calls
$js_files = array(
_THEME_JS_DIR_.'tools/statesManagement.js',
__PS_BASE_URI__.'js/jquery/jquery-typewatch.pack.js'
);
$errors = array();
$back = Tools::getValue('back');
$key = Tools::safeOutput(Tools::getValue('key'));
if (!empty($key))
$back .= (strpos($back, '?') !== false ? '&' : '?').'key='.$key;
if (!empty($back))
$smarty->assign('back', Tools::safeOutput($back));

if (Tools::getValue('create_account'))
{
$create_account = 1;
$smarty->assign('email_create', 1);
}
if (Tools::isSubmit('SubmitCreate'))
{
if (!Validate::isEmail($email = Tools::getValue('email_create')))
 $errors[] = Tools::displayError('invalid e-mail address');
elseif (Customer::customerExists($email))
 $errors[] = Tools::displayError('someone has already registered with this e-mail address');
else
{
 $create_account = 1;
 $smarty->assign('email_create', Tools::safeOutput($email));
 $_POST['email'] = $email;
}
}
if (Tools::isSubmit('submitAccount'))
{
$create_account = 1;
$smarty->assign('email_create', 1);
$validateDni = Validate::isDni(Tools::getValue('dni'));
if (!Validate::isEmail($email = Tools::getValue('email')))
 $errors[] = Tools::displayError('e-mail not valid');
if (!Validate::isPasswd(Tools::getValue('passwd')))
 $errors[] = Tools::displayError('invalid password');
if (Customer::customerExists($email))
 $errors[] = Tools::displayError('someone has already registered with this e-mail address');
if (Tools::getValue('dni') != NULL AND $validateDni != 1)
{
 $error = array(
 0 => Tools::displayError('DNI isn\'t valid'),
 -1 => Tools::displayError('this DNI has been already used'),
 -2 => Tools::displayError('NIF isn\'t valid'),
 -3 => Tools::displayError('CIF isn\'t valid'),
 -4 => Tools::displayError('NIE isn\'t valid')
 );
 $errors[] = $error[$validateDni];
}
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) AND !(Tools::getValue('months') == '' AND Tools::getValue('days') == '' AND Tools::getValue('years') == ''))
 $errors[] = Tools::displayError('invalid birthday');
if (!sizeof($errors))
{
 $customer = new Customer();
 if (Tools::isSubmit('newsletter'))
 {
  $customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
  $customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
 }
 $customer->birthday = (empty($_POST['years']) ? '' : intval($_POST['years']).'-'.intval($_POST['months']).'-'.intval($_POST['days']));
 /* Customer and address, same fields, caching data */
 $addrLastname = isset($_POST['lastname']) ? $_POST['lastname'] : $_POST['customer_lastname'];
 $addrFirstname = isset( $_POST['firstname']) ?  $_POST['firstname'] : $_POST['customer_firstname'];
 $_POST['lastname'] = $_POST['customer_lastname'];
 $_POST['firstname'] = $_POST['customer_firstname'];
 $errors = $customer->validateControler();
 $_POST['lastname'] = $addrLastname;
 $_POST['firstname'] = $addrFirstname;
 $address = new Address();
 $address->id_customer = 1;
 $errors = array_unique(array_merge($errors, $address->validateControler()));
 if (!sizeof($errors))
 {
  if (!$country = new Country($address->id_country) OR !Validate::isLoadedObject($country))
   die(Tools::displayError());
  if (intval($country->contains_states) AND !intval($address->id_state))
   $errors[] = Tools::displayError('this country require a state selection');
  else
  {
   $customer->active = 1;
   if (!$customer->add())
 $errors[] = Tools::displayError('an error occurred while creating your account');
   else
   {
 $address->id_customer = intval($customer->id);
 if (!$address->add())
  $errors[] = Tools::displayError('an error occurred while creating your address');
 else
 {
  if (!Mail::Send(intval($cookie->id_lang), 'account', 'Welcome!',
  array('{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, '{passwd}' => Tools::getValue('passwd')), $customer->email, $customer->firstname.' '.$customer->lastname))
   $errors[] = Tools::displayError('cannot send email');
  $smarty->assign('confirmation', 1);
  $cookie->id_customer = intval($customer->id);
  $cookie->customer_lastname = $customer->lastname;
  $cookie->customer_firstname = $customer->firstname;
  $cookie->passwd = $customer->passwd;
  $cookie->logged = 1;
  $cookie->email = $customer->email;
  Module::hookExec('createAccount', array(
   '_POST' => $_POST,
   'newCustomer' => $customer
  ));
  if ($back)
   Tools::redirect($back);
  Tools::redirect('my-account.php');
 }
   }
  }
 }
}
}
if (Tools::isSubmit('SubmitLogin'))
{
$passwd = trim(Tools::getValue('passwd'));
$email = trim(Tools::getValue('email'));
if (empty($email))
 $errors[] = Tools::displayError('e-mail address is required');
elseif (!Validate::isEmail($email))
 $errors[] = Tools::displayError('invalid e-mail address');
elseif (empty($passwd))
 $errors[] = Tools::displayError('password is required');
elseif (Tools::strlen($passwd) > 32)
 $errors[] = Tools::displayError('password is too long');
elseif (!Validate::isPasswd($passwd))
 $errors[] = Tools::displayError('invalid password');
else
{
 $customer = new Customer();
 $authentication = $customer->getByEmail(trim($email), trim($passwd));
 /* Handle brute force attacks */
 sleep(1);
 if (!$authentication OR !$customer->id)
  $errors[] = Tools::displayError('authentication failed');
 else
 {
  $cookie->id_customer = intval($customer->id);
  $cookie->customer_lastname = $customer->lastname;
  $cookie->customer_firstname = $customer->firstname;
  $cookie->logged = 1;
  $cookie->passwd = $customer->passwd;
  $cookie->email = $customer->email;
  if (Configuration::get('PS_CART_FOLLOWING') AND (empty($cookie->id_cart) OR Cart::getNbProducts($cookie->id_cart) == 0))
   $cookie->id_cart = intval(Cart::lastNoneOrderedCart(intval($customer->id)));
  Module::hookExec('authentication');
  if ($back = Tools::getValue('back'))
   Tools::redirect($back);
  Tools::redirect('my-account.php');
 }
}
}
if (isset($create_account))
{
/* Generate years, months and days */
if (isset($_POST['years']) AND is_numeric($_POST['years']))
 $selectedYears = intval($_POST['years']);
$years = Tools::dateYears();
if (isset($_POST['months']) AND is_numeric($_POST['months']))
 $selectedMonths = intval($_POST['months']);
$months = Tools::dateMonths();
if (isset($_POST['days']) AND is_numeric($_POST['days']))
 $selectedDays = intval($_POST['days']);
$days = Tools::dateDays();
/* Select the most appropriate country */
if (isset($_POST['id_country']) AND is_numeric($_POST['id_country']))
 $selectedCountry = intval($_POST['id_country']);
elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
{
 $array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
 if (Validate::isLanguageIsoCode($array[0]))
 {
  $selectedCountry = Country::getByIso($array[0]);
  if (!$selectedCountry)
   $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
 }
}
if (!isset($selectedCountry))
 $selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
$countries = Country::getCountries(intval($cookie->id_lang), true);
$smarty->assign(array(
 'years' => $years,
 'sl_year' => (isset($selectedYears) ? $selectedYears : 0),
 'months' => $months,
 'sl_month' => (isset($selectedMonths) ? $selectedMonths : 0),
 'days' => $days,
 'sl_day' => (isset($selectedDays) ? $selectedDays : 0),
 'countries' => $countries,
 'sl_country' => (isset($selectedCountry) ? $selectedCountry : 0)
));
/* Call a hook to display more information on form */
$smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'),
			   'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')
		  ));
}
include(dirname(__FILE__).'/header.php');
$smarty->assign('errors', $errors);
Tools::safePostVars();
$smarty->display(_PS_THEME_DIR_.'authentication.tpl');
include(dirname(__FILE__).'/footer.php');
?>

Link to comment
Share on other sites

Hi again,

my file seems to be the same and everything works fine. As I can see you use only one language in store so you can replace

if (!Mail::Send(intval($cookie->id_lang), 'account', 'Welcome!',

 

by

if (!Mail::Send(intval(Configuration::get('PS_LANG_DEFAULT')), 'account', 'Welcome!',

Link to comment
Share on other sites

  • 2 months later...

all the mail's subjects translation are in the relative lang.php in mail folder.

but something must be really broken with the translations engine for this, 'cause inside the file are thing like those:

$_LANGMAIL[' Mail::l(\'Order confirmation\''] = 'オーダーを受け付けました。';

$_LANGMAIL[' Mail::l(\'Your order return state has changed\''] = '返品のリクエストを受け付けました。';

 

instead of

$_LANGMAIL['Order confirmation'] = 'オーダーを受け付けました。';

$_LANGMAIL['Your order return state has changed'] = '返品のリクエストを受け付けました。';

 

...i think it is really a bug...

Link to comment
Share on other sites

  • 2 months later...

Hi,

 

if you want to do it the same way go to classes/PaymentModule.php, find Mail:: function and replace 'Order confirmation' by 'Bestelbevestiging'

I did this too, and it solved the problem! THANKS! But I've been searching for an hour now on how to do the same with order return state and translate "Your order return state has changed" to "Opdatering af reklamationssag".

 

I'm using 1.4.4.1 and translation feature does not work :( Please help!

 

SOLVED: admin/tabs/AdminReturn.php - change

Mail::Send((int)$order->id_lang, 'order_return_state', Mail::l('[b]Your order return state has changed[/b]',

to your liking.

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

  • 11 months later...
  • 3 months later...
  • 5 weeks later...
  • 1 month later...
  • 4 years later...

My version is 1.7.2.4 and the topic was the same.

In fact there is no need to make any changes of php - "ciccio mazzetta" (see above) was right - simply find "lang.php" file in the /public_html/themes/YOURTHEME/mails/LL, where YOURTHEME is your active (in use) theme and LL is your language.

For example if you use Classic theme and Danish language - it should be "/public_html/themes/classic/mails/dk", initially it looks like this:

<?php

global $_LANGMAIL;
$_LANGMAIL = array();
$_LANGMAIL['Welcome!'] = '';
$_LANGMAIL['Your order has been changed'] = '';
$_LANGMAIL['Product available'] = '';
$_LANGMAIL['New order : #%d - %s'] = '';
$_LANGMAIL['Stock coverage'] = '';
$_LANGMAIL['Product out of stock'] = '';
$_LANGMAIL['New return from order #%d - %s'] = '';
$_LANGMAIL['Message from %1$s %2$s'] = '';

?>

 

then just add/ modify your translations (shown in green as example), place file back, clear cache - and that's all - you should receive e-mails with appropriate subjects in your language ;)

<?php

global $_LANGMAIL;
$_LANGMAIL = array();
$_LANGMAIL['Welcome!'] = 'Velkommen';
$_LANGMAIL['Your order has been changed'] = 'Din ordre er blevet ændret';
$_LANGMAIL['Product available'] = 'Produkt til rådighed';
$_LANGMAIL['New order : #%d - %s'] = 'Ny ordre : #%d - %s';
$_LANGMAIL['Stock coverage'] = '';
$_LANGMAIL['Product out of stock'] = '';
$_LANGMAIL['New return from order #%d - %s'] = '';
$_LANGMAIL['Message from %1$s %2$s'] = '';

?>

 

 

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

  • 4 months later...

Prestashop Version 1.7.4.3 here,

trying to change subjects for emails as the original poster did.

In my installation, the folder themes/classic/mails/dk  (or en, fr, de, it, es in my case) does not contain a file called lang.php

In a fresh install, even the folder "mail" seens not to exist, I am a little confused myself. My current installation has the folder. But no .php file, only the actual email files themselves (.txt and .html files).

My shop has 5 languages so the easy solution as suggested earlier in this thread might not solve it for me.

I want to change email subjects for a few entries, like "order confirmation" and "shipped".

I went on to change the subjects through the translation feature in the backoffice (International - Translations).

It very cumbersome because first the language has to be selected, then the subject has to be found. So changing one subject in 5 languages makes you click a lot.

Order confirmation is part of email subjects, which seems to make sense. So this one worked. It did not work for "shipped", the entry simply does not exist. However in "email body" an entry exists, and when trying to edit the email body with this method, then I get the information that a subject for this email was not found in the database.

I found an instance of "Shipped" in backoffice translation, but that was not it. (what I found was in International - Translations, backoffice - admin - Orderscustomers - Feature, and there is a field called "Shipped" which can be changed, but it is not the email subject.)

I finally found the field I was looking for, to quickly and easily change some of the status names. I tested it, it also changes the subject of the email which is sent out.

In the database, table name (prefix_)order_state_lang

Change the content of the field "name". Done.

Thanks and best regards

 

Edited by sumsel
Found a solution. (see edit history)
Link to comment
Share on other sites

  • 2 years later...
On 11/23/2018 at 11:04 AM, sumsel said:

Prestashop Version 1.7.4.3 here,

trying to change subjects for emails as the original poster did.

In my installation, the folder themes/classic/mails/dk  (or en, fr, de, it, es in my case) does not contain a file called lang.php

In a fresh install, even the folder "mail" seens not to exist, I am a little confused myself. My current installation has the folder. But no .php file, only the actual email files themselves (.txt and .html files).

My shop has 5 languages so the easy solution as suggested earlier in this thread might not solve it for me.

I want to change email subjects for a few entries, like "order confirmation" and "shipped".

I went on to change the subjects through the translation feature in the backoffice (International - Translations).

It very cumbersome because first the language has to be selected, then the subject has to be found. So changing one subject in 5 languages makes you click a lot.

Order confirmation is part of email subjects, which seems to make sense. So this one worked. It did not work for "shipped", the entry simply does not exist. However in "email body" an entry exists, and when trying to edit the email body with this method, then I get the information that a subject for this email was not found in the database.

I found an instance of "Shipped" in backoffice translation, but that was not it. (what I found was in International - Translations, backoffice - admin - Orderscustomers - Feature, and there is a field called "Shipped" which can be changed, but it is not the email subject.)

I finally found the field I was looking for, to quickly and easily change some of the status names. I tested it, it also changes the subject of the email which is sent out.

In the database, table name (prefix_)order_state_lang

Change the content of the field "name". Done.

Thanks and best regards

 

What you did over there is alter the Statuses in BO for users too. You changed the Subject of the email, but you changed the status aswell.

So, what you did can be easily done from Parameters -> Orders -> Statuses.

What people are trying to find out is to:

- Change the subject of the email;

- Leave the BO status to be shown in the account and in BO as it should.

Example: Status in BO and in order is Shipped, but actual email message should be changed to: Your order has been shipped.

This is a 5 year + old bug that will still be a bug even long after.

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