2

What is the email template system variable for "Order Created at" for Magento ver. 2.2.6?

Using the variable name: {{var order.getCreatedAtFormated('long')}} doesn't work for me. This is a variable applied using the Magento UI:

enter image description here

I looked into the devdocs and the is no variable for this: https://devdocs.magento.com/guides/v2.2/frontend-dev-guide/templates/template-email.html

In addition, why are the varibale names different from when you using Magento UI and when looking at the devdocs? E.g:

Getting billing address:

  1. Using UI: {{var order.getBillingAddress().format('html')}}
  2. Devdocs: {{var formattedBillingAddress|raw}}

NOTE: I had to use the devdocs variable names for it to work properly.

6
  • It is not order.getCreatedAtFormatted. It is $order.getCreatedAtFormatted. Notice the $ (dollar sign) before order object. Commented Jan 3, 2019 at 14:04
  • Just tried it... No luck still. Also, why would it be added without the "$" by default using UI? Commented Jan 3, 2019 at 14:23
  • $order.getCreatedAtFormatted(2) |raw This is the function already available in magento2 order templates Commented Jan 3, 2019 at 14:51
  • Whoopp. At the end this worked for me: {{var order.getCreatedAtFormatted(2)|raw}}. You helped anyway :) Thank you kindly. Commented Jan 3, 2019 at 14:57
  • Would you like to post an answer so I can accept it? Commented Jan 3, 2019 at 15:39

2 Answers 2

1

Use :

{{var order.getCreatedAtFormatted(2)|raw}} 
1

You can either set is_legacy column in email_template table to 1

or use {{var created_at_formatted}} variable instead (but it doesn't available for shipping, creditmemo and invoice emails)

The reason is that Magento\Framework\Filter\VariableResolverStrictResolver\StrictResolver doesn't provide handleObjectMethod() method (and Magento\Framework\Filter\VariableResolver\LegacyResolver does)

1
  • correct answer. {{var created_at_formatted |raw }} worked for me. Commented Sep 19, 2024 at 8:44

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.