Skip to content

Commit

Permalink
ENGCOM-3257: Collect totals in placeOrder when no paymentMethod provi…
Browse files Browse the repository at this point in the history
…ded #18768
  • Loading branch information
sidolov authored Dec 10, 2018
2 parents c6c7821 + d85fcec commit 9e51141
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/code/Magento/Quote/Model/QuoteManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @param \Magento\Customer\Model\CustomerFactory $customerModelFactory
* @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory,
* @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
* @param StoreManagerInterface $storeManager
* @param \Magento\Checkout\Model\Session $checkoutSession
Expand Down Expand Up @@ -221,7 +221,7 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function createEmptyCart()
{
Expand All @@ -241,7 +241,7 @@ public function createEmptyCart()
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function createEmptyCartForCustomer($customerId)
{
Expand All @@ -257,7 +257,7 @@ public function createEmptyCartForCustomer($customerId)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function assignCustomer($cartId, $customerId, $storeId)
{
Expand Down Expand Up @@ -332,7 +332,7 @@ protected function createCustomerCart($customerId, $storeId)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
{
Expand All @@ -349,6 +349,8 @@ public function placeOrder($cartId, PaymentInterface $paymentMethod = null)

$data = $paymentMethod->getData();
$quote->getPayment()->importData($data);
} else {
$quote->collectTotals();
}

if ($quote->getCheckoutMethod() === self::METHOD_GUEST) {
Expand Down Expand Up @@ -379,7 +381,7 @@ public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
}

/**
* {@inheritdoc}
* @inheritdoc
*/
public function getCartForCustomer($customerId)
{
Expand All @@ -406,6 +408,8 @@ public function submit(QuoteEntity $quote, $orderData = [])
}

/**
* Convert quote items to order items for quote
*
* @param Quote $quote
* @return array
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ protected function setUp()
'setCustomerGroupId',
'assignCustomer',
'getPayment',
'collectTotals'
]);

$this->quoteAddressFactory = $this->createPartialMock(
Expand Down Expand Up @@ -687,6 +688,7 @@ public function testPlaceOrderIfCustomerIsGuest()
$service->expects($this->once())->method('submit')->willReturn($orderMock);

$this->quoteMock->expects($this->atLeastOnce())->method('getId')->willReturn($cartId);
$this->quoteMock->expects($this->once())->method('collectTotals')->willReturnSelf();

$orderMock->expects($this->atLeastOnce())->method('getId')->willReturn($orderId);
$orderMock->expects($this->atLeastOnce())->method('getIncrementId')->willReturn($orderIncrementId);
Expand Down

0 comments on commit 9e51141

Please sign in to comment.