File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
app/code/Magento/Ups/Model Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -771,6 +771,22 @@ protected function _getBaseCurrencyRate($code)
771
771
return $ this ->_baseCurrencyRate ;
772
772
}
773
773
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
+
774
790
/**
775
791
* Prepare shipping rate result based on response
776
792
*
@@ -800,7 +816,6 @@ protected function _parseXmlResponse($xmlResponse)
800
816
) && !empty ($ negotiatedArr );
801
817
802
818
$ allowedCurrencies = $ this ->_currencyFactory ->create ()->getConfigAllowCurrencies ();
803
-
804
819
foreach ($ arr as $ shipElement ) {
805
820
$ code = (string )$ shipElement ->Service ->Code ;
806
821
if (in_array ($ code , $ allowedMethods )) {
@@ -812,7 +827,9 @@ protected function _parseXmlResponse($xmlResponse)
812
827
813
828
//convert price with Origin country currency code to base currency code
814
829
$ successConversion = true ;
815
- $ responseCurrencyCode = (string )$ shipElement ->TotalCharges ->CurrencyCode ;
830
+ $ responseCurrencyCode = $ this ->mapCurrencyCode (
831
+ (string )$ shipElement ->TotalCharges ->CurrencyCode
832
+ );
816
833
if ($ responseCurrencyCode ) {
817
834
if (in_array ($ responseCurrencyCode , $ allowedCurrencies )) {
818
835
$ cost = (double )$ cost * $ this ->_getBaseCurrencyRate ($ responseCurrencyCode );
You can’t perform that action at this time.
0 commit comments