Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
ENGCOM-5010: #646: Incorrect name of Selected Shipping Method #647
Browse files Browse the repository at this point in the history
  • Loading branch information
naydav authored May 1, 2019
2 parents 6661215 + 28e791a commit bcda0d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,26 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
/** @var Address $address */
$address = $value['model'];
$rates = $address->getAllShippingRates();
$carrierTitle = null;
$methodTitle = null;

if (count($rates) > 0) {
list($carrierCode, $methodCode) = explode('_', $address->getShippingMethod(), 2);

/** @var Rate $rate */
$rate = current($rates);
foreach ($rates as $rate) {
if ($rate->getCode() == $address->getShippingMethod()) {
$carrierTitle = $rate->getCarrierTitle();
$methodTitle = $rate->getMethodTitle();
break;
}
}

$data = [
'carrier_code' => $carrierCode,
'method_code' => $methodCode,
'carrier_title' => $rate->getCarrierTitle(),
'method_title' => $rate->getMethodTitle(),
'carrier_title' => $carrierTitle,
'method_title' => $methodTitle,
'amount' => [
'value' => $address->getShippingAmount(),
'currency' => $address->getQuote()->getQuoteCurrencyCode(),
Expand All @@ -54,8 +63,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
$data = [
'carrier_code' => null,
'method_code' => null,
'carrier_title' => null,
'method_title' => null,
'carrier_title' => $carrierTitle,
'method_title' => $methodTitle,
'amount' => null,
'base_amount' => null,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function testSetUpsShippingMethod(string $methodCode, string $methodTitle
self::assertEquals(self::CARRIER_TITLE, $shippingAddress['selected_shipping_method']['carrier_title']);

self::assertArrayHasKey('method_title', $shippingAddress['selected_shipping_method']);
self::assertEquals($methodTitle, $shippingAddress['selected_shipping_method']['method_title']);
}

/**
Expand Down Expand Up @@ -171,6 +172,7 @@ public function testSetUpsShippingMethodBasedOnCanadaAddress(string $methodCode,
self::assertEquals(self::CARRIER_TITLE, $shippingAddress['selected_shipping_method']['carrier_title']);

self::assertArrayHasKey('method_title', $shippingAddress['selected_shipping_method']);
self::assertEquals($methodTitle, $shippingAddress['selected_shipping_method']['method_title']);
}

/**
Expand Down

0 comments on commit bcda0d3

Please sign in to comment.