价格计算在WooCommerce Checkout小计和总计行中显示2种货币

时间:2018-05-04 08:51:38

标签: woocommerce hook-woocommerce

ETH 5 ($ 3.753,65)

我想在结帐时显示两种货币小计&在woocommerce总计。我猜我正在使用错误的钩子?

Example Image

// Convert to USD
function convert_price_cart( $price ){
$convertion_rate = 780.730022;
$new_price = $price * $convertion_rate;
return number_format($new_price, 2, '.', '');
}

add_filter( 'wc_price', 'my_custom_price_format', 10, 3 );
function my_custom_price_format( $formatted_price, $price, $args ) {

// The currency conversion custom calculation function
$price_usd = convert_price_cart($price);

// the currency symbol for US dollars
$currency = 'USD';
$currency_symbol = get_woocommerce_currency_symbol( $currency );
$price_usd = $currency_symbol.$price_usd; // adding currency symbol

// The USD formatted price
$formatted_price_usd = "<span class='price-usd'> ($price_usd)</span>";

// Return both formatted currencies
return $formatted_price . $formatted_price_usd;
}

有没有人可以帮我解决这个问题。

0 个答案:

没有答案