1. How to output the value of order custom field in template
To output data of custom field use the method getCustomField
. Example:
{{ order.getCustomField('some_code') }}
In example some_code
is symbolic code of custom field.
2. Error occurred while trying to output order field containing the date
It means the problem in case when you see the following error message:
Object of class DateTime could not be converted to string
The fact is that for output order (or customer) fields, which contain dates, to twig-template, it is required apply filter date
, to specify the format of date input.
Example:
{{ order.createdAt|date("d.m.Y") }}
3. Error occurred while trying to output field containing the date interval
It means the problem in case when you see an error message like:
Calling "m" property on a "DateInterval" object is not allowed
The fact is that for output fields, which contain date intervals, to twig-template, it is required apply filter date
, to specify the output format.
Example:
{{ period|date("%m") }}
A detailed description of the DateInterval output formats can be found at: http://php.net/manual/ru/dateinterval.format.php
4. How to output current date
To output current date use filter date
in the following way:
{{ "now"|date("d.m.Y") }}