Skip to content

Commit

Permalink
#26107: Exception message on cart with no shipment items
Browse files Browse the repository at this point in the history
  • Loading branch information
michalderlatka committed Jun 27, 2020
1 parent 1091a30 commit c8c4e06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Quote/Model/ShippingAddressManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $addres
$quote = $this->quoteRepository->getActive($cartId);
if ($quote->isVirtual()) {
throw new NoSuchEntityException(
__('Shipping address is not allowed on cart: cart contains no items for shipment.')
__('The Cart includes virtual product(s) only, so a shipping address is not used.')
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ public function execute(
try {
$this->shippingAddressManagement->assign($cart->getId(), $shippingAddress);
} catch (NoSuchEntityException $e) {
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
if ($cart->getIsVirtual()) {
throw new GraphQlNoSuchEntityException(
__('Shipping address is not allowed on cart: cart contains no items for shipment.'),
$e
);
} else {
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
}
} catch (InputException $e) {
throw new GraphQlInputException(__($e->getMessage()), $e);
}
Expand Down

0 comments on commit c8c4e06

Please sign in to comment.