I am getting the order information using
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Api\OrderRepositoryInterface')->get($orderid);
Then I am iterating the $order to get the ordered item related info. How can I get the tracking number for those items as well?
<?php foreach ($order->getAllVisibleItems() as $item): ?>
// how to use $item to get tracking number
<?php?>
I came to this this solution but this didn't work and I don't want to iterate it $order->getTracksCollection()
as I am already in a loop of <?php foreach ($order->getAllVisibleItems() as $item): ?>
$tracksCollection = $order->getTracksCollection();
foreach ($tracksCollection->getItems() as $item) {
echo $track->getTrackNumber(); // Tracking number
}