[SOLVED] Programatically Change WooCommerce Stripe Currency at Checkout without Plugin

March 1, 2022

I had a client project recently whereby they have different dealers using a single woocommerce install but each dealer would process payments with their own stripe API keys but the added challenge was that they process in different currencies.

So for example, Canadian dealers would process in CAD and US dealers would process their stripe payment in USD.

As woocommerce stores ONE main currency, in this case CAD, on checkout, payments made through stripe would process in CAD and not USD.

Here is the code to switch the currency

In my example below I am dynamically pulling in the preferred currency through get_dealers_store_array() which will set the woocommerce_currency to whatever currency I put.

It would also work if you just said $array = “USD” and this would force the checkout currency to USD.

add_filter( 'woocommerce_currency', 'filter_woocommerce_currency', 10, 1 );
function filter_woocommerce_currency( $array ) { 
    $dealers_array = get_dealers_store_array();
    $currency = $dealers_array["parts_store_data"]["store_currency"];    $array = $currency;
    return $array; 

How to check if its working

To see if its working, add some products to the cart, go to checkout page and view source.

Look for the tag “data-currency” which is part of the stripe plugin.