Skip to content

Commit c223484

Browse files
Merge forwardport of #11458 to 2.3-develop branch
Applied pull request patch https://github.com/magento/magento2/pull/11458.patch (created by @peterjaap) based on commit(s): 1. 80ed833 2. 24d6a57 3. a19eeb2 4. 846f117 Fixed GitHub Issues in 2.3-develop branch: - #2991: Products added to cart with REST API give total prices equal to zero (reported by @degaray)
2 parents 26f3109 + e60ecdf commit c223484

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ public function createEmptyCart()
232232
$quote->setShippingAddress($this->quoteAddressFactory->create());
233233

234234
try {
235+
$quote->getShippingAddress()->setCollectShippingRates(true);
235236
$this->quoteRepository->save($quote);
236237
} catch (\Exception $e) {
237238
throw new CouldNotSaveException(__('Cannot create quote'));

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,15 @@ public function testCreateEmptyCartAnonymous()
246246
$quoteId = 2311;
247247

248248
$quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
249-
250-
$quoteAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class);
249+
$quoteAddress = $this->createPartialMock(
250+
\Magento\Quote\Model\Quote\Address::class,
251+
['setCollectShippingRates']
252+
);
253+
$quoteAddress->expects($this->once())->method('setCollectShippingRates')->with(true);
251254

252255
$quoteMock->expects($this->any())->method('setBillingAddress')->with($quoteAddress)->willReturnSelf();
253256
$quoteMock->expects($this->any())->method('setShippingAddress')->with($quoteAddress)->willReturnSelf();
257+
$quoteMock->expects($this->any())->method('getShippingAddress')->willReturn($quoteAddress);
254258

255259
$this->quoteAddressFactory->expects($this->any())->method('create')->willReturn($quoteAddress);
256260

0 commit comments

Comments
 (0)