Reputation: 615
I am using Magento 2.1.3. I want to get order id in guest checkout before success page. I have search on google and found some code like this.
$orderIncrementId = $this->checkoutSession->getLastRealOrderId();
Using chcekout seesion \Magento\Checkout\Model\Session object, I have try to get order id but it does not work. In magento 1.x , we can easily get order id from checkout session using same method. In magento 2.x we can not able to do this.
In magento 2.x How to get order id in guest checkout before success page ?
Any help would be appreciated.
Thanks
Upvotes: 0
Views: 8629
Reputation: 354
try these lines of code :
$this->checkoutSession->getQuote()->reserveOrderId();
$reservedOrderId = $this->checkoutSession->getQuote()->getReservedOrderId();
Upvotes: 12
Reputation: 615
$this->_checkoutSession->getQuote()->reserveOrderId();
$order = $this->_checkoutSession->getQuote()->getReservedOrderId();
Upvotes: -1