Skip to content

Commit

Permalink
fix wrong currency value
Browse files Browse the repository at this point in the history
  • Loading branch information
hgati authored Jan 28, 2024
1 parent 437b49d commit 4833ea2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Model/Currency/Import/FreeCurrencyApiConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@
use Magento\Directory\Model\CurrencyFactory;
use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Config\ScopeConfigInterface as ScopeConfig;
//use Magento\Framework\HTTP\ZendClient;
//use Magento\Framework\HTTP\ZendClientFactory;
use Laminas\Http\Client as HttpClient;;
use Laminas\Uri\Http as HttpUri;
use Magento\Framework\Encryption\EncryptorInterface;
use Exception;

/**
* currencyapi converter (currencyapi.net).
* currencyapi converter (currencyapi.com).
*/
class FreeCurrencyApiConverter extends \Magento\Directory\Model\Currency\Import\AbstractImport
{
Expand Down Expand Up @@ -125,7 +123,11 @@ private function convertBatch(array $data, string $currencyFrom, array $currenci
}

$response = $response['data'];

// $response = [
// 'AUD' => ['code' => 'AUD', 'value' => 2.0528424423 ],
// 'KRW' => ['code' => 'KRW', 'value' => 1324.0528424423 ],
// ...
// ];
foreach ($currenciesTo as $to) {
if ($currencyFrom === $to) {
$data[$currencyFrom][$to] = $this->_numberFormat(1);
Expand All @@ -136,7 +138,7 @@ private function convertBatch(array $data, string $currencyFrom, array $currenci
$data[$currencyFrom][$to] = null;
} else {
$data[$currencyFrom][$to] = $this->_numberFormat(
(double)$response[$to]
(double)$response[$to]['value']
);
}
}
Expand Down

0 comments on commit 4833ea2

Please sign in to comment.