PrestaShop / PrestaShop

PrestaShop is the universal open-source software platform to build your e-commerce solution.
https://www.prestashop-project.org/
Other
8.09k stars 4.79k forks source link

Add more vars to status change email #13963

Open cedricfontaine opened 5 years ago

cedricfontaine commented 5 years ago

For coherence between email templates, it will be great if we could use delivery_firstname delivery_lastname invoice_firstname invoice_lastname in all email templates sent. Right now we could use those only in the order_conf template.

khouloudbelguith commented 5 years ago

Hi @cedricfontaine,

Thanks for your report. @marionf, @colinegin what do you think of his suggestion?

Thanks!

matks commented 5 years ago

We can do that, but if someone else needs to add a new variable, then we'll add to do it again.

What about we provide a hook to allow people to choose any variable they want ?

cedricfontaine commented 5 years ago

I like this option. It's ok for me.

jolelievre commented 5 years ago

Hi @cedricfontaine

I'm sorry I couldn't find any trace of the variables you mentioned in any templates.

Besides we can't add these variables in all templates, each mail is contextualized and the variables available in the template depends on the variables injecting in the call to Mail::send function (see https://devdocs.prestashop.com/1.7/development/mail/ for more detail).

So although in an order confirmation you can find variables about order, shipping delivery and so on.. It won't be available in a newsletter registration mail, for example. Which is why we can't add the injection of delivery_firstname in all templates, that wouldn't make sens.

However about your need to add new variables this is already possible, there are two hooks that allow you to change an email template variables, so if you change your email template and use the hooks you will be able to add your custom variables.

You can either use actionEmailSendBefore or sendMailAlterTemplateVars (the later seems more appropriate), be careful to only add variables on the template you are willing to customize. You can see these hooks in Mail::send function:

https://github.com/PrestaShop/PrestaShop/blob/913c4c84893373c9ef97da09b6c7ea93b10831e3/classes/Mail.php#L154 https://github.com/PrestaShop/PrestaShop/blob/913c4c84893373c9ef97da09b6c7ea93b10831e3/classes/Mail.php#L214

and they are documented in:

https://devdocs.prestashop.com/1.7/modules/concepts/hooks/list-of-hooks/

cedricfontaine commented 5 years ago

Hello @jolelievre,

Those variables are available only in order_conf in classes/PaymentModule.php but we would like to be able to use it in every step of the order life cycle. sendMailAlterTemplateVars seems to be a good alternative and I'll try to work with it.

jolelievre commented 5 years ago

Hi @cedricfontaine,

this could be a nice improvement, although it requires to modify every calls sending mails for an order, @colinegin what do you think?

hibatallahAouadni commented 3 years ago

Ping @PrestaShop/product-team friendly reminder :wink: could someone answer @jolelievre :slightly_smiling_face:

SmartPhoneLover commented 2 months ago

Any progress on this?