Get currency symbol in WooCommerce

Get currency symbol in WooCommerce
1121 Views
3.1
(132)

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.

How useful was this blog?

Click on a star to rate it!

Average rating 3.1 / 5. Vote count: 132

No votes so far! Be the first to rate this blog.

  • CodexCoach

    - Web Development Expert

    CodexCoach is a skilled tech educator known for easy-to-follow tutorials in coding, digital design, and software development. With practical tips and interactive examples, CodexCoach helps people learn new tech skills and advance their careers.

Leave a comment

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