Skip to content

Commit 7bc9c31

Browse files
committed
Collect totals in placeOrder when no paymentMethod provided
Quote item values such as `base_original_price` are only populated during total collection. Currently in `QuoteManagement::placeOrder` if `$paymentMethod` is passed `Payment::importData` collects the quote totals to populate these values. Payment methods like Auth.net DirectPost do pass a value for `$paymentMethod` during order placement which causes order items to be converted with zero values for the `original_price` attributes. Fixes #16050
1 parent 7fc1ef6 commit 7bc9c31

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

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)