Skip to content

Commit 3b977c8

Browse files
authored
ENGCOM-5771: graphQl-891: refactored the customer notes field in the shipping address #901
2 parents 2457268 + f0d8d3f commit 3b977c8

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
5353
$customerAddressId = $shippingAddressInput['customer_address_id'] ?? null;
5454
$addressInput = $shippingAddressInput['address'] ?? null;
5555

56+
if ($addressInput) {
57+
$addressInput['customer_notes'] = $shippingAddressInput['customer_notes'] ?? '';
58+
}
59+
5660
if (null === $customerAddressId && null === $addressInput) {
5761
throw new GraphQlInputException(
5862
__('The shipping address must contain either "customer_address_id" or "address".')

app/code/Magento/QuoteGraphQl/etc/schema.graphqls

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ input SetShippingAddressesOnCartInput {
8585
input ShippingAddressInput {
8686
customer_address_id: Int # If provided then will be used address from address book
8787
address: CartAddressInput
88+
customer_notes: String
8889
}
8990

9091
input SetBillingAddressOnCartInput {
@@ -211,17 +212,18 @@ interface CartAddressInterface @typeResolver(class: "\\Magento\\QuoteGraphQl\\Mo
211212
postcode: String
212213
country: CartAddressCountry
213214
telephone: String
214-
customer_notes: String
215215
}
216216

217217
type ShippingCartAddress implements CartAddressInterface {
218218
available_shipping_methods: [AvailableShippingMethod] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\AvailableShippingMethods")
219219
selected_shipping_method: SelectedShippingMethod @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\SelectedShippingMethod")
220220
items_weight: Float
221221
cart_items: [CartItemQuantity]
222+
customer_notes: String
222223
}
223224

224225
type BillingCartAddress implements CartAddressInterface {
226+
customer_notes: String @deprecated (reason: "The field is used only in shipping address")
225227
}
226228

227229
type CartItemQuantity {

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
8484
telephone: "88776655"
8585
save_in_address_book: false
8686
}
87+
customer_notes: "Test note"
8788
}
8889
]
8990
}
@@ -102,6 +103,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
102103
code
103104
}
104105
__typename
106+
customer_notes
105107
}
106108
}
107109
}
@@ -671,7 +673,8 @@ private function assertNewShippingAddressFields(array $shippingAddressResponse):
671673
['response_field' => 'postcode', 'expected_value' => '887766'],
672674
['response_field' => 'telephone', 'expected_value' => '88776655'],
673675
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
674-
['response_field' => '__typename', 'expected_value' => 'ShippingCartAddress']
676+
['response_field' => '__typename', 'expected_value' => 'ShippingCartAddress'],
677+
['response_field' => 'customer_notes', 'expected_value' => 'Test note']
675678
];
676679

677680
$this->assertResponseFields($shippingAddressResponse, $assertionMap);

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
5555
telephone: "88776655"
5656
save_in_address_book: false
5757
}
58+
customer_notes: "Test note"
5859
}
5960
]
6061
}
@@ -73,6 +74,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
7374
label
7475
}
7576
__typename
77+
customer_notes
7678
}
7779
}
7880
}
@@ -527,7 +529,8 @@ private function assertNewShippingAddressFields(array $shippingAddressResponse):
527529
['response_field' => 'postcode', 'expected_value' => '887766'],
528530
['response_field' => 'telephone', 'expected_value' => '88776655'],
529531
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
530-
['response_field' => '__typename', 'expected_value' => 'ShippingCartAddress']
532+
['response_field' => '__typename', 'expected_value' => 'ShippingCartAddress'],
533+
['response_field' => 'customer_notes', 'expected_value' => 'Test note']
531534
];
532535

533536
$this->assertResponseFields($shippingAddressResponse, $assertionMap);

0 commit comments

Comments
 (0)