Override subject in mail template

  • Posts: 15
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
3 years 2 months ago #328138

-- HikaShop version -- : 4.2.2
-- Joomla version -- : 3.9.21
-- PHP version -- : 7.2.31

Hi,

Using system>>Emails, one is able to override the content of the emails sent to customers.
We added a status (devis) for sending ProForma invoices to customers (asking for subventions). Hence, in the back-office we set some orders from created to "Devis". At that time an Email is sent to the customers based on the "Order status notification" template. This particular template allows to adjust the content based on the status value (per status override). That's great. However I did not find a way to override the mail's subject "per status". Is it possible ?

In this particular case, the mail subject should not be "your order status has been modified" since it's not yet an order. More, it is true for most of the status modification (canceled, shipped, etc...). Would be great to be able to change the mail's subject regarding the status notification nature.

Any suggestion ?

Thanks

Laurent p/o Grégoire Vitry

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
3 years 2 months ago #328148

Hi,

In the per status override you can add such PHP code to override the subject:

<?php $data->mail->subject = 'The subject I want for this specific status'; ?>

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
3 years 2 months ago #328257

Hi,

Thanks for your answer but I can't make it working. Editing the mail in "system", there are Two box "Main information" and "Sender information". The fist one contains the subject with a language constant.
Below there are three text edition area "Html Version", "Text Version" and "Preload". The first two ones are for the content of the message as far as I understand. Can't put your code there. And the last one is to preload variables used in the content templates....
Where should I put this code ? Should the subject language constant be considered as a default value ?

Thanks for your answer

Laurent

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
3 years 2 months ago #328264

Hi,

No, you can't put that code in the subject input field.
As I said, you need to add it to a "per status override". And there is no such override for the subject input field anyways.
So you need to add it either to the HTML per status override or the preload per status override via the corresponding "per status override" button.

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
3 years 2 months ago #328275

Hi,

I'm sorry but I'm able to change the content of the mail but never the subject is modified whatever I do and wherever I put the code. The standard subject text is always sent.

Are you sure it's possible ?

Thanks

Laurent

Please Log in or Create an account to join the conversation.

  • Posts: 4491
  • Thank you received: 609
  • MODERATOR
3 years 2 months ago #328285

Hello,

Sorry for this question, but how do you process your test to see if the subject override works ?
Be specific in your answer please, help us to understand you with step by step, screenshot, and precisely the code you have added.

Awaiting these elements to be able to progress on your subject.
Regards

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
3 years 2 months ago #328309

Hello,

Reading my first post and the others :
I understand and successfully sent an overridden specific mail to the customer when the status is changed from created to "devis" on the backend.
As far as the override concerns the body (content) of the mail.

Here how I do :

System-->emails
Edit mail #4 on my system : Order status notification
In the main block named "HTML VERSION", I click on the "Per status override" button
I select the status "devis" and I change what ever I want to change in the edit area in the popup
Save the popup and save the email.
Then I go to the customer order set it back to "created" to reset his order and modifiy it again to "devis" and click on "notify customer".
The mail is sent and received with the modified content as expected.

So everything works perfectly as far as it concerns the mail's body.

I've tried to add the code given by Nicolas in the HTML VERSION block (per status override->devis popup) either at the beginning or at the end with no success (with or without the <?php ?> tags depends if I put it inside some already php lines or at the HTML level).
Also I tried on he preload version block (per status override->devis popup of course). but no success.

The mail is sent with always the same subject. The one indicated in the "Main Information" block by the language constant "ORDER_STATUS_NOTIFICATION_SUBJECT"

Are you able to alter the mail's subject while modifying the order status to created to , saying, "Pending" using this method ? If yes where do you put the code exactly ? Should I remove the content of the EMAIL SUBJECT in the MAIN INFORMATION block ?...

I'm using Hikashop over years now. I did some custom works on view and created some plugin (zoom registration, GoCardLess Prélèvement Payment plugin, etc...). So I think, I understand what I'm doing. I could make a mistake or misunderstand what it needs to be done. But I'd like to be sure it could be done. Did you try successfully ?

Regards,

Laurent

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
3 years 2 months ago #328490

Hi,

My bad, the code should actually be:

<?php $mail->subject = 'The subject I want for this specific status'; ?>
I had to run some tests and do some debugging to figure out what was missing.
Regarding were you put that code, as I already explained, you need to add it in the popup you get when you click on the per status override button of the preload section of the email.
I successfully tested this new code and can confirm it works when you change the status of the order in the backend.

Please Log in or Create an account to join the conversation.

Time to create page: 0.065 seconds
Powered by Kunena Forum