How can I get the shipment tracking information from shipment or order object in magento2. Following ways doesn't work for me.



2 Answers 2


To get the shipping tracking numbers, use the following code.

$tracksCollection = $order->getTracksCollection();

foreach ($tracksCollection->getItems() as $track) {

     $trackNumbers[] = $track->getTrackNumber();


This will return an array of all shipment tracking numbers.


To get track collection object


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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