2

in Magento 2 i extend the magento place order function \Magento\Sales\Model\Order but i did give the order id

public function afterPlace(\Magento\Sales\Model\Order $subject, $result){
    $this->logger->info($subject->getId());
    $this->logger->info($subject->getIncrementId());
    return $result;
}
3

Magento\Sales\Model\Service\OrderService

public function place(\Magento\Sales\Api\Data\OrderInterface $order)
{
    // transaction will be here
    //begin transaction
    try {
        $order->place();
        return $this->orderRepository->save($order);
        //commit
    } catch (\Exception $e) {
        throw $e;
        //rollback;
    }
}

It seems order place() is done before it's saved, so it explains why you can't get ID

You'd better change your after plugin to Magento\Sales\Model\Service\OrderService place() method, in the case you are using standard checkout

| improve this answer | |

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.