cancel
Showing results for 
Search instead for 
Did you mean: 

How to dynamically add the current year to a Magento email template?

How to dynamically add the current year to a Magento email template?

I looked around but I couldn't find a straightforward answer that does not involve making changes to the pHTML files. I'm a newbie to Magento and would prefer the most straightforward method of adding the current year to my email templates. This is very easy to do in Email Service Platforms. Does Magento has a single variable for the current year that I can add to my template?

2 REPLIES 2

Re: How to dynamically add the current year to a Magento email template?

Hello @lorenzstru6724,

 

I have one solution. But I'm sure that will work for you or not. 

Use the following code where you want to display the current year in your HTML code. 

<script>document.write(new Date().getFullYear())</script>

I hope this solution helps you. If not, don't hesitate to contact us. 

If solved? click KUDOS and accept it as a solution. 

Thank you!

Re: How to dynamically add the current year to a Magento email template?

There is not an out of the box solution, but if you don't want to make program changes, the simplest way to include the current year is to create custom variable (System > Other Settings > Custom Variables.) and to insert it in your e-mail templates.

 

Yes it is not a 100% dynamic solution, so you will need to edit the variable once per year, but it is still better to do it in only 1 place.