Skip to content

Commit

Permalink
ENGCOM-7796: #26107: Exception message on cart with no shipment items #…
Browse files Browse the repository at this point in the history
…28904

 - Merge Pull Request #28904 from michalderlatka/magento2:26107_virtual_product_exception_message
 - Merged commits:
   1. 1091a30
   2. c8c4e06
   3. 77bd613
  • Loading branch information
magento-engcom-team committed Jul 8, 2020
2 parents 735579d + 77bd613 commit 5d24f19
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Magento\Quote\Model\ShippingAddressManagementInterface;

/**
* Assign shipping address to cart
* Assigning shipping address to cart
*/
class AssignShippingAddressToCart
{
Expand Down 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
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
public function testSetNewShippingAddressOnCartWithVirtualProduct()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('The Cart includes virtual product(s) only, so a shipping address is not used.');
$this->expectExceptionMessage('Shipping address is not allowed on cart: cart contains no items for shipment.');

$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
public function testSetNewShippingAddressOnCartWithVirtualProduct()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('The Cart includes virtual product(s) only, so a shipping address is not used.');
$this->expectExceptionMessage('Shipping address is not allowed on cart: cart contains no items for shipment.');

$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');

Expand Down

0 comments on commit 5d24f19

Please sign in to comment.