1

I've added one step in checkout after Review & payment step. Now i want to get last order id in this step. Can anyone help me?

Actually added the last step at the checkout page and that step I want to show just like checkout sucess page, but i dont know how to get the last order id at the my custom step in .html file

  • show us what you tried – Philipp Sander Dec 21 '18 at 10:49
  • last order id means previously placed order ID? – Keyur Shah Dec 21 '18 at 10:49
  • yes previously placed id – Rasik Miyani Dec 21 '18 at 10:52
1
   use Magento\Checkout\Model\Session as checkoutSession;

    /**
     * @var checkoutSession
     */
    private $checkoutSession;


    /**
     * @param checkoutSession $checkoutSession
     */
    public function __construct(
        checkoutSession $checkoutSession
    ) {
        $this->checkoutSession = $checkoutSession;
    }

Now you can use like,

$previousOrderId = $this->checkoutSession->getLastOrderId();
  • this will display the entity_id which is quite useless for the customer. – Philipp Sander Dec 21 '18 at 11:01
  • Actually i get the orderId in js adn that id bind into .html dynamic – Rasik Miyani Dec 21 '18 at 11:01
  • He did not mention which kind of id he wants @PhilippSander that's why I added getLastOrderId() – Keyur Shah Dec 21 '18 at 11:03
  • get the order id in JS means ? @RasikMiyani please update your exact requirenment otherwise someone will close your question , – Keyur Shah Dec 21 '18 at 11:04
  • Actually added the last step at the checkout page and that step i want to show just like checkout sucess page, but i dont know how to get the last order id at the my custom step in .html file – Rasik Miyani Dec 21 '18 at 11:24
0
\Magento\Checkout\Model\Session::getLastRealOrder

this method does what you want on PHP side

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.