How to display two currencies in WooCommerce?

The process is quite simple you just have to follow some simple steps as described below:

  • Once you have set your Store with WooCommerce just add a new product, as an example, I am adding Chocolate (If you already have products in store you can skip this step)
  • View your product and it will show only one currency that you have selected while setting WooCommerce, I have selected US dollars so it shows me the price 50$

Our team at Themelocation is comprised of WordPress developers of high expertise

  • We can maintain, support and manage your single, or all your clients, website with dedication
  • Our skills are at your disposal.

Book a Call

  • Now go to your Dashboard-> Appearance-> Editor
  • On the right side of editor, you will find several templates click on Theme Functions file (functions.php)

Note: Please Always backup your functions file before making any change.

Add the following code to the functions file, Put at the end of the existing code.

add_action( 'woocommerce_product_options_pricing', 'themelocation_custom_cost_product_field' );

function themelocation_custom_cost_product_field() {

//Change Your desire currency here

$custom_currency_symbol = '$';

woocommerce_wp_text_input( array( 'id' => 'custom_price', 'class' => 'wc_input_price short', 'label' => __( 'Custom Price', 'woocommerce' ) . ' (' . $custom_currency_symbol . ')' ) );

}

After the Code:

Go to products and add a new product now you will get a new field in product data known as Custom Price, in this field you can add the second price you want to show on your website as well.

You will get price of your product in two different currencies you can change the symbol of second currency by changing ‘$’ with your desired currency in $custom_currency_symbol = ‘$’; in the code, you have inserted in functions.php

Note: You need to add the price of the other Currency yourself.

Also, Checkout will be proceed only with the default Currency. The Currency, We added is only for display purpose.

Waqas

I hope you enjoy reading this blog post. If you want my team to do WooCommerce Maintenance for you, click here.

1 thought on “How to display two currencies in WooCommerce?”

  1. This code works for simple products only…
    Could you please share the same code but for variable products?

Leave a Comment

Your email address will not be published. Required fields are marked *