The code in this article is to be considered a customisation. As such, it's outside the scope of our support service. Should you need assistance implementing the code, please feel free to contact us to request a consultation.


This article applies to Currency Switcher 4.x and later. Overriding the amount of decimals is not possible in earlier versions of the plugin.


The Currency Switcher does indeed cap the decimals used for exchange rates to four. This was chosen as a reasonable amount, as it covers almost every case. Starting from Currency Switcher 4.0, it's possible to override override the amount of decimals using a custom filter. The filter doesn't affect the decimals used by WooCommerce for its prices, only the FX rates used by the Currency Switcher.


Example - Setting the amount of decimals to six

<?php
/**
 * Alters the amount of decimals used to determine the exchange rate between a
 * base currency and a target currency.
 *
 * @param int decimals The amount of decimals.
 * @param string currency The target currency.
 * @param string base_currency The base currency.
 * @return int The amount of decimals to use.
 * @author Aelia <support@aelia.co>
 * @since Currency Switcher 4.0
 */
add_filter('wc_aelia_afc_exchange_rates_decimals', function($decimals, $currency, $base_currency) {
  // Override the amount of decimals to six
  return 6;
}, 10, 3);


You can purchase the Currency Switcher from our online shop.