1

(magento 2.0.10) My Orders->Order Shipments->Track this shipment->after click.

Invalid method Magento\Framework\View\Element\Template::formatDeliveryDateTime(Array
(
    [0] => 2016-11-22
    [1] => 13:20:00
)
)
0 /usr/local/nginx/html/vendor/magento/module-shipping/view/frontend/templates/tracking/details.phtml(80): Magento\Framework\DataObject->__call('formatDeliveryD...', Array)
1 /usr/local/nginx/html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include('/usr/local/ngin...')
2 /usr/local/nginx/html/vendor/magento/framework/View/Element/Template.php(255): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Framework\View\Element\Template), '/usr/local/ngin...', Array)
3 /usr/local/nginx/html/vendor/magento/framework/View/Element/Template.php(279): Magento\Framework\View\Element\Template->fetchView('/usr/local/ngin...')
4 /usr/local/nginx/html/vendor/magento/framework/View/Element/AbstractBlock.php(657): Magento\Framework\View\Element\Template->_toHtml()
5 /usr/local/nginx/html/vendor/magento/framework/View/Layout.php(542): Magento\Framework\View\Element\AbstractBlock->toHtml()

Can you help me? I am a beginner(Green hand), please give me answer in detail.

Thanks.

3

2 Answers 2

1

This is a Magento 2 bug.

If you look for function formatDeliveryDateTime inside file vendor/magento/module-shipping/view/frontend/templates/tracking/details.phtml whose block is \Magento\Framework\View\Element\Template

Use below block function

$blockObj = $block->getLayout()->createBlock('Magento\Shipping\Block\Tracking\Popup');

Replace :

echo $block->formatDeliveryDateTime($track->getDeliverydate(), $track->getDeliverytime());

By

echo $blockObj->formatDeliveryDateTime($track->getDeliverydate(), $track->getDeliverytime());
0

It looks like you can't access the block for some reason. In a pinch, you could try accessing the class directly.

In vendor/magento/module-shipping/view/frontend/templates/tracking/details.phtml, around line 80:

<?php /* @noEscape */ echo $block->formatDeliveryDateTime($track->getDeliverydate(), $track->getDeliverytime()); ?>

Replace with:

<?php /* @noEscape */ echo \Magento\Shipping\Block\Tracking::formatDeliveryDateTime($track->getDeliverydate(), $track->getDeliverytime()); ?>

This is NOT the ideal solution here but should make it work until you figure it out.

1
  • class is wrong . use - Magento\Shipping\Block\Tracking\Popup Nov 29, 2017 at 11:20

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.