Hi; it was working prior to latest update like 2 weeks ago.
I tried even version 8, 10, 11
I gett this error in logs
The website encountered an unexpected error. Please try again later.
InvalidArgumentException: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 201 of core/lib/Drupal/Component/Datetime/DateTimePlus.php).
Drupal\Core\Datetime\DateFormatter->format(NULL, 'short') (Line: 72)
__TwigTemplate_9291fc326d4111f1be20f990d1554cb77826efedc57dcb106e7a36433d109333->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array, Array) (Line: 43)
__TwigTemplate_ad4381e1888de763bc02b1b8b1deade59cdb5786c4dc6818bcca4145ec7898d1->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('modules/contrib/commerce/modules/order/templates/commerce-order-receipt--entity-print.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('commerce_order_receipt__entity_print', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 446)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array) (Line: 479)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 55)
__TwigTemplate_d7d4f9008ddb7c3aa8159d87b442dd98c795f4696b4225ee6ce896bbfa0c2347->doDisplay(Array, Array) (Line: 405)
Twig\Template->displayWithErrorHandling(Array, Array) (Line: 378)
Twig\Template->display(Array) (Line: 390)
Twig\Template->render(Array) (Line: 55)
twig_render_template('modules/contrib/entity_print/templates/entity-print.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('entity_print', Array) (Line: 433)
Drupal\Core\Render\Renderer->doRender(Array, 1) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, 1) (Line: 90)
Drupal\entity_print\Renderer\RendererBase->Drupal\entity_print\Renderer\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 91)
Drupal\entity_print\Renderer\RendererBase->generateHtml(Array, Array, 1, 1) (Line: 132)
Drupal\entity_print\PrintBuilder->prepareRenderer(Array, Object, 1) (Line: 56)
Drupal\entity_print\PrintBuilder->deliverPrintable(Array, Object, , 1) (Line: 91)
Drupal\entity_print\Controller\EntityPrintController->Drupal\entity_print\Controller\{closure}() (Line: 112)
Symfony\Component\HttpFoundation\StreamedResponse->sendContent() (Line: 381)
Symfony\Component\HttpFoundation\Response->send() (Line: 92)
Drupal\entity_print\Controller\EntityPrintController->viewPrint('pdf', 'commerce_order', '1122')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 713)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Comments
Comment #2
rottenmango commentedafter further investigation, this line gave me error in the commerce twig
{# /* Date Of Invoice: {{ order_entity.getCompletedTime|format_date('short') }} */ #}
i commented it out but we need the date of the invoice
Comment #3
larowlanThis looks to be related to commerce order, specifically code in the commerce order file.
That could should probably be wrapped in
{% if order_entity.getCompletedTime %}Comment #4
rottenmango commentedI changed the code from
{{ order_entity.getCompletedTime|format_date('short') }}
to
{{ order_entity.getPlacedTime|format_date('short') }}
and it works to print out the order pdf, but for cart pdf it does not work
I tried your code
Date Of Invoice: {% if order_entity.getCompletedTime %}
and i got an error
Comment #5
larowlanyeah you need to wrap it - so you need an else tag too.
Comment #6
rottenmango commentedcan you post a code?
{{ order_entity.getPlacedTime|format_date('short') }} works on printing the date in orders but in orders/carts it does not work the date is empty...do you have the code in that case?