How to display two Currencies in WooCommerce? | themelocation

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$

  • 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.

No comments yet.

Leave a Reply