Skip to content

Commit 91d8a92

Browse files
committed
magento/graphql-ce#646: Incorrect name of Selected Shipping Method
1 parent 93a8162 commit 91d8a92

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,26 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
3030
/** @var Address $address */
3131
$address = $value['model'];
3232
$rates = $address->getAllShippingRates();
33+
$carrierTitle = null;
34+
$methodTitle = null;
3335

3436
if (count($rates) > 0) {
3537
list($carrierCode, $methodCode) = explode('_', $address->getShippingMethod(), 2);
38+
3639
/** @var Rate $rate */
37-
$rate = current($rates);
40+
foreach ($rates as $rate) {
41+
if ($rate->getCode() == $address->getShippingMethod()) {
42+
$carrierTitle = $rate->getCarrierTitle();
43+
$methodTitle = $rate->getMethodTitle();
44+
break;
45+
}
46+
}
3847

3948
$data = [
4049
'carrier_code' => $carrierCode,
4150
'method_code' => $methodCode,
42-
'carrier_title' => $rate->getCarrierTitle(),
43-
'method_title' => $rate->getMethodTitle(),
51+
'carrier_title' => $carrierTitle,
52+
'method_title' => $methodTitle,
4453
'amount' => [
4554
'value' => $address->getShippingAmount(),
4655
'currency' => $address->getQuote()->getQuoteCurrencyCode(),
@@ -54,8 +63,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
5463
$data = [
5564
'carrier_code' => null,
5665
'method_code' => null,
57-
'carrier_title' => null,
58-
'method_title' => null,
66+
'carrier_title' => $carrierTitle,
67+
'method_title' => $methodTitle,
5968
'amount' => null,
6069
'base_amount' => null,
6170
];

0 commit comments

Comments
 (0)