Skip to content

Commit

Permalink
MAGETWO-39842: REST call PUT: carts/mine/order or carts/:cartId/orde…
Browse files Browse the repository at this point in the history
…r throws exception when there is no item in cart
  • Loading branch information
Olexii Korshenko committed Jul 28, 2015
1 parent f94490e commit 2f26635
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/code/Magento/Quote/Model/QuoteManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Authorization\Model\UserContextInterface;
use Magento\Framework\Event\ManagerInterface as EventManager;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\StateException;
use Magento\Quote\Model\Quote as QuoteEntity;
use Magento\Quote\Model\Quote\Address\ToOrder as ToOrderConverter;
Expand Down Expand Up @@ -324,6 +325,11 @@ public function placeOrder($cartId, $agreements = null, PaymentInterface $paymen
}

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

if (null == $order) {
throw new LocalizedException(__('Cannot place order.'));
}

$this->checkoutSession->setLastQuoteId($quote->getId());
$this->checkoutSession->setLastSuccessQuoteId($quote->getId());
$this->checkoutSession->setLastOrderId($order->getId());
Expand All @@ -347,15 +353,15 @@ public function getCartForCustomer($customerId)
*
* @param Quote $quote
* @param array $orderData
* @return \Magento\Framework\Model\AbstractExtensibleModel|\Magento\Sales\Api\Data\OrderInterface|object|void
* @return \Magento\Framework\Model\AbstractExtensibleModel|\Magento\Sales\Api\Data\OrderInterface|object|null
* @throws \Exception
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function submit(QuoteEntity $quote, $orderData = [])
{
if (!$quote->getAllVisibleItems()) {
$quote->setIsActive(false);
return;
return null;
}

return $this->submitQuote($quote, $orderData);
Expand Down

0 comments on commit 2f26635

Please sign in to comment.