- Issue created by @kopeboy
- 🇭🇷Croatia valic Osijek
If you create a manual exchange rate, let's say, with machine name
example
,you then get the configuration file which is exported and named
commerce_exchanger.latest_exchange_rates.example.ymlLet's say you manually defined the relationship on creation between HRK and EUR currency.
The above YML configuration file then have contents as shown here:rates: EUR: HRK: value: 7.5345 sync: 1 HRK: EUR: value: 0.1327 sync: 1
Programmatically you can modify these by using the config service.
Alter ratio EUR / HRK from 7.5345 to 1000 would look something like this:
$rates = \Drupal::configFactory()->getEditable('commerce_exchanger.latest_exchange_rates.example'); $rates->set('EUR', ['HRK' => ['value' => 1000, 'sync' => 1]]); $rates->save();
But as well you can use UI in Drupal to alter values.
If you have an external rate source, I would suggest creating a plugin.
Usually, this boils down to a few lines of code (see examples in the main module or readme) - Status changed to Closed: outdated
7 months ago 8:54pm 1 May 2024 - 🇭🇷Croatia valic Osijek
#2 is no longer applicable, from version 2 we don't use any more Drupal configuration to store exchange rates.
Now it's dedicated database table `commerce_exchanger_latest_rates`
See 3366705 🐛 Latest exchange rates shouldn't be saved in config Fixed
You can use https://git.drupalcode.org/project/commerce_exchanger/-/blob/2.0.x/src/E... for storing and retrieving data.