From 80ed8330926834840848330dc55f40b41b740bd5 Mon Sep 17 00:00:00 2001 From: peterjaap Date: Sat, 14 Oct 2017 12:38:24 +0200 Subject: [PATCH 1/3] Added fix for issue 2991 to fetch billing and shipping addresses to enable getting a correct price through the (web) API after adding a product to an empty cart --- app/code/Magento/Quote/Model/QuoteManagement.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php index 49206ff924f13..6089e6b670513 100644 --- a/app/code/Magento/Quote/Model/QuoteManagement.php +++ b/app/code/Magento/Quote/Model/QuoteManagement.php @@ -232,6 +232,8 @@ public function createEmptyCart() $quote->setShippingAddress($this->quoteAddressFactory->create()); try { + $quote->getBillingAddress(); + $quote->getShippingAddress()->setCollectShippingRates(true); $this->quoteRepository->save($quote); } catch (\Exception $e) { throw new CouldNotSaveException(__('Cannot create quote')); From 24d6a578c7825b491cae179c9597b0476ee282bc Mon Sep 17 00:00:00 2001 From: peterjaap Date: Sat, 14 Oct 2017 12:38:24 +0200 Subject: [PATCH 2/3] Added fix for issue 2991 to fetch billing and shipping addresses to enable getting a correct price through the (web) API after adding a product to an empty cart --- app/code/Magento/Quote/Model/QuoteManagement.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php index 49206ff924f13..9b88d102b733f 100644 --- a/app/code/Magento/Quote/Model/QuoteManagement.php +++ b/app/code/Magento/Quote/Model/QuoteManagement.php @@ -232,6 +232,9 @@ public function createEmptyCart() $quote->setShippingAddress($this->quoteAddressFactory->create()); try { + $quote->getBillingAddress()->setCollectShippingRates(true); + $quote->getShippingAddress()->setCollectShippingRates(true); + $this->quoteRepository->save($quote); } catch (\Exception $e) { throw new CouldNotSaveException(__('Cannot create quote')); From 846f117afded21fdea34fc0b11fc395f65d2da78 Mon Sep 17 00:00:00 2001 From: peterjaap Date: Sun, 15 Oct 2017 10:39:21 +0200 Subject: [PATCH 3/3] Removed setCollectShippingRates() on ShippingAddress because that method does not exist for a billing address. Also removed getBillingAddress() call because the empty address is already created 3 lines above. --- app/code/Magento/Quote/Model/QuoteManagement.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php index 9b88d102b733f..72c1942159016 100644 --- a/app/code/Magento/Quote/Model/QuoteManagement.php +++ b/app/code/Magento/Quote/Model/QuoteManagement.php @@ -232,7 +232,6 @@ public function createEmptyCart() $quote->setShippingAddress($this->quoteAddressFactory->create()); try { - $quote->getBillingAddress()->setCollectShippingRates(true); $quote->getShippingAddress()->setCollectShippingRates(true); $this->quoteRepository->save($quote);