A WooCommerce currency integration should make one bounded server-side request, reuse the result, and fail back to the store currency. It should not call an upstream API once for every product card or expose a secret in browser JavaScript.
Key points
Use
wp_remote_get on the server and keep the key in WordPress configuration.Cache a successful response with a transient instead of fetching per product.
Return the original store currency when the upstream rate is unavailable.
Treat the converted display as indicative unless the payment gateway supplies the quote.
Create a cached server-side conversion helper
Use the result as a labelled reference display
Add the estimate beside the normal WooCommerce price instead of replacing the canonical store price. That keeps taxes, coupons, refunds, and gateway settlement attached to WooCommerce’s own money model.
Production checklist
- Define
EXCHANGERATE_API_KEYoutside the theme and repository. - Validate the supported currency allowlist before building the upstream URL.
- Cache by pair; multiply locally for catalogue display amounts.
- Preserve the original store currency when the rate is unavailable.
- Escape rendered output and make the “estimated” label visible.
Float is for the display example only
For booked orders, refunds, accounting, or settlement, use WooCommerce money primitives and decimal-safe arithmetic. Keep the full-precision rate beside the recorded amount.
ER
exchangerate.dev
Practical integration guides for developers working with currency data.
