Using a custom icon instead of WooCommerce price currency

Hello bricks team,

It would be great if you could add the ability to use a custom SVG instead of the $ symbol or any other currency.

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

function custom_currency_symbol($currency_symbol, $currency) {
    if ($currency === 'USD') { // Replace 'USD' with your desired currency code
        $currency_symbol = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" width="15" height="15" x="0" y="0" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512" xml:space="preserve" class=""><g><path fill="#FED843" d="M406 196v-30c0-49.629-40.371-90-90-90h-30V0h-60v76h-22.617C149.682 76 106 119.682 106 173.383a97.24 97.24 0 0 0 73.77 94.482l46.23 11.56V376h-30c-16.538 0-30-13.462-30-30v-30h-60v30c0 49.629 40.371 90 90 90h30v76h60v-76h22.617C362.318 436 406 392.318 406 338.617a97.24 97.24 0 0 0-73.77-94.482L286 232.575V136h30c16.538 0 30 13.462 30 30v30zm-180 21.572-31.67-7.919a37.313 37.313 0 0 1-28.33-36.27c0-20.61 16.772-37.383 37.383-37.383H226zm91.67 84.776a37.313 37.313 0 0 1 28.33 36.27c0 20.61-16.772 37.383-37.383 37.383H286v-81.572z" opacity="1" data-original="#fed843" class=""></path><path fill="#FABE2C" d="M308.617 436C362.318 436 406 392.318 406 338.617a97.24 97.24 0 0 0-73.77-94.482L286 232.575V136h30c16.538 0 30 13.462 30 30v30h60v-30c0-49.629-40.371-90-90-90h-30V0h-30v512h30v-76zM286 294.428l31.67 7.919a37.313 37.313 0 0 1 28.33 36.27c0 20.61-16.772 37.383-37.383 37.383H286z" opacity="1" data-original="#fabe2c" class=""></path></g></svg>';
    }

    return $currency_symbol;
}
1 Like