Frequently occurring problems false W3sidGl0bGUiOiJBdXRvbWF0aW9uIiwidXJsIjoiL2RldmVsb3BlcnMvYXV0b21hdGlvbi8ifSx7InRpdGxlIjoiVHdpZy10ZW1wbGF0ZXMiLCJ1cmwiOiIvZGV2ZWxvcGVycy9hdXRvbWF0aW9uL3R3aWcvIn1d Automation /developers/automation/ ["developers","Automation"] ["developers","Automation","Twig-templates"] developers

Frequently occurring problems

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 allowedHUGO_MIGRATION_LITERAL_3_TOKEN

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:

```php
{{ "now"|date("d.m.Y") }}
Thank you for your feedback.
Was this article helpful?
No
  • The recommendations did not help
  • There is no answer to my question
  • The text is difficult to understand
  • I do not like the described functionality
Yes
Previous article
Canceling of the template rendering
There can be situation when it is necessary to cancel the template generating. The article describes how to do this.