Viewing 6 replies - 1 through 6 (of 6 total)
  • I use € [format currency=EUR][field _price][/format].

    Thread Starter maestro2012

    (@maestro2012)

    Thanks. But how do you add a currency symbol? I use a currency conversion plugin, the symbol must be from WooCommerce to be automatically changed by the currency conversion plugin.

    For me, the main currency is the US Dollar, plus Euro and one more currency.

    This depends on the way the currency conversion plugin is working. Can you get the converted currency or the converted price with a shortcode?

    Thread Starter maestro2012

    (@maestro2012)

    I used the following function to insert a price. Maybe it will be useful to someone.
    The currency conversion plugin I use is “Currency Exchange for WooCommerce”. Currency change seems to be working.

    function my_shortcode_product_price() {
        $html = '';
    
        global $product;
    
        $price = wc_get_price_to_display( $product, array( 'price' => $product->get_price() ) );
    
        $args = array(
                'ex_tax_label'       => false,
                'currency'           => 'USD',
                'decimal_separator'  => '.',
                'thousand_separator' => ' ',
                'decimals'           => 2,
                'price_format'       => '%2$s %1$s',
            );
    
        $html = "<span>" . wc_price( $price, $args ) . "</span>";
    
        return $html;
     }
     add_shortcode( 'product_price', 'my_shortcode_product_price' );

    [product_price]

    But shouldn’t the shortcode or the plugin not also deliver the currency? If there is no currency delivered – how should CCS know what currency you are using?

    Thread Starter maestro2012

    (@maestro2012)

    The above function solves the problem.
    This function inserts the price with the currency symbol. Found it today. I put the shortcode in the loop and it works fine.
    Currency switching as well.

    Earlier I used
    [format currency = EUR] [field _price] [/ format] but it does not give the currency symbol and currency switching does not work.

    • This reply was modified 3 years, 11 months ago by maestro2012.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘woocommerce price with currency symbol’ is closed to new replies.