finxx
Registered Member
- Sep 21, 2012
- 67
- 41
Code:
add_filter( 'wc_price', 'my_custom_price_format', 10, 3 );
function my_custom_price_format( $formatted_price, $price, $args ) {
## Bitcoin
$rate_source = 'CoinDesk';
// The currency conversion custom calculation function
$price_btc = $price*0.00016; // WCR_Bitcoin_Exchange_Rate::get( $price, 'USD', 'BTC', $rate_source );
// the currency symbol for BTC
$currency_symbol = '<i class="cc BTC"></i> ';
$price_btc = $currency_symbol.$price_btc; // adding currency symbol
//Bitcoin formattd price
$formatted_price_btc = "<br><span class='price-btc'> $price_btc</span>";
## USD (formatted price)
$formatted_price = '<br>('.$formatted_price .')';
// Return the 2 formatted currencies
return $formatted_price_btc . $formatted_price ;
}
this code is messing up on larger amounts. its not calculating correctly. if anybody could point me in the right direction please I'd appreciate it.