Get currency symbol in WooCommerce

Get currency symbol in WooCommerce
1027 Views

You can get current currency in woocommerce using get_woocommerce_currency_symbol(); function.

<?php echo get_woocommerce_currency_symbol(); ?>

Use this to show price with currency

<?php $product->get_price_html(); ?>

Your code should function, therefore the problem may be in the database. You can verify that you are using the functions correctly by checking these two functions from the WooCommerce documentation: get_woocommerce_currency() and get get_woocommerce_currency_symbol().

What is get_option('woocommerce_currency') returning? If nothing, then you have no currency set and that is why you get nothing from get_woocommerce_currency_symbol();

It gets displayed something like echo get_woocommerce_currency_symbol("USD");

The user should be informed that he must have the currency configured before using your extension, so you should add some error-handling lines to your script.

<?php echo get_option( 'woocommerce_currency' ); ?>

How can I display currency in WooCommerce?

Go to WooCommerce > Settings > General > Currency Options and choose your chosen currency from the Currency drop-down menu.

Was this article helpful?
YesNo

Leave a comment

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