This snippet will display the total on the order received page in fiat and / or crypto.
Configure the currency_id on line 8 to change currency.
Switch the comments between 30 and 31 to switch how the total is shown.
/**
@brief On the order received page, shows the total in fiat+crypto or just crypto.
@since 2018-11-07 18:21:07
**/
function mcc_woocommerce_get_order_item_totals( $total_rows, $order, $tax_display )
{
// Display the total in ETH
$currency_id = 'ETH';
// Is MCC installed?
if ( ! function_exists( 'mycryptocheckout' ) )
return $total_rows;
if ( ! isset( $total_rows[ 'order_total' ] ) )
return $total_rows;
// Retrieve all of our currencies.
$currencies = MyCryptoCheckout()->currencies();
$currency = $currencies->get( $currency_id );
// Is this currency known?
if ( ! $currency )
return $total_rows;
$total = $order->get_total();
$new_price = $currency->convert( get_woocommerce_currency(), $total );
$new_total = $new_price . ' ' . $currency_id;
// This displays FIAT / CRYPTO.
$total_rows[ 'order_total' ][ 'value' ] .= ' / ' . $new_total;
// This displays only CRYPTO.
// $total_rows[ 'order_total' ][ 'value' ] = $new_total;
return $total_rows;
}
add_filter( 'woocommerce_get_order_item_totals', 'mcc_woocommerce_get_order_item_totals', 10, 3 );