Simultaneous different currencies for specific products on WooCommerce

I wanted to show on the same website some products in Canadian dollars and some others in US dollars. By default you can’t do that on WooCommerce. You have to choose which currency to display for the whole shop. There are some plugins that allow to switch between currencies but again that’s for the whole shop. And my WooCommerce plugin is in Catalog mode so shopping cart currency is not an issue here.

I did not manage to find any hook to achieve this properly in the theme functions.php. I had then to modify some core WooCommerce files. Keep in mind that this method is not optimal as every time you will upgrade WooCommerce, your new edited files will be overwritten. Best way to achieve this would be to add extra field in your Woocommerce admin and display the currency depending on this field but I wanted to do something easy and simple.

To achieve the tweak, there are two files to edit.

Abstract-wc-product.php

/wp-content/plugins/woocommerce/includes/abstracts/abstract-wc-product.php

Look for the function:

function get_price_html

Replace

$price .= wc_price( $display_price ) . $this->get_price_suffix();

by

if ($this->post->ID == "2875") {
$price .= wc_price( $display_price,null,true) . $this->get_price_suffix();
}
else
{
$price .= wc_price( $display_price ) . $this->get_price_suffix();
}

where “2875” should be your product/post ID you want to display an alternative currency for. Obviously, this file has to be edited each time you upload a new product in the alternative currency.

Wc-formatting-functions.php

/wp-content/plugins/woocommerce/includes/wc-formatting-functions.php

Look for

function wc_price

We should add an argument to the function so just replace the header line by

function wc_price( $price, $args = array(), $usd = false ) {

Then look for this line:

$formatted_price = ( $negative ? '-' : '' ) . sprintf( $price_format, get_woocommerce_currency_symbol( $currency ), $price );

and replace it by

if ($usd==true){
$formatted_price = ( $negative ? '-' : '' ) . sprintf( $price_format, "USD$ ", $price );
}
else
{
$formatted_price = ( $negative ? '-' : '' ) . sprintf( $price_format, get_woocommerce_currency_symbol( $currency ), $price );
}

It will basically check if the $usd (you can call the variable anything of course) condition is met. Update the string “USD$ ” to the alternative currency symbol you want to display and that’s it! Trick’s done. You’ll now have some products in the main currency and some others showing up in the alternative currency. Happy tweaking!