

Buy and sell rates inside a regular paragraph, as a store page would show them.
Show your visitors today’s US dollar exchange rate in Costa Rican colones and convert prices between colones and dollars, with no API key, token or settings. Add a shortcode and the rate keeps itself up to date.
The rates are the reference exchange rate of the Central Bank of Costa Rica (BCCR), as published by the public API of Costa Rica’s Ministry of Finance (Ministerio de Hacienda). See “External services” below.
[WPTCR_TIPO_CAMBIO_VENTA].454.07.The example outputs use a buy rate of 448.98 and a sell rate of 454.07.
Buy rate (compra)
[WPTCR_TIPO_CAMBIO_COMPRA]
Output: 448.98
Sell rate (venta)
[WPTCR_TIPO_CAMBIO_VENTA]
Output: 454.07
Colones to dollars (uses the sell rate)
[WPTCR_CONVERTIR_COLONES_DOLARES monto="20000"]
Output: 44.05
Dollars to colones (uses the buy rate)
[WPTCR_CONVERTIR_DOLARES_COLONES monto="10"]
Output: 4489.80
If monto is omitted, 100 is used. The shortcodes print only the number, so you can add the currency symbol and any text around them, for example Venta: ₡[WPTCR_TIPO_CAMBIO_VENTA]. If the rate is not available or monto is not a valid amount, they print nothing.
Use these functions in your theme templates, and escape their output when you print it. The example outputs use the same rates as above.
wptcr_tipo_cambio( $tipo ) returns the rate as a number. $tipo is 'COMPRA' (the default) or 'VENTA', in any case.
<?php echo esc_html( wptcr_tipo_cambio( 'VENTA' ) ); ?>
Output: 454.07
wptcr_convertir_colones_dolares( $monto ) returns the amount in dollars, as a string with two decimals.
<?php echo esc_html( wptcr_convertir_colones_dolares( 25000 ) ); ?>
Output: 55.06
wptcr_convertir_dolares_colones( $monto ) returns the amount in colones, as a string with two decimals.
<?php echo esc_html( wptcr_convertir_dolares_colones( 100 ) ); ?>
Output: 44898.00
All of them return 0 if the rate is not available.
Muestra en su sitio el tipo de cambio de referencia del dólar (compra y venta) y convierte montos entre colones y dólares, sin configuración ni token. Los datos vienen de la API pública del Ministerio de Hacienda y se actualizan solos cada 4 horas. Si la API no responde, el sitio sigue mostrando el último valor válido.
Para empezar basta con agregar un bloque Shortcode con [WPTCR_TIPO_CAMBIO_COMPRA] o [WPTCR_TIPO_CAMBIO_VENTA]. Para convertir montos están [WPTCR_CONVERTIR_COLONES_DOLARES monto="20000"] y [WPTCR_CONVERTIR_DOLARES_COLONES monto="100"].
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.
https://api.hacienda.go.cr/indicadores/tc/dolar.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.