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
  • Loading branch information
cpartica authored Jul 10, 2020
2 parents 51866b2 + 5d24f19 commit dd10f7a
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 dd10f7a

Please sign in to comment.