3

In M1, our invoice email templates contained the store address:

{{config path='general/store_information/address'}}

In M2, this does not work, because store information / address is split into multiple fields.

Is there an easy way how to insert the store address into transactional emails? Best with only one variable instead of an entire variables section? I would prefer a one-fits-all approach; one email template for all countries.

2 Answers 2

3

This is from Magento development docs

The selection of available variables depends on which template you use as a basis. The template-specific variables are contained in a comment at the top of each template on the file system. (For example, look at app/code/Magento/Customer/view/frontend/email/account_new.html.

You can read more https://devdocs.magento.com/guides/v2.0/frontend-dev-guide/templates/template-email.html

So you can rewrite <Magento_Email_module_dir>/view/frontend/email/footer.html and add your variable.

I found that you can also add customer variables in backend. System>Custom Variables:

And one more information: I found on Marketing => email templates=> and load Footer (Magento/luma) and this template load address using:

<p class="address"> {{var store.getFormattedAddress()|raw}}  </p>

Uptate: for Magento 2.3.4:

<p class="address"> {{var store.formatted_address|raw}} </p>

Ref: https://github.com/magento/magento2/blob/2.3/app/design/frontend/Magento/luma/Magento_Email/email/footer.html

Migrating templates:

https://devdocs.magento.com/guides/v2.3/frontend-dev-guide/templates/template-email-migration.html

Or just switch to use legacy template in mail template table.

5
  • This does not print state/region.
    – Sejal Shah
    Sep 14, 2020 at 7:52
  • Please check update
    – BartZalas
    Sep 14, 2020 at 21:36
  • Thank you @BartZalas. I used <p class="address"> {{var store.getFormattedAddress()|raw}} </p> but it displays full region and not the region code. So I changed in renderer.php.
    – Sejal Shah
    Sep 15, 2020 at 6:35
  • If I use {{var store.getFormattedAddress()|raw}} and load the template in admin >> Marketing >> Email Templates, and set the same template in Content>> Configuration>>Transactional Emails >> Footer Template, the address is not printed. @BartZalas could you please help? magento.stackexchange.com/questions/322294/…
    – Sejal Shah
    Sep 15, 2020 at 11:24
  • Please read my update from yesterday, there is not get
    – BartZalas
    Sep 15, 2020 at 18:03
1
{{config path="general/store_information/street_line1"}} // Street Address

{{config path="general/store_information/street_line2"}} // Street Address Line 2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.