I have Magento 2.2 and the Track Order button is not working, when I open any order and I press Track Order button I have this error:

Shipment #000000013

Fatal error: Uncaught Error: Call to undefined method Magento\Framework\Phrase::getTracking() in /home/public_html/vendor/magento/module-shipping/view/frontend/templates/tracking/details.phtml:22 
Stack trace: #0 /home/public_html/vendor/magento/framework/View/TemplateEngine/Php.php(59): include() #1 /home/public_html/vendor/magento/framework/View/Element/Template.php(270): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Framework\View\Element\Template), '/home/public_ht...', Array) #2 /home/public_html/vendor/magento/framework/View/Element/Template.php(300): Magento\Framework\View\Element\Template->fetchView('/home/public_ht...') #3 /home/public_html/vendor/magento/framework/View/Element/AbstractBlock.php(667): Magento\Framework\View\Element\Template->_toHtml() #4 /home/public_html/vendor/magento/framework/View/Layout.php(558): Magento\Framework\View\Element\AbstractBlock->toHtml() #5 /home/public_html/vendor/magento/frame in /home/public_html/vendor/magento/module-shipping/view/frontend/templates/tracking/details.phtml on line 22

In that file details.phtml at the line 22 I have this code:

$number = is_object($track) ? $track->getTracking() : $track['number'];

How I can fix this?



Ussually, this error happens because of carrier getTracking() function is not returning the proper value.

You can fix this by modifying the shipping plugin's code located in app/code/<Plugin name>/<Carrier name>/Model/<carrier name>.php

Just remove the getTracking() function, instead use function getTrackingInfo(). Here is the defintion of the function, Just copy paste with necessary modifications.

public function getTrackingInfo($trackingNumber)
        $tracking = $this->_trackStatusFactory->create();

        $url = 'http://www.stamps.com/shipstatus/?confirmation=' . $trackingNumber; // this is the tracking URL of stamps.com, replace this with your's

            'carrier' => $this->_code,
            'carrier_title' => $this->getConfigData('title'),
            'tracking' => $trackingNumber,
            'url' => $url,
        return $tracking;
|improve this answer|||||

I think the fix is easy (vendor/magento/module-shipping/view/frontend/templates/tracking/details.phtml):

<table class="data table order tracking" id="tracking-table-popup-<?php /* @noEscape */ echo is_object($track) ? $track->getTracking() : null; ?>">

instead of

<table class="data table order tracking" id="tracking-table-popup-<?php /* @noEscape */ echo $track->getTracking(); ?>">
|improve this answer|||||
  • there I have this code: <table class="data table order tracking" id="tracking-table-popup-<?= /* @noEscape */ $number ?>"> – Robert May 23 '18 at 14:32
  • your code is not help me anymore – Robert May 23 '18 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.