You are here

protected function ExchangerProviderRemoteBase::crossSyncCalculate in Commerce Exchanger 8

Rates calculation for currencies when we use cross sync conversion.

Parameters

\Drupal\commerce_exchanger\ExchangerProviderRates $exchange_rates: The ExchangeRates.

Return value

array Return data prepared for saving.

1 call to ExchangerProviderRemoteBase::crossSyncCalculate()
ExchangerProviderRemoteBase::importCrossSync in src/Plugin/Commerce/ExchangerProvider/ExchangerProviderRemoteBase.php
Preform cross conversion between currencies to build exchange data rates.

File

src/Plugin/Commerce/ExchangerProvider/ExchangerProviderRemoteBase.php, line 164

Class

ExchangerProviderRemoteBase
Base class for Commerce exchanger provider plugins.

Namespace

Drupal\commerce_exchanger\Plugin\Commerce\ExchangerProvider

Code

protected function crossSyncCalculate(ExchangerProviderRates $exchange_rates) {
  $calculated_rates = [];

  // Enabled currency.
  $currencies = $this->currencies;
  foreach ($currencies as $currency_code => $name) {
    $calculate_rates = $this
      ->recalculateRates($currency_code, $exchange_rates);
    $map_rates = $this
      ->mapExchangeRates($calculate_rates);
    $calculated_rates[$currency_code] = $map_rates[$currency_code];
  }
  return $calculated_rates;
}