How to add item status for an order in magento 2
-
02-03-2021 - |
Question
I have multiple items in my order. How can I add item status and its tracking information for that order in My Account
Orders?
I am using this to get orders
$_orders = $block->getOrders();
And for order status I do
$_order->getStatusLabel();
How to get the item status
and its tracking information.
Like I have to show the
1) item status
which I have hardcoded right now as Shipped
and
2) item tracking
information.
I have found Item.php
which have this function
public function getStatus()
{
return $this->getStatusName($this->getStatusId());
}
Is this php class ? How can I call this function in my phtml?
Solution
You can get the status of each individual item using the following:
foreach ($_order->getAllItems() as $item) {
echo $item->getStatus();
}
OTHER TIPS
Please change
$_order->getStatusLabel();
to
$_order->getStatus();
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange