Question

I am running Magento 2.2 and I want to get the order id on the success page.

$block->getOrderId() // returns 000000008 for example

I do not want 000000008, but the real ID from the database, like 11616. How could I do that on the success page?

Thanks!

Was it helpful?

Solution

you need to customize prepareBlockData in vendor/magento/module-checkout/Block/Onepage/Success.php .

Just need to change one line

'order_id'  => $order->getIncrementId()  to 'order_id'  => $order->getId()

Note: Recommended way to write files . Don't change core files, create block and override with < preference > in di.xml file.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top