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. Jan 3, 2019 at 14:04
  • Just tried it... No luck still. Also, why would it be added without the "$" by default using UI?
    – Greg
    Jan 3, 2019 at 14:23
  • $order.getCreatedAtFormatted(2) |raw This is the function already available in magento2 order templates 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.
    – Greg
    Jan 3, 2019 at 14:57
  • Would you like to post an answer so I can accept it?
    – Greg
    Jan 3, 2019 at 15:39

2 Answers 2

1

Use :

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

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)

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.