Get order id (not increment id) on success page?
-
13-02-2021 - |
Pergunta
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!
Solução
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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange