Menu
All plugins

Currency Switcher

Show every price on a page in the visitor’s own currency. A flag dropdown switches all marked prices at once, with no reload and no request to any rate service, and remembers the choice. Bookings and payments always stay in your base currency (GBP).

Version: 1.6.0 · Requires: PHP 7.4+. Bricks is needed only for the native elements. · Live demo · Rounding and rates demo · Selector variants and popup options

Installation

  1. Upload and activate the plugin. If you run an older currency switcher, deactivate it first so the two do not clash.
  2. Open Currency Switcher in the admin menu. Frankfurter is selected by default, so rates arrive with no setup. Tick the currencies to offer.
  3. Add the selector and your prices with the Bricks elements or the shortcodes below.

Bricks elements

  • Currency Price: amount from a custom or ACF field, a Bricks dynamic data tag, or a manual amount. Set the price type (holiday headline price or other amount) and an optional rounding override.
  • Currency Selector: flag and code pill or compact flag only, in three sizes.
  • Currency Converter: an amount box and currency list with the result beneath. Unrounded.
  • Exchange Rate Table: the rate actually used for every enabled currency, with its source.
  • Currency Information: the approximate-price note, shown once and only while a converted currency is selected.

Shortcodes

  • [nl_currency_switcher] selector (style pill or flag, size small, medium or large)
  • [nl_price amount="4499"] holiday headline price, always rounded up to 99 when converted
  • [nl_price amount="550" type="other"] deposit, supplement or fee: no 99 rule
  • [nl_price amount="4499" round="whole"] override the rounding for one price (none, whole, 10, 50, 100, up99)
  • [nl_price field="holiday_price"] price from a custom field on the current post
  • [nl_currency_converter], [nl_exchange_rates], [nl_currency_notice], [nl_rounding_examples]

For your own markup add data-nlcs-amount="4499" data-nlcs-type="holiday" to a dedicated price element.

Popup panel options

The dropdown panel can be trimmed per selector. Each Bricks Currency Selector has Heading, Search and Footer controls (Default, Show or Hide), and the shortcode takes the same as heading, search and footer set to yes or no, for example [nl_currency_switcher heading="no" search="no"]. Site-wide defaults live under Display in the settings. Search is shown automatically only when 8 or more currencies are offered, so a short list stays clean. The variants demo shows each combination.

Country detection

Optional and off by default. Turn it on under Display to preselect the visitor’s currency on their first visit. The browser makes one request to your own site (/wp-json/nlcs/v1/geo), which reads the country code Cloudflare adds to each request (CF-IPCountry) and maps it to a currency. No visitor data is sent to a third party and no IP address is stored.

  • It applies only if that currency is enabled and has a usable rate; otherwise the visitor stays on GBP.
  • The result is remembered in the browser, so it runs once. A currency the visitor chooses themselves always wins and is never overridden.
  • Pages stay fully cacheable: the server never varies the page by country. A brand-new visitor may see GBP for a moment before the switch, and search crawlers always see GBP.
  • It needs Cloudflare IP Geolocation switched on. Without the header, nothing happens. The status line under the setting shows whether the country header is being received.
  • Developers can adjust the mapping with the nlcs_geo_map filter or supply the country with nlcs_geo_country.
  • To retest, clear nlcs_currency_v1 and nlcs_geo_v1 in the browser’s local storage.

Exchange-rate providers

Provider Cost and key Refresh Notes
Frankfurter Free, no key Daily (ECB, about 16:00 CET on working days) The default. About 30 currencies; AED is not published.
Open Exchange Rates Free or paid plan, App ID Hourly on the free plan (about 1,000 requests a month) The free plan is USD-based; the plugin derives GBP rates itself and never assumes a paid feature.
Wise Wise API agreement, token Hourly Documented rates API only. Disabled until you confirm Wise’s terms permit showing its rates on your site.
Manual Free When you edit Rates you type. They never expire.

