:::: MENU ::::

Magento 2 current order

Magento 2 current order

In this tutorial, we talk about how to get Magento 2 current order. Which includes order information current order id, Increment Id and other order-related data too like shipping information, billing information, and customer information. Now we start with our example.

You have to inject the checkout model session to get the latest order information.

protected $_checkoutSession;

public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,

) {

        $this->_checkoutSession = $checkoutSession;


Now with $_checkoutSession obejct you can get order following information.

 $order = $this->_checkoutSession->getLastRealOrder();
 $orderId=$order->getEntityId();  // order id
 $order->getIncrementId();  // order increment id
 $order->getShippingMethod(); // shippingm ehtod
 $order->getPayment();   // payment method
 $order->getCustomerEmail(); // customer email
Author: Qaisar Satti
Category: Magento 2
Last Modified: February 4, 2020

So, what do you think ?

You must be logged in to post a comment.