Woocommerce 吴哥商业货币符号

Woocommerce 吴哥商业货币符号,woocommerce,currency,symbols,Woocommerce,Currency,Symbols,我最近正在为我的客户使用WooCommerce WordPress项目,我正在为WooCommerce WordPress编辑一个插件。我正在尝试显示产品价格,以包括使用此功能的货币代码 * @param mixed $item * @param bool $inc_tax (default: false). * @param bool $round (default: true). * @return float */ public function get_item_total(

我最近正在为我的客户使用WooCommerce WordPress项目,我正在为WooCommerce WordPress编辑一个插件。我正在尝试显示产品价格,以包括使用此功能的货币代码

 * @param mixed $item
 * @param bool $inc_tax (default: false).
 * @param bool $round (default: true).
 * @return float
 */
public function get_item_total( $item, $inc_tax = false, $round = true ) {

    $qty = ( ! empty( $item['qty'] ) ) ? $item['qty'] : 1;

    if ( $inc_tax ) {
        $price = ( $item['line_total'] + $item['line_tax'] ) / max( 1, $qty );
    } else {
        $price = $item['line_total'] / max( 1, $qty );
    }

    $price = '<span class="price">' . $round ? round( $price, wc_get_price_decimals() ) . '</span>' : '<span class="price">' . $price . '</span>' ;

    return apply_filters( 'woocommerce_order_amount_item_total',  $price, $this, $item, $inc_tax, $round ); 
}
但它会吐出一个像55这样没有货币符号的数字。是否有人会得到货币符号为55美元的数字

感谢您对我们的帮助

这就是它现在的修复方法

public function get_item_total( $item, $inc_tax = false, $round = true ) {

    $qty = ( ! empty( $item['qty'] ) ) ? $item['qty'] : 1;

    if ( $inc_tax ) {
        $price = ( $item['line_total'] + $item['line_tax'] ) / max( 1, $qty );
    } else {
        $price = $item['line_total'] / max( 1, $qty );
    }

   $currency_symbol = get_woocommerce_currency_symbol();

   $price = $round ? round($price, wc_get_price_decimals() ): $price;

$price = '<span class="price">' .$currency_symbol . $price .'</span>';  
    return apply_filters( 'woocommerce_order_amount_item_total',$price, $this, $item, $inc_tax, $round ); 
}

我发现这很容易。只需在主题文件夹下的functions.php文件中插入以下代码块

//Change the symbol of an existing currency
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
     switch( $currency ) {
          case 'USD': $currency_symbol = 'USD&#36;'; break;
}
     return $currency_symbol;
}

您是否尝试使用get\u\u currency预挂货币?因为在你的代码里没有什么可以回应的。例如:$price=。获得商业和货币。。。。。。。。。