WPCS - WordPress Currency Switcher Professional

Currency switcher 'no data for' currency error: exchange rate fixes

When the currency switcher shows no data for a currency (no data for EUR, no data for CAD) after you press Update all rates, the plugin is passing on the answer of the exchange rate service it asked. The service had no rate for that pair, refused the request, or never answered. The same goes for the other messages that can appear in the rate fields. Below is where WPCS gets its rates, what each message means, why prices can drop to 0 after an update, and how to keep automatic updates within your API limits.

Where the exchange rates come from

Rates are fetched from the service selected in Settings → Currency Switcher → Options → Currency aggregator. The base currency is the one whose radio button is selected in the Currencies tab: it has the rate 1, and every request asks the service for the rate from the base currency to one other currency. One update sends one request per currency besides the base.

AggregatorNeeds a key in Aggregator API key
Currencyapi, Open exchange rates, Currencylayer, FixerYes
finance.yahoo.com, CryptoCompareNo
The European Central Bank (www.ecb.europa.eu), PrivatBank and the national banks of Ukraine, Poland, Moldova, Romania, Hungary and RussiaNo; each publishes a fixed list of currencies against its own currency

Rates are updated in three ways: the Update all rates button above the currency list, the small update button next to each rate field, and the Rate auto update option, which runs through WP-Cron. The two buttons only fill in the rate fields; nothing is stored until you click Save options.

What each rate message means

When the service does not return a number, the plugin writes its message into the rate field instead:

Message in the rate fieldMeaning
no data for XXXThe answer contained no rate for XXX: the code is not a valid currency code, the source does not publish that currency, or no usable answer arrived at all
There is no data for these currencies: USD/XXXThe same, from finance.yahoo.com
Invalid API key or no data for these currencies: USD/XXXCurrencyapi rejected the key or has no such pair
This aggregator requires a license codeThe selected aggregator needs a key and Aggregator API key is empty
Aggregator Error: followed by textThe service refused the request; the text after the colon is its own explanation

Currency switcher "no data for" a currency: check the code, the source and the connection

  1. The currency code. Rates are requested by the code in the currency's name field, so it must be the three-letter ISO 4217 code: EUR, not Euro or €. The FAQ why the rate auto update is not working links the list of valid codes.
  2. The source's coverage. The European Central Bank publishes about 30 currencies against the euro, and each national bank publishes its own list against its own currency. A currency missing from that list always returns no data, whatever the base currency. Crypto currencies such as BTC need CryptoCompare, a source made for them.
  3. The connection. The plugin cannot tell an empty answer from no answer. If every currency fails, try another aggregator and press Update all rates. If every source fails for every currency, your server cannot reach external services: a firewall blocking outgoing requests, a DNS or SSL problem, or a temporary outage. The Site Health screen under Tools reports when WordPress cannot reach WordPress.org, a sign that outgoing requests are blocked; the host can open them.

The quickest fix in most cases is another aggregator. We usually recommend Currencyapi: create a free key on its site, select it in Currency aggregator, paste the key into Aggregator API key, click Save options, then Update all rates and Save options again.

"This aggregator requires a license code" and "Aggregator Error"

Currencyapi, Open exchange rates, Currencylayer and Fixer work only with a key from their own site, entered in Aggregator API key. The field holds one key, so it must belong to the aggregator currently selected; a Fixer key does not work with Currencyapi.

With a key, the service can still refuse, and the reason follows Aggregator Error:. The three usual ones:

  • Invalid key. Copy it again from the service's dashboard, without spaces.
  • The plan does not allow your base currency. Free plans of several services work with a single base currency: Fixer's with EUR, those of Open Exchange Rates and Currencylayer with USD. If your base currency is different, every request fails. Check the current terms of your plan, or choose an aggregator whose plan accepts your base currency.
  • The monthly quota is used up. See the last section.

Prices became 0 after updating rates

This happens when an error message sat in a rate field and the settings were saved. The field is stored as a number, a message becomes 0, and every price in that currency converts to 0. Rates are not stored until you save, so:

  • If you have not saved yet, reload the settings page without saving and the previous rates come back.
  • If you already saved, type the correct rate into each affected field, or fix the aggregator and update again, then save.
  • The alert Request error! Try later or another agregator! means the answer to the update request could not be read, usually because a PHP warning or error was printed into it. No rate was changed; try again or switch the aggregator, and if it repeats, look at the PHP error log.

Automatic updates never store 0: when the source returns nothing for a currency, the cron job keeps its previous rate.

Rare or obsolete currencies: set the rate by hand

If no aggregator has data for a currency, type its rate (units of that currency per one unit of the base currency) into the rate field and save. Automatic updates leave this rate alone, because the source returns nothing for it, but they overwrite manual rates of currencies the source does know. To keep your own rates for every currency, set Rate auto update to no auto update. The interest field next to the rate adds a fixed amount on top of the rate on the site, and setting exchange rates in code covers rules such as adding a percentage.

Rates not updating automatically, or API requests running out

Rate auto update offers hourly, twicedaily (the default), daily, weekly and monthly. Each run sends one request per currency besides the base. With nine extra currencies that is about 540 requests a month on twicedaily, 270 on daily and under 40 on weekly, plus nine for every click on Update all rates. When requests run out faster than that, check two things:

  • An old schedule is still running. The plugin creates its WP-Cron event (wpcs_currencies_rate_auto_update) once, with the interval selected at that moment, and does not recreate it when you change the option. After switching from hourly to weekly the event keeps running hourly. Delete it, and the plugin creates a new one with the current interval on the next page load. With WP-CLI:
    wp cron event delete wpcs_currencies_rate_auto_update
    A cron manager plugin can delete the same event from the WordPress admin.
  • Another copy of the site uses the same key. A staging site or clone runs its own WP-Cron and spends the same quota. Give it its own key, or set its Rate auto update to no auto update.

If rates never update by themselves, WP-Cron is not running. It starts only when someone visits the site, so on a quiet site updates come late. When DISABLE_WP_CRON is set in wp-config.php, a server task must call wp-cron.php, as described in Hooking WP-Cron into the system task scheduler.

Checklist

  • Every currency uses its ISO 4217 code, and the base currency has the rate 1.
  • The selected aggregator publishes all your currencies, and its plan accepts your base currency.
  • Key-based aggregators have their own key in Aggregator API key.
  • After Update all rates every field shows a number before you click Save options.
  • The auto update interval matches your quota, and no old schedule or staging copy spends it.
  • After changing rates, the page cache is cleared so visitors get the new prices.

If rates still do not load, open a topic on the WPCS support forum with the aggregator you use, your base currency and the exact message from the rate field.