BACK TO DIRECTORY

Tipo de Cambio Costa Rica

by Ariel Orozco

0.0
(0 ratings)

This plugin shows the current reference exchange rate of the US dollar in Costa Rican colones (buy and sell rates) and converts amounts between colones and dollars. You can use it in any post or page with shortcodes, or in your theme templates with PHP functions.

The rates come from the public API of Costa Rica’s Ministry of Finance (Ministerio de Hacienda), which publishes the reference exchange rate of the Central Bank of Costa Rica (BCCR). No API key or token is needed. See “External services” below.

The rate is updated automatically every 4 hours in the background (WP-Cron). Your pages never wait for the API: they show the last rate that was obtained successfully.

Shortcodes

Buy exchange rate (compra): [WPTCR_TIPO_CAMBIO_COMPRA]

Sell exchange rate (venta): [WPTCR_TIPO_CAMBIO_VENTA]

Colones to dollars (uses the sell rate): [WPTCR_CONVERTIR_COLONES_DOLARES monto=20000]

Dollars to colones (uses the buy rate): [WPTCR_CONVERTIR_DOLARES_COLONES monto=200]

If monto is omitted, 100 is used. If the rate is not available or monto is not a valid amount, the shortcodes print nothing.

PHP functions for your theme

To get the exchange rate:

<?php echo esc_html( wptcr_tipo_cambio( 'COMPRA' ) ); ?>
<?php echo esc_html( wptcr_tipo_cambio( 'VENTA' ) ); ?>

To convert a value:

<?php echo esc_html( wptcr_convertir_colones_dolares( 25000 ) ); ?>
<?php echo esc_html( wptcr_convertir_dolares_colones( 100 ) ); ?>

wptcr_tipo_cambio() returns a number. The conversion functions return a string with two decimals. All of them return `0` if the rate is not available.

External services

This plugin connects to the public API of the Ministerio de Hacienda (Ministry of Finance) of Costa Rica to get the reference exchange rate of the US dollar (buy and sell rates). The plugin needs this service to show the exchange rate.

  • Service: API of the Ministerio de Hacienda, endpoint https://api.hacienda.go.cr/indicadores/tc/dolar.
  • When: every 4 hours from WP-Cron, and once when a page needs the rate and no rate has been stored yet (for example, right after installing the plugin).
  • Data sent: a plain HTTP GET request with no parameters. It does not include personal data, cookies or any content or URL of your site. The request identifies itself with the User-Agent TipoDeCambioCR/<plugin version> (+https://wordpress.org/plugins/tipo-de-cambio-costa-rica/). As with any HTTP request, the API receives the IP address of your server.
  • Usage policies and limits of the API: https://api.hacienda.go.cr/docs/
  • Privacy policy of the Ministerio de Hacienda (Directriz DM-009-2021): https://www.hacienda.go.cr/docs/PoliticadePrivacidadDirectrizN.DM-009-2021.pdf

Plugin Details

Active Installs
10
Total Downloads
3,484
Version
2.0.0
Requires WP
6.0
Requires PHP
7.4
Tested Up To
7.1.4
Added
2017-02-17
Last Updated
2026-10-31 9:40pm GMT

Ratings

5
0
4
0
3
0
2
0
1
0