Jump to content

Changing the email subject


Recommended Posts

Do anyone know how to change the subjects on the emails that are sent depending on order status? Such as "Shipped" or "Payment accepted" etc. I cannot find the translations in the mail directory, neither in the html/txt files or the lang files.

Anyone?

Link to comment
Share on other sites

Go to Orders > Statuses, edit each status, then click the flag next to the "Name" field.


rocky, do you or anybody else also know where to change the template for those customer messages which are sent from the order page in the BO? thought about contact.html in /mail but that did not do the trick here.

phil
Link to comment
Share on other sites

Go to the Orders > Order Messages tab.


been there but there is still some header added before the text I input under orders --> oder messages, and I want to edit that header (referring to something like 'Re your order number xx' and also a salutation like Hello which I would like to edit. So it must be a html/tpl or whatever file I guess which I need to edit then.
Link to comment
Share on other sites

  • 2 years later...

Hi Phil

 

Did you ever get this fixed? I too want to alter the 'Subject' headers of some of my system generated emails - for example, I want to alter the cancelled email so that it reads 'Cancelled', rather than 'Canceled'. I have found the .txt and .html files for the mails, but this only lets me alter the email body copy (not the subject line). I figured that this is held somewhere else - just can't find which file.

 

Any ideas?

 

Cheers, Ian

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

Hi,

 

My PrestaShop version is 1.6.0.8

 

The solution posted at #7 works but this means that to change the e-mail title for updating order statuses it's necessary to change the name of the status itself. I need to update the title of e-mail that is sent when the status is changed to Payment accepted to read: Your payment has been received by [name of the company]. It would be rather ridiculous to change the status to this long text in order to get the e-mail title working. Is there a way to get e-mail title different than the name of the order status?

Link to comment
Share on other sites

  • 5 months later...

Hi,

 

My PrestaShop version is 1.6.0.8

 

The solution posted at #7 works but this means that to change the e-mail title for updating order statuses it's necessary to change the name of the status itself. I need to update the title of e-mail that is sent when the status is changed to Payment accepted to read: Your payment has been received by [name of the company]. It would be rather ridiculous to change the status to this long text in order to get the e-mail title working. Is there a way to get e-mail title different than the name of the order status?

 

Hi Jacek Es,

 

Have you found a solution for your problem? I too want to change the email subject without changing the status itself.

 

I also found that this problem exists for many years... A desirable solution would be to change the email subject just like 'account' for example.

 

For now I am looking into the code for 'bankwire', 'payment' and 'shipped' to see if it can be hardcoded.

Link to comment
Share on other sites

You can change email in translations "email translations".

 

Good luck!

 

No, you did not read the question.

 

The question is about changing the email subject for statuses like 'payment', 'shipped', 'bankwire', etc. You can find these statuses via the Backend -> Orders -> Statuses.

 

The problem is, the only way to change the email subject is to change the status itself via Backend -> Orders -> Statuses. But I and others don't want that. What we want is:

  1. Keep the status as it is, so: "Payment received", "Shipped", "Awaiting bankwire".
  2. Send the email to the customer with email subject: "We have received your payment", "Your order has been shipped", "We are awaiting your bankwire".

 

This was never possible since 2011 or maybe even earlier.

Link to comment
Share on other sites

Which version are you using?

I have this problem for 1.6.0.13 and 1.5.4.1.

 

When you go to Backend -> Localization -> Translations -> Email templates, do you see this message at 'shipped': No Subject was found for shipped in the database.

Link to comment
Share on other sites

  • 2 years later...
  • 6 months later...
  • 2 years later...

This is a very good question. In fact, Prestashop should include a "Subject" field in the status form. It's a very simple improvement with a great benefit.

I implemented it in Prestashop 1.7.5.1.

Here's how I did it:

1.- Modify the database. Add a column to "order_state_lang" table. Name the column "email_subject". set it as varchar and not null.

2.- Edit /controllers/admin/AdminStatusesController.php and add a field to to the form. This is done by adding an array item in $this->fields_form, which is located in renderForm() method. This item should be inside the input array, as the rest of the form fields

 array(
    'type' => 'text',
    'label' => $this->trans('E-mail Subject', array(), 'Admin.Shopparameters.Feature'),
    'name' => 'email_subject',
    'lang' => true,
    'required' => false,
    'hint' => array(
    $this->trans('E-mail Subject (e.g. \'Your order has been shipped!\').', array(), 'Admin.Shopparameters.Help'),
    $this->trans('Invalid characters: numbers and', array(), 'Admin.Shopparameters.Help') . ' !<>,;?=+()@#"{}_$%:',
    ),
  ), 

3.- Add the field to the OrderState entity. Edit /classes/order/OrderState.php and add the following array entry to $definition['table']['fields']:

'email_subject' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => false, 'size' => 64),


4.- Finally, go to /classes/order/OrderHistory.php

Edit classes/order/OrderHistory.php. Inside method "sendEmail", replace:

SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`, o.`shipping_number`

With:

SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, osl.`email_subject` AS subject, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`, o.`shipping_number`


And inside the same method, look for this line:

$topic = $result['osname'];


And replace it with:

$topic = $result['subject'];

 

IMO, this should be a native functionality. Will be great if some core developer consider it for a future release.
 

Screen Shot 2020-05-14 at 11.00.52 PM.png

Edited by Mercader Virtual (see edit history)
  • Thanks 3
Link to comment
Share on other sites

  • 10 months later...
On 5/15/2020 at 7:59 AM, Mercader Virtual said:

This is a very good question. In fact, Prestashop should include a "Subject" field in the status form. It's a very simple improvement with a great benefit.

I implemented it in Prestashop 1.7.5.1.

Here's how I did it:

1.- Modify the database. Add a column to "order_state_lang" table. Name the column "email_subject". set it as varchar and not null.

2.- Edit /controllers/admin/AdminStatusesController.php and add a field to to the form. This is done by adding an array item in $this->fields_form, which is located in renderForm() method. This item should be inside the input array, as the rest of the form fields


 array(
    'type' => 'text',
    'label' => $this->trans('E-mail Subject', array(), 'Admin.Shopparameters.Feature'),
    'name' => 'email_subject',
    'lang' => true,
    'required' => false,
    'hint' => array(
    $this->trans('E-mail Subject (e.g. \'Your order has been shipped!\').', array(), 'Admin.Shopparameters.Help'),
    $this->trans('Invalid characters: numbers and', array(), 'Admin.Shopparameters.Help') . ' !<>,;?=+()@#"{}_$%:',
    ),
  ), 

3.- Add the field to the OrderState entity. Edit /classes/order/OrderState.php and add the following array entry to $definition['table']['fields']:


'email_subject' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => false, 'size' => 64),


4.- Finally, go to /classes/order/OrderHistory.php

Edit classes/order/OrderHistory.php. Inside method "sendEmail", replace:


SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`, o.`shipping_number`

With:


SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, osl.`email_subject` AS subject, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`, o.`shipping_number`


And inside the same method, look for this line:


$topic = $result['osname'];


And replace it with:


$topic = $result['subject'];

 

IMO, this should be a native functionality. Will be great if some core developer consider it for a future release.
 

Screen Shot 2020-05-14 at 11.00.52 PM.png

Hello, thank you for sharing your solution.
Question: do you know if the changes you indicated are lost every time there is an update of the PrestaShop version?

Link to comment
Share on other sites

  • 6 months later...
  • 4 weeks later...
On 5/15/2020 at 8:59 AM, Mercader Virtual said:

This is a very good question. In fact, Prestashop should include a "Subject" field in the status form. It's a very simple improvement with a great benefit.

I implemented it in Prestashop 1.7.5.1.

Here's how I did it:

1.- Modify the database. Add a column to "order_state_lang" table. Name the column "email_subject". set it as varchar and not null.

2.- Edit /controllers/admin/AdminStatusesController.php and add a field to to the form. This is done by adding an array item in $this->fields_form, which is located in renderForm() method. This item should be inside the input array, as the rest of the form fields

 array(
    'type' => 'text',
    'label' => $this->trans('E-mail Subject', array(), 'Admin.Shopparameters.Feature'),
    'name' => 'email_subject',
    'lang' => true,
    'required' => false,
    'hint' => array(
    $this->trans('E-mail Subject (e.g. \'Your order has been shipped!\').', array(), 'Admin.Shopparameters.Help'),
    $this->trans('Invalid characters: numbers and', array(), 'Admin.Shopparameters.Help') . ' !<>,;?=+()@#"{}_$%:',
    ),
  ), 

3.- Add the field to the OrderState entity. Edit /classes/order/OrderState.php and add the following array entry to $definition['table']['fields']:

'email_subject' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => false, 'size' => 64),


4.- Finally, go to /classes/order/OrderHistory.php

Edit classes/order/OrderHistory.php. Inside method "sendEmail", replace:

SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`, o.`shipping_number`

With:

SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, osl.`email_subject` AS subject, c.`email`, os.`module_name`, os.`id_order_state`, os.`pdf_invoice`, os.`pdf_delivery`, o.`shipping_number`


And inside the same method, look for this line:

$topic = $result['osname'];


And replace it with:

$topic = $result['subject'];

 

IMO, this should be a native functionality. Will be great if some core developer consider it for a future release.
 

Screen Shot 2020-05-14 at 11.00.52 PM.png

I can confirm that this solution does not work in 1.7.6.9.

Notice on line 197 in file /home/XXXX/public_html/var/cache/dev/smarty/compile/fd/ed/90/fded90ccbbac3d2fc08cd6d590e5717e53c09ca6_0.file.form.tpl.php
[8] Undefined index: title

 

Edited by inowgsm
More information (see edit history)
Link to comment
Share on other sites

2 hours ago, inowgsm said:

I can confirm that this solution does not work in 1.7.6.9.

Notice on line 197 in file /home/XXXX/public_html/var/cache/dev/smarty/compile/fd/ed/90/fded90ccbbac3d2fc08cd6d590e5717e53c09ca6_0.file.form.tpl.php
[8] Undefined index: title

 

Prestashop 1.7.6.9 - Subject mail differs from order status.

In order for everybody to understand:

Code to add:

array(
    'type' => 'text',
    'label' => $this->trans('E-mail Subject', array(), 'Admin.Shopparameters.Feature'),
    'name' => 'email_subject',
    'lang' => true,
    'required' => false,
    'hint' => array(
    $this->trans('E-mail Subject (e.g. \'Your order has been shipped!\').', array(), 'Admin.Shopparameters.Help'),
    $this->trans('Invalid characters: numbers and', array(), 'Admin.Shopparameters.Help') . ' !<>,;?=+()@#"{}_$%:',
    ),
  ),

after: (controllers/admin/AdminStatusesController.php)

'input' => array(
                array(
                    'type' => 'text',
                    'label' => $this->trans('Status name', array(), 'Admin.Shopparameters.Feature'),
                    'name' => 'name',
                    'lang' => true,
                    'required' => true,
                    'hint' => array(
                        $this->trans('Order status (e.g. \'Pending\').', array(), 'Admin.Shopparameters.Help'),
                        $this->trans('Invalid characters: numbers and', array(), 'Admin.Shopparameters.Help') . ' !<>,;?=+()@#"{}_$%:',
                    ),
                ),

So that everybody is clear where to add the specific code.

Else, it works!

Minor bug: You cannot know if you have added an email subject without looking into MySQL. It does not pull the text from mysql, it will only add.

Edited by inowgsm
Additional info (see edit history)
Link to comment
Share on other sites

Hi all,

its so funny.

"Not all subjects can be changed in translation, they can be changed in order statuses"

I already ask for "best praxis" to find any "string" to change it.
I hope I get there any answer. Could be there is no "best praxis".

For newbies (me) its more a "needle in a haystack" - game.

yours,
Daniel

Link to comment
Share on other sites

3 hours ago, danielsaar said:

Hi all,

its so funny.

"Not all subjects can be changed in translation, they can be changed in order statuses"

I already ask for "best praxis" to find any "string" to change it.
I hope I get there any answer. Could be there is no "best praxis".

For newbies (me) its more a "needle in a haystack" - game.

yours,
Daniel

Well, Prestashop does not care. If it did, there won't be as many bug reports..

It is down to business on modules.

After all, Wordpress does the same. Look at how many features are PAID on Wordpress and free on Prestashop.

Link to comment
Share on other sites

Hi apollux,

I understand the complexity of the problem.

On the end, we find html-code in the browser.

Perhaps it would help to assign a new attribute to a html-tag.

The attribute a non-developer can find in the console (ok, when he have to know what a "console" is )
translation="backend seetings" or
translation="in international->translation"
..
Probably I need to check the code-files (.tpl etc) and search whether there is a special kind of code
to know, the translation is a setting in the module or I should search in BO Menu-point "international".

yours,
Daniel

Link to comment
Share on other sites

7 minutes ago, danielsaar said:

Hi apollux,

I understand the complexity of the problem.

On the end, we find html-code in the browser.

Perhaps it would help to assign a new attribute to a html-tag.

The attribute a non-developer can find in the console (ok, when he have to know what a "console" is )
translation="backend seetings" or
translation="in international->translation"
..
Probably I need to check the code-files (.tpl etc) and search whether there is a special kind of code
to know, the translation is a setting in the module or I should search in BO Menu-point "international".

yours,
Daniel

Well, unfortunately, the above solution is the only one. Further more, it can work like this:

- Status: Shipped.

- Subject: Your order has been shipped!

In phpmyadmin you can edit the subject field and state: The order {order_name} has been shipped! - Because Prestashop by default doesn't let you use special chars... well, due to php :).

Link to comment
Share on other sites

  • 1 year later...

twelve years of people chasing the same problem... and prestashop does not fix this... incredible

 

On 4/25/2018 at 11:26 PM, chulien07 said:

hello. you may edit the file themes/(THEME YOU ARE USING HERE) /mails/en/lang.php

then edit your desired email subject there.

hi from the future, im editing that file this way, but it doesn't work for me

 

<?php

global $_LANGMAIL;
$_LANGMAIL = array();
$_LANGMAIL['The virtual product that you bought is available for download'] = '';
$_LANGMAIL['Virtual product to download'] = '';
$_LANGMAIL['Order confirmation'] = '';
$_LANGMAIL['New voucher regarding your order %s'] = '';
$_LANGMAIL['New voucher for your order %s'] = '';
$_LANGMAIL['Payment error'] = '';
$_LANGMAIL['Payment accepted'] = '';
$_LANGMAIL['Payment pending'] = '';
$_LANGMAIL['New price'] = '';
$_LANGMAIL['name of my state'] = 'new text i WhatsAppnt on the subject';

?>

how can i achieve this?

thanks

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