wordpress codings

finxx

Registered Member
Joined
Sep 21, 2012
Messages
67
Reaction score
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.
 

Attachments

  • coinsnap.JPG
    coinsnap.JPG
    69.3 KB · Views: 118
Actually I figured it out. It was the discounted price formula that woocommerce uses that meshes it up.

$10 paypal to anybody who helps me with attaching it to an api so I don't have to manually changes prices. I see it commented out.
 
Sorry, don't know woocommerce too well, but couldn't you just change ...

Code:
$price_btc = $price*0.00016; // WCR_Bitcoin_Exchange_Rate::get( $price, 'USD', 'BTC', $rate_source );

with

Code:
 $price_btc = WCR_Bitcoin_Exchange_Rate::get( $price, 'USD', 'BTC', $rate_source );
 
Yeah I tried that. It said WCR_Bitcoin_Exchange_Rate was undefined.
 
Back
Top