Skip to content

Commit e5b0392

Browse files
authored
Merge pull request #3810 from magento-engcom/graphql-develop-prs
[EngCom] Public Pull Requests - GraphQL
2 parents 697978e + 20f85f1 commit e5b0392

File tree

7 files changed

+36
-6
lines changed

7 files changed

+36
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public function execute(QuoteAddress $address): array
4141
$addressData['model'] = $address;
4242

4343
$addressData = array_merge($addressData, [
44+
'address_id' => $address->getId(),
4445
'country' => [
4546
'code' => $address->getCountryId(),
4647
'label' => $address->getCountry()

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
9393
);
9494
}
9595
if (null === $customerAddressId) {
96+
$addressInput['country_id'] = $addressInput['country_code'] ?? '';
9697
$billingAddress = $this->addressModel->addData($addressInput);
9798
} else {
9899
$this->checkCustomerAccount->execute($context->getUserId(), $context->getUserType());

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
8787
);
8888
}
8989
if (null === $customerAddressId) {
90+
$addressInput['country_id'] = $addressInput['country_code'] ?? '';
9091
$shippingAddress = $this->addressModel->addData($addressInput);
9192
} else {
9293
$this->checkCustomerAccount->execute($context->getUserId(), $context->getUserType());

app/code/Magento/QuoteGraphQl/Model/Resolver/SetShippingMethodsOnCart.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
7272
if (!$shippingMethod['cart_address_id']) {
7373
throw new GraphQlInputException(__('Required parameter "cart_address_id" is missing'));
7474
}
75-
if (!$shippingMethod['shipping_carrier_code']) {
75+
if (!$shippingMethod['carrier_code']) {
7676
throw new GraphQlInputException(__('Required parameter "shipping_carrier_code" is missing'));
7777
}
78-
if (!$shippingMethod['shipping_method_code']) {
78+
if (!$shippingMethod['method_code']) {
7979
throw new GraphQlInputException(__('Required parameter "shipping_method_code" is missing'));
8080
}
8181

@@ -85,8 +85,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
8585
$this->setShippingMethodOnCart->execute(
8686
$cart,
8787
$shippingMethod['cart_address_id'],
88-
$shippingMethod['shipping_carrier_code'],
89-
$shippingMethod['shipping_method_code']
88+
$shippingMethod['carrier_code'],
89+
$shippingMethod['method_code']
9090
);
9191

9292
return [

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ type Cart {
128128
}
129129

130130
type CartAddress {
131+
address_id: Int
131132
firstname: String
132133
lastname: String
133134
company: String

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ public function testSetNewBillingAddressByGuest()
8888
city
8989
postcode
9090
telephone
91+
country {
92+
code
93+
label
94+
}
9195
}
9296
}
9397
}
@@ -140,6 +144,10 @@ public function testSetNewBillingAddressWithUseForShippingParameterByGuest()
140144
city
141145
postcode
142146
telephone
147+
country {
148+
code
149+
label
150+
}
143151
}
144152
shipping_addresses {
145153
firstname
@@ -149,6 +157,10 @@ public function testSetNewBillingAddressWithUseForShippingParameterByGuest()
149157
city
150158
postcode
151159
telephone
160+
country {
161+
code
162+
label
163+
}
152164
}
153165
}
154166
}
@@ -234,6 +246,10 @@ public function testSetNewBillingAddressByRegisteredCustomer()
234246
city
235247
postcode
236248
telephone
249+
country {
250+
code
251+
label
252+
}
237253
}
238254
}
239255
}
@@ -413,7 +429,8 @@ private function assertNewAddressFields(array $billingAddressResponse): void
413429
['response_field' => 'street', 'expected_value' => [0 => 'test street 1', 1 => 'test street 2']],
414430
['response_field' => 'city', 'expected_value' => 'test city'],
415431
['response_field' => 'postcode', 'expected_value' => '887766'],
416-
['response_field' => 'telephone', 'expected_value' => '88776655']
432+
['response_field' => 'telephone', 'expected_value' => '88776655'],
433+
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
417434
];
418435

419436
$this->assertResponseFields($billingAddressResponse, $assertionMap);

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ public function testSetNewShippingAddressByGuest()
9090
city
9191
postcode
9292
telephone
93+
country {
94+
code
95+
label
96+
}
9397
}
9498
}
9599
}
@@ -176,6 +180,10 @@ public function testSetNewShippingAddressByRegisteredCustomer()
176180
city
177181
postcode
178182
telephone
183+
country {
184+
label
185+
code
186+
}
179187
}
180188
}
181189
}
@@ -462,7 +470,8 @@ private function assertNewShippingAddressFields(array $shippingAddressResponse):
462470
['response_field' => 'street', 'expected_value' => [0 => 'test street 1', 1 => 'test street 2']],
463471
['response_field' => 'city', 'expected_value' => 'test city'],
464472
['response_field' => 'postcode', 'expected_value' => '887766'],
465-
['response_field' => 'telephone', 'expected_value' => '88776655']
473+
['response_field' => 'telephone', 'expected_value' => '88776655'],
474+
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
466475
];
467476

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

0 commit comments

Comments
 (0)