3

In How to create order programmatically in Magento 2? it shows two methods on how to place a quote as an order. The first method uses

$order = $this->quoteManagement->submit($quote);

via \Magento\Quote\Model\QuoteManagement. This returns an \Magento\Sales\Model\Order object.

The second method is using

$cart = $this->cartRepositoryInterface->get($cart->getId());
$order_id = $this->cartManagementInterface->placeOrder($cart->getId());

This method uses both the \Magento\Quote\Api\CartRepositoryInterface $cartRepositoryInterface and the \Magento\Quote\Api\CartManagementInterface $cartManagementInterface.

Another approach I found is basically the first one, but using \Magento\Quote\Api\CartManagementInterface instead...

What are the differences between those approaches?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.