1

How to wrap woocommerce currency symbol in span? The question pretty much sums it all up. I want to style woocommerce currency symbol individually and i can't do it since it is outputted as text content with the price.

Please if anyone can help me, I would vary much appreciate it.

Thank you.

2 Answers2

1

I figured it out :)

add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
function change_existing_currency_symbol( $currency_symbol, $currency ) {
   $currency_symbol = '<span>' . $currency_symbol . '</span>';
   return $currency_symbol;
}
0

This way you can add custom currency in woocommerce :

add_filter('woocommerce_currencies', 'add_custom_currency');

function add_custom_currency($currencies) {

    $currencies["SPAN"] = 'Span Euro';

    return $currencies;
}

add_filter('woocommerce_currency_symbol', 'add_custom_currency_symbol', 10, 2);

function add_custom_currency_symbol($currency_symbol, $currency) {

    switch ($currency) {

        case 'SPAN': $currency_symbol = 'Sp';

            break;
    }

    return $currency_symbol;
}

Here 'Sp' is the currency shown on your website.

Maha Dev
  • 3,915
  • 2
  • 31
  • 50
  • As I understand this will allow me to add new currency, but I need a way to wrap in span the symbols for default woocommerce currencies, so no matter what currency user chooses the symbol will be wrapped in span. – Nikola Topalovic Feb 23 '16 at 18:36