Choose a primary and an optional fallback. A refresh always comes from one provider; rates are never mixed. The refresh interval is never faster than the provider publishes, so Frankfurter polls daily even if hourly is chosen.

Credentials

Enter the App ID or token under Rate provider. It is stored encrypted with your site’s security salts, never shown again and never sent to visitors, or in HTML, JavaScript, REST output or logs. Alternatively define NLCS_OXR_APP_ID or NLCS_WISE_TOKEN in wp-config.php, which takes priority. Without the PHP sodium extension keys cannot be stored encrypted, so use the constants. Changing your salts makes saved keys unreadable.

Automatic refresh, fallback and stale protection

  1. One WP-Cron event refreshes at the effective interval. Use a real cron for exact timing.
  2. Each refresh is locked, validated (positive, finite, complete) and compared with the stored rates. A move above the anomaly threshold (15% by default) is held for you to Approve or Discard.
  3. If the primary fails, the fallback is tried. If both fail, nothing is overwritten and a retry is scheduled with backoff.
  4. Rates older than twice the interval show as stale in the admin. Older than the maximum age (72 hours by default) and visitors see GBP prices with a short explanation, never blank prices and never invented rates. Cached pages carry the same expiry.
  5. When rates move by at least 0.25%, supported page caches are cleared. Never on page views.

Always round up to 99

A converted holiday price is the smallest whole amount ending in 99 that is not lower than the converted price: 99 + 100 × max(0, ceil((x − 99) / 100)). The GBP source price is never changed. Order: convert, apply any adjustment (0% by default, shown separately), round, then format. All arithmetic is exact decimal, so 4,499.00 can never become 4,599.

Converted Shown Converted Shown
4,347.82 4,399 4,498.99 4,499
4,399.00 4,399 4,499.00 4,499
4,399.01 4,499 4,499.01 4,599
4,400.00 4,499 6,572.40 6,599

Headline prices and other amounts

Every price element is a holiday headline price unless you set type="other". Fees, supplements, deposits and small amounts use Other monetary values (no rounding by default). The 99 rule also skips headline amounts below the 99 rule minimum (250 by default), and is never applied to percentages, rate displays or the converter.

Methods and overrides

Choose a method for converted currencies (default Always round up to 99), for GBP (default No rounding) and for other amounts: Always round up to 99, No rounding, next whole unit, next 10, next 50, next 100. Each currency can override the default in the currency table, and one price can override everything with round="…".

Why converted prices are indicative

Bookings are charged in GBP. A converted figure is a guide based on a published rate at one moment, not a quote: your bank or card provider applies its own rate and fees. The note “Approximate price. All bookings are charged in GBP.” appears once (where you place it, or beside the first selector) and is announced once to screen readers when the currency changes. The text is configurable.

Verifying the rate in use

Under Currencies & rates each currency shows the provider rate, the adjustment, the rate used, the rounding method and a worked example for a £4,499 holiday. The status panel shows the active provider, source timestamp, last update and age. Visitors can see the same rates in the rate table.

Troubleshooting

  • Rates expired: run Test connection. 401 or 403 means a wrong key or a plan that does not allow the request; 429 means the allowance is used up.
  • A currency is unavailable: the provider does not publish it (Frankfurter and AED). Pick another provider or remove it.
  • Cannot reach the provider: the server must allow outbound HTTPS to api.frankfurter.dev, openexchangerates.org or api.wise.com.
  • Refresh never runs: WP-Cron is disabled or there is no traffic.
  • An update is waiting for review: a rate moved more than the threshold. Check it, then Approve or Discard.
  • Old prices after a change: your page cache is not one the plugin knows; hook nlcs_purge_page_cache.

Upgrading from 1.4

Settings are kept. The old provider becomes the primary provider, existing rates become the first snapshot, the old rate buffer becomes an explicit per-currency adjustment, and the GBP price stays unrounded.