File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed
app/code/Magento/QuoteGraphQl/Model/Cart
dev/tests/api-functional/testsuite/Magento/GraphQl/Quote Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change 1616use Magento \Quote \Model \ShippingAddressManagementInterface ;
1717
1818/**
19- * Assign shipping address to cart
19+ * Assigning shipping address to cart
2020 */
2121class AssignShippingAddressToCart
2222{
@@ -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 }
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
149149 public function testSetNewShippingAddressOnCartWithVirtualProduct ()
150150 {
151151 $ this ->expectException (\Exception::class);
152- $ this ->expectExceptionMessage ('The Cart includes virtual product(s) only, so a shipping address is not used . ' );
152+ $ this ->expectExceptionMessage ('Shipping address is not allowed on cart: cart contains no items for shipment . ' );
153153
154154 $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
155155
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
9797 public function testSetNewShippingAddressOnCartWithVirtualProduct ()
9898 {
9999 $ this ->expectException (\Exception::class);
100- $ this ->expectExceptionMessage ('The Cart includes virtual product(s) only, so a shipping address is not used . ' );
100+ $ this ->expectExceptionMessage ('Shipping address is not allowed on cart: cart contains no items for shipment . ' );
101101
102102 $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
103103
You can’t perform that action at this time.
0 commit comments