Skip to content

Commit b37b15d

Browse files
committed
Merge remote-tracking branch 'origin/MC-31277-PR' into MC-32120
2 parents c63046f + 35d0442 commit b37b15d

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/ShippingAddress/AvailableShippingMethods.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
5959
if (!isset($value['model'])) {
6060
throw new LocalizedException(__('"model" values should be specified'));
6161
}
62-
$address = $value['model'];
62+
$address = clone $value['model'];
63+
$address->setLimitCarrier(null);
6364

6465
// Allow shipping rates by setting country id for new addresses
6566
if (!$address->getCountryId() && $address->getCountryCode()) {

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected function setUp()
3939
}
4040

4141
/**
42+
* @magentoConfigFixture default_store carriers/freeshipping/active 1
4243
* @magentoApiDataFixture Magento/Customer/_files/customer.php
4344
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
4445
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
@@ -64,7 +65,17 @@ public function testSetShippingMethodOnCartWithSimpleProduct()
6465
self::assertCount(1, $response['setShippingMethodsOnCart']['cart']['shipping_addresses']);
6566

6667
$shippingAddress = current($response['setShippingMethodsOnCart']['cart']['shipping_addresses']);
68+
$availableShippingMethods = $shippingAddress['available_shipping_methods'];
69+
6770
self::assertArrayHasKey('selected_shipping_method', $shippingAddress);
71+
self::assertArrayHasKey('available_shipping_methods', $shippingAddress);
72+
73+
self::assertCount(2, $availableShippingMethods);
74+
self::assertEquals('freeshipping', $availableShippingMethods[0]['carrier_code']);
75+
self::assertEquals($carrierCode, $availableShippingMethods[1]['carrier_code']);
76+
77+
self::assertEquals($availableShippingMethods[0]['amount']['value'], 0);
78+
self::assertEquals($availableShippingMethods[1]['amount']['value'], 10);
6879

6980
self::assertArrayHasKey('carrier_code', $shippingAddress['selected_shipping_method']);
7081
self::assertEquals('flatrate', $shippingAddress['selected_shipping_method']['carrier_code']);
@@ -146,7 +157,7 @@ public function testSetShippingMethodWithWrongParameters(string $input, string $
146157
$query = <<<QUERY
147158
mutation {
148159
setShippingMethodsOnCart(input: {
149-
{$input}
160+
{$input}
150161
}) {
151162
cart {
152163
shipping_addresses {
@@ -237,7 +248,7 @@ public function testSetMultipleShippingMethods()
237248
$query = <<<QUERY
238249
mutation {
239250
setShippingMethodsOnCart(input: {
240-
cart_id: "{$maskedQuoteId}",
251+
cart_id: "{$maskedQuoteId}",
241252
shipping_methods: [
242253
{
243254
carrier_code: "flatrate"
@@ -329,9 +340,9 @@ private function getQuery(
329340
): string {
330341
return <<<QUERY
331342
mutation {
332-
setShippingMethodsOnCart(input:
343+
setShippingMethodsOnCart(input:
333344
{
334-
cart_id: "$maskedQuoteId",
345+
cart_id: "$maskedQuoteId",
335346
shipping_methods: [{
336347
carrier_code: "$shippingCarrierCode"
337348
method_code: "$shippingMethodCode"
@@ -349,6 +360,12 @@ private function getQuery(
349360
currency
350361
}
351362
}
363+
available_shipping_methods {
364+
amount{
365+
value
366+
}
367+
carrier_code
368+
}
352369
}
353370
}
354371
}

0 commit comments

Comments
 (0)