Skip to content

Commit 2962ee6

Browse files
MAGETWO-97317: Price missing when adding product via API to previously emptied cart
- Add try catch for case if customer has address that doesn't exist.
1 parent 45c5c9b commit 2962ee6

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,12 @@ protected function _prepareCustomerQuote($quote)
594594
} else {
595595
$defaultShipping = $this->customerRepository->getById($customer->getId())->getDefaultShipping();
596596
if ($defaultShipping) {
597-
$shippingAddress = $this->addressRepository->getById($defaultShipping);
597+
try {
598+
$shippingAddress = $this->addressRepository->getById($defaultShipping);
599+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
600+
} catch (LocalizedException $e) {
601+
// no address
602+
}
598603
}
599604
}
600605
if (isset($shippingAddress)) {
@@ -623,7 +628,12 @@ protected function _prepareCustomerQuote($quote)
623628
} else {
624629
$defaultBilling = $this->customerRepository->getById($customer->getId())->getDefaultBilling();
625630
if ($defaultBilling) {
626-
$billingAddress = $this->addressRepository->getById($defaultBilling);
631+
try {
632+
$billingAddress = $this->addressRepository->getById($defaultBilling);
633+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
634+
} catch (LocalizedException $e) {
635+
// no address
636+
}
627637
}
628638
}
629639
if (isset($billingAddress)) {

0 commit comments

Comments
 (0)