I'm creating a custom module for order tracking in which i'm accepting order id from customer and using the order id i want to display the status of particular order.
Now I'm not getting the order status where it gets store.
I want the status of order using order id in frontend. Is there any way to get status of order in magento 2.
this is my controller where I get order id
<?php
namespace Codazon\AjaxCartPro\Controller\Customer;
class Trackorder extends \Magento\Framework\App\Action\Action {
protected $resultPageFactory;
protected $request;
/**
* Constructor
*
* @param \Magento\Framework\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
*/
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Magento\Framework\App\Request\Http $request,
\Magento\Framework\Registry $coreRegistry
)
{
$this->_coreRegistry = $coreRegistry;
$this->request = $request;
$this->resultPageFactory = $resultPageFactory;
parent::__construct($context);
}
/**
* Execute view action
*
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
$orderid = $this->request->getParam('orderID'); // all params
$this->registry->register('order_status', $orderStatus);
return $this->resultPageFactory->create();
}
}
I need whole process after this.
Best Answer
You need to inject
\Magento\Sales\Api\OrderRepositoryInterface
class to get order statusIn Your Block
Call function in your phtml