Question

I am using WooCommerce for my online shop. I have my prices set in USD in the admin panel.

How can I display that price in Bitcoin for the front-end user?

I will make the script where it reads current Bitcoin value and convert that USD amount in BTC.

$backendPrice = 1000.00
$bitcoinPrice = 500.00
$displayPrice = 2
Was it helpful?

Solution

This series of filter hooks will do the job:

if( !is_admin() )
{
    add_filter( 'woocommerce_get_sale_price', 'bit_price', 10, 2 );
    add_filter( 'woocommerce_get_regular_price', 'bit_price', 10, 2 );
    add_filter( 'woocommerce_get_price', 'bit_price', 10, 2 );

    add_filter( 'woocommerce_currency_symbol', function( $currency_symbol, $currency ) {
        return 'Bits'; //$currency_symbol;
    }, 10, 2 );

    add_filter( 'woocommerce_currency', function( $currency ) {
        return $currency;
    });
}

function bit_price( $price, $product )
{
    return $price * 0.5;
}

OTHER TIPS

You can use GoUrl Bitcoin Gateway Plugin for WooCommerce.

It supports - "Set prices in USD/EUR/etc. in the admin panel and display that prices in Bitcoins for the front-end user"

https://wordpress.org/plugins/gourl-woocommerce-bitcoin-altcoin-payment-gateway-addon/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top