Skip to content

Commit 59a52d6

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-53795' into MPI-BUGFIXES
2 parents 2d4be23 + 15986b5 commit 59a52d6

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

app/code/Magento/Ups/Model/Carrier.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,22 @@ protected function _getBaseCurrencyRate($code)
771771
return $this->_baseCurrencyRate;
772772
}
773773

774+
/**
775+
* Map currency alias to currency code
776+
*
777+
* @param string $code
778+
* @return string
779+
*/
780+
private function mapCurrencyCode($code)
781+
{
782+
$currencyMapping = [
783+
'RMB' => 'CNY',
784+
'CNH' => 'CNY'
785+
];
786+
787+
return isset($currencyMapping[$code]) ? $currencyMapping[$code] : $code;
788+
}
789+
774790
/**
775791
* Prepare shipping rate result based on response
776792
*
@@ -800,7 +816,6 @@ protected function _parseXmlResponse($xmlResponse)
800816
) && !empty($negotiatedArr);
801817

802818
$allowedCurrencies = $this->_currencyFactory->create()->getConfigAllowCurrencies();
803-
804819
foreach ($arr as $shipElement) {
805820
$code = (string)$shipElement->Service->Code;
806821
if (in_array($code, $allowedMethods)) {
@@ -812,7 +827,9 @@ protected function _parseXmlResponse($xmlResponse)
812827

813828
//convert price with Origin country currency code to base currency code
814829
$successConversion = true;
815-
$responseCurrencyCode = (string)$shipElement->TotalCharges->CurrencyCode;
830+
$responseCurrencyCode = $this->mapCurrencyCode(
831+
(string)$shipElement->TotalCharges->CurrencyCode
832+
);
816833
if ($responseCurrencyCode) {
817834
if (in_array($responseCurrencyCode, $allowedCurrencies)) {
818835
$cost = (double)$cost * $this->_getBaseCurrencyRate($responseCurrencyCode);

0 commit comments

Comments
 (0)