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 fieldsarray( '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.
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