Currently we are working on Magento-2.2.6 website and on Porto theme.

I want to create one form to get the order details by entering the user email is and order id.

For this, we want to create one cms page and will be used as Track order.

We want to track the order without using any third party extensions.


In order, you need a block that you insert into your cms page: see below an example:

{{block class="Mbs\OrderStatus\Block\OrderDetail" template="Mbs_OrderStatus::order_form.phtml"}}

then in the template of the block, you may add a html form so that your web user can submit the order id for instance he wants to check. This form may post its data to a custom controller: you will need to add a route and a controller in your module. And you will be able to redirect to your cms page but this time with order data

below some code that will give you order status and order customer name

     * @var \Magento\Sales\Api\OrderRepositoryInterface
    private $orderRepositoryFactory;

    public function __construct(
        Template\Context $context,
        \Magento\Sales\Api\OrderRepositoryInterfaceFactory $orderRepositoryFactory,
        array $data = []
    ) {
        parent::__construct($context, $data);
        $this->orderRepositoryFactory = $orderRepositoryFactory;

    public function _toHtml()
        $orderRepository = $this->orderRepositoryFactory->create();
        $order = $orderRepository->get(8);

        $orderStatus = $order->getStatus();
        $customer = $order->getBillingAddress()->getFirstname().' '.$order->getBillingAddress()->getLastname();

        return 'status'.$orderStatus.'<br/>'.$customer;

this task if not simple if you are not a programmer. However, if you have html skills and know the fundamentals of Magento, you should be able to use the above.

Furthermore, if you wanted a sleek integration, yoou would likely want to use ajax rather than update the full page but I suspect the above may guide you for the time being. good luck

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.