Skip to content

Commit bfa0278

Browse files
author
Vitaliy Boyko
committed
graphQl-891: refactored the customer notes field in the shipping address
1 parent db43c11 commit bfa0278

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 {
@@ -210,17 +211,18 @@ interface CartAddressInterface @typeResolver(class: "\\Magento\\QuoteGraphQl\\Mo
210211
postcode: String
211212
country: CartAddressCountry
212213
telephone: String
213-
customer_notes: String
214214
}
215215

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

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

226228
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)