Nikola Topalovic
Nikola Topalovic

Reputation: 95

How to wrap woocommerce currency symbol in span?

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.

Upvotes: 1

Views: 726

Answers (2)

Nikola Topalovic
Nikola Topalovic

Reputation: 95

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;
}

Upvotes: 1

Maha Dev
Maha Dev

Reputation: 3965

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.

Upvotes: 0

Related Questions