How to force any currency on the checkout page
Sometimes it’s necessary to force a specific currency on the checkout page based on business logic.
Simplest Method:
- Open functions.php of your current WordPress theme and add the following code:
-
add_filter('wp_head', function(){ if(is_checkout()){ global $WOOCS; $WOOCS->set_currency('USD'); } }); - Change ‘USD‘ to any currency you need…
Notice: This works only when the “Is multiple allowed” option is enabled (Yes).
Advanced Method:
// Define forced currency once to avoid repetition
define('WOOCS_FORCED_CHECKOUT_CURRENCY', 'USD'); // Change to your currency
// Method 1: Force on page load
add_action('template_redirect', 'woocs_force_checkout_currency', 999);
// Method 2: Force during checkout process (after WOOCS hooks)
add_action('woocommerce_checkout_process', 'woocs_force_checkout_currency', 999);
function woocs_force_checkout_currency() {
if (!is_checkout()) {
return;
}
global $WOOCS;
if (!isset($WOOCS) || !is_object($WOOCS)) {
return;
}
$WOOCS->set_currency(WOOCS_FORCED_CHECKOUT_CURRENCY);
// Also set in storage to prevent reset
if (isset($WOOCS->storage)) {
$WOOCS->storage->set_val('woocs_current_currency', WOOCS_FORCED_CHECKOUT_CURRENCY);
}
}
// Method 3: Force on AJAX updates
add_filter('woocommerce_checkout_update_order_review', 'woocs_force_currency_ajax', 10000);
function woocs_force_currency_ajax($post_data) {
global $WOOCS;
if (!isset($WOOCS) || !is_object($WOOCS)) {
return $post_data;
}
$WOOCS->set_currency(WOOCS_FORCED_CHECKOUT_CURRENCY);
if (isset($WOOCS->storage)) {
$WOOCS->storage->set_val('woocs_current_currency', WOOCS_FORCED_CHECKOUT_CURRENCY);
}
return $post_data;
}
// Prevent GeoIP override
add_filter('woocs_force_pay_bygeoip_rules', '__return_false');
Source: https://wordpress.org/support/topic/how-to-force-any-currency-on-the-checkout-page/
