Skip to content

Commit 9e51141

Browse files
authored
ENGCOM-3257: Collect totals in placeOrder when no paymentMethod provided #18768
2 parents c6c7821 + d85fcec commit 9e51141

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

app/code/Magento/Quote/Model/QuoteManagement.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class QuoteManagement implements \Magento\Quote\Api\CartManagementInterface
159159
* @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
160160
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
161161
* @param \Magento\Customer\Model\CustomerFactory $customerModelFactory
162-
* @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory,
162+
* @param \Magento\Quote\Model\Quote\AddressFactory $quoteAddressFactory
163163
* @param \Magento\Framework\Api\DataObjectHelper $dataObjectHelper
164164
* @param StoreManagerInterface $storeManager
165165
* @param \Magento\Checkout\Model\Session $checkoutSession
@@ -221,7 +221,7 @@ public function __construct(
221221
}
222222

223223
/**
224-
* {@inheritdoc}
224+
* @inheritdoc
225225
*/
226226
public function createEmptyCart()
227227
{
@@ -241,7 +241,7 @@ public function createEmptyCart()
241241
}
242242

243243
/**
244-
* {@inheritdoc}
244+
* @inheritdoc
245245
*/
246246
public function createEmptyCartForCustomer($customerId)
247247
{
@@ -257,7 +257,7 @@ public function createEmptyCartForCustomer($customerId)
257257
}
258258

259259
/**
260-
* {@inheritdoc}
260+
* @inheritdoc
261261
*/
262262
public function assignCustomer($cartId, $customerId, $storeId)
263263
{
@@ -332,7 +332,7 @@ protected function createCustomerCart($customerId, $storeId)
332332
}
333333

334334
/**
335-
* {@inheritdoc}
335+
* @inheritdoc
336336
*/
337337
public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
338338
{
@@ -349,6 +349,8 @@ public function placeOrder($cartId, PaymentInterface $paymentMethod = null)
349349

350350
$data = $paymentMethod->getData();
351351
$quote->getPayment()->importData($data);
352+
} else {
353+
$quote->collectTotals();
352354
}
353355

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

381383
/**
382-
* {@inheritdoc}
384+
* @inheritdoc
383385
*/
384386
public function getCartForCustomer($customerId)
385387
{
@@ -406,6 +408,8 @@ public function submit(QuoteEntity $quote, $orderData = [])
406408
}
407409

408410
/**
411+
* Convert quote items to order items for quote
412+
*
409413
* @param Quote $quote
410414
* @return array
411415
*/

app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ protected function setUp()
188188
'setCustomerGroupId',
189189
'assignCustomer',
190190
'getPayment',
191+
'collectTotals'
191192
]);
192193

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

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

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

0 commit comments

Comments
 (0)