Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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