Skip to content

Commit bf8eb47

Browse files
MAGETWO-81994: Products added to cart with REST API give total prices equal to zero #11458
2 parents 26c1f7b + 8252f45 commit bf8eb47

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

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

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

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ class QuoteManagementTest extends \PHPUnit\Framework\TestCase
131131
*/
132132
private $addressRepositoryMock;
133133

134+
/**
135+
* @var \PHPUnit_Framework_MockObject_MockObject
136+
*/
137+
private $quoteFactoryMock;
138+
134139
/**
135140
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
136141
*/
@@ -241,10 +246,15 @@ public function testCreateEmptyCartAnonymous()
241246

242247
$quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
243248

244-
$quoteAddress = $this->createMock(\Magento\Quote\Model\Quote\Address::class);
249+
$quoteAddress = $this->getMockBuilder(\Magento\Quote\Model\Quote\Address::class)
250+
->disableOriginalConstructor()
251+
->setMethods(['setCollectShippingRates'])
252+
->getMock();
245253

246254
$quoteMock->expects($this->any())->method('setBillingAddress')->with($quoteAddress)->willReturnSelf();
247255
$quoteMock->expects($this->any())->method('setShippingAddress')->with($quoteAddress)->willReturnSelf();
256+
$quoteMock->expects($this->any())->method('getShippingAddress')->willReturn($quoteAddress);
257+
$quoteAddress->expects($this->once())->method('setCollectShippingRates')->with(true);
248258

249259
$this->quoteAddressFactory->expects($this->any())->method('create')->willReturn($quoteAddress);
250260

0 commit comments

Comments
 (0)