Skip to content

Commit c8c4e06

Browse files
#26107: Exception message on cart with no shipment items
1 parent 1091a30 commit c8c4e06

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $addres
8888
$quote = $this->quoteRepository->getActive($cartId);
8989
if ($quote->isVirtual()) {
9090
throw new NoSuchEntityException(
91-
__('Shipping address is not allowed on cart: cart contains no items for shipment.')
91+
__('The Cart includes virtual product(s) only, so a shipping address is not used.')
9292
);
9393
}
9494

app/code/Magento/QuoteGraphQl/Model/Cart/AssignShippingAddressToCart.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ public function execute(
4949
try {
5050
$this->shippingAddressManagement->assign($cart->getId(), $shippingAddress);
5151
} catch (NoSuchEntityException $e) {
52-
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
52+
if ($cart->getIsVirtual()) {
53+
throw new GraphQlNoSuchEntityException(
54+
__('Shipping address is not allowed on cart: cart contains no items for shipment.'),
55+
$e
56+
);
57+
} else {
58+
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
59+
}
5360
} catch (InputException $e) {
5461
throw new GraphQlInputException(__($e->getMessage()), $e);
5562
}

0 commit comments

Comments
 (0)