Convert WooCommerce Prices to EUR with SiteLocaleAI
International shoppers expect to see prices in their local currency, and a smooth conversion can boost conversion rates. In this tutorial we’ll walk through a complete, self‑hosted solution for a WooCommerce store that:
- Detects a European visitor.
- Calls SiteLocaleAI’s JS library to translate the page and convert all product prices to EUR.
- Applies psychological rounding (e.g., €19.99 → €20).
- Generates SEO‑friendly pre‑rendered pages for Google and Bing.
1. Prerequisites
- A WordPress site with WooCommerce installed.
- Access to an LLM API key (Claude, GPT‑4o‑mini, etc.).
- A SiteLocaleAI account (any plan works; the Indie plan is $5/month).
- Basic knowledge of WordPress theme editing or a child theme.
2. Install the SiteLocaleAI WordPress plugin
SiteLocaleAI ships a lightweight plugin that enqueues the library without requiring Node.js. From the WordPress admin dashboard:
- Navigate to Plugins → Add New.
- Search for SiteLocaleAI.
- Click Install Now and then Activate.
The plugin adds a settings page under Settings → SiteLocaleAI. Enter your LLM API key and set the default target language to English (or any language you prefer). Save changes.
3. Enqueue the JS library and pass configuration
Add the following snippet to your child theme’s functions.php (or a custom plugin). This code loads the SiteLocaleAI script and injects a small configuration object that tells the library to target EUR for European IPs.
function mytheme_enqueue_sitelocaleai() {
// Load the SiteLocaleAI library from the plugin folder
wp_enqueue_script(
'sitelocaleai-js',
plugins_url('js/sitelocaleai.min.js', __FILE__),
[],
null,
true
);
// Pass configuration to the script
$config = [
'apiKey' => 'YOUR_LLM_API_KEY',
'targetLang' => 'en', // keep English text, only change numbers
'currency' => [
'default' => 'USD',
'override' => [
// List of country codes that should see EUR
'AT' => 'EUR', // Austria
'BE' => 'EUR', // Belgium
'CY' => 'EUR', // Cyprus
'EE' => 'EUR', // Estonia
'FI' => 'EUR', // Finland
'FR' => 'EUR', // France
'DE' => 'EUR', // Germany
'GR' => 'EUR', // Greece
'IE' => 'EUR', // Ireland
'IT' => 'EUR', // Italy
'LV' => 'EUR', // Latvia
'LT' => 'EUR', // Lithuania
'LU' => 'EUR', // Luxembourg
'MT' => 'EUR', // Malta
'NL' => 'EUR', // Netherlands
'PT' => 'EUR', // Portugal
'SK' => 'EUR', // Slovakia
'SI' => 'EUR', // Slovenia
'ES' => 'EUR', // Spain
],
],
'rounding' => [
'strategy' => 'psychological', // e.g., 19.99 → 20
],
];
wp_localize_script('sitelocaleai-js', 'siteLocaleConfig', $config);
}
add_action('wp_enqueue_scripts', 'mytheme_enqueue_sitelocaleai');
Tip: Replace
YOUR_LLM_API_KEYwith the key you stored in the plugin settings. Thewp_localize_scriptcall makes the configuration available as a globalsiteLocaleConfigobject.
4. Initialise SiteLocaleAI on the front‑end
Create a small JavaScript file (e.g., sitelocale-init.js) in your theme’s js folder and enqueue it after the library. This script tells SiteLocaleAI to run on every page load, detect the visitor’s location, and convert price elements.
document.addEventListener('DOMContentLoaded', function () {
// Ensure the library is loaded
if (typeof SiteLocaleAI === 'undefined') return;
// Initialise with the config passed from PHP
const locale = new SiteLocaleAI(siteLocaleConfig);
// Define a selector that matches WooCommerce price elements
const priceSelector = '.price, .woocommerce-Price-amount';
// Register a custom formatter for currency conversion
locale.registerFormatter('currency', async (original) => {
// Strip non‑numeric characters
const numeric = parseFloat(original.replace(/[^0-9.,]/g, '').replace(',', '.'));
if (isNaN(numeric)) return original;
// Ask the LLM to convert USD → EUR using the latest rate (the LLM can be prompted with a simple instruction)
const prompt = `Convert ${numeric} USD to EUR using the current exchange rate and round psychologically.`;
const response = await locale.llmQuery(prompt);
// The LLM returns a string like "€20" – return it directly
return response.trim();
});
// Apply the formatter to all price elements
locale.translateAndFormat(priceSelector, 'currency');
});
Enqueue this file in functions.php:
wp_enqueue_script('sitelocale-init', get_stylesheet_directory_uri() . '/js/sitelocale-init.js', ['sitelocaleai-js'], null, true);
Now, when a European visitor lands on any product or shop page, the script will:
- Detect the visitor’s country via the LLM (or a simple IP‑to‑country lookup if you prefer).
- Convert every price from USD to EUR.
- Apply psychological rounding (e.g., €19.99 → €20).
5. SEO‑friendly pre‑rendering with the CLI
Search engines can’t execute JavaScript reliably, so we’ll pre‑render the translated pages using SiteLocaleAI’s CLI. This step generates static HTML snapshots for each language/currency combination, which you can serve to crawlers via robots.txt or a custom route.
# Install the CLI globally (requires Node.js only on your build server)
npm i -g @sitelocaleai/cli
# Run the pre‑render for the Euro version of the shop
sitelocaleai prerender \
--url https://yourstore.com/shop \
--lang en \
--currency EUR \
--output ./prerendered/eur.html
Add the generated file to your server and tell Google to use it via the X-Robots-Tag header or by serving it to the Accept-Language header.
For a deeper dive on the CLI options, see the official docs: SiteLocaleAI Docs.
6. Verify the implementation
- Open an incognito window with a VPN set to a European country (e.g., Germany).
- Navigate to a product page. Prices should appear in € and be rounded to the nearest whole number.
- View the page source (Ctrl+U). You should see the rendered HTML with the Euro values, confirming that pre‑rendering works.
- Run a Lighthouse audit to ensure the page loads quickly and SEO scores are high.
7. Wrap‑up & next steps
You now have a fully functional, self‑hosted solution that:
- Converts WooCommerce prices to EUR for European visitors.
- Uses psychological rounding to improve perceived value.
- Generates SEO‑ready static snapshots for better indexing.
- Keeps all LLM calls on your own API keys, preserving privacy and cost control.
If you want to support more currencies, simply extend the override map in functions.php. For multilingual stores, change targetLang to the desired language code and let SiteLocaleAI handle the translation of UI text.
Ready to boost your international sales? Try SiteLocaleAI today and see how effortless global localization can be.
Explore the full documentation and start translating your site in minutes!