价格转换
Price conversion
我需要一些帮助。
在 Wordpress 房地产网站上,我想在以欧元为单位的价格旁边显示以 XPF 为单位的价格。
价格函数为:
public static function format_price($price,$html = true){
$return = '';
$currency_code = self::get_general_option('currency');
$currency_symbol = self::get_currency_symbol($currency_code);
$currency_position = self::get_general_option('currency_position');
switch ( $currency_position ) {
case 'left' :
$format = '%1$s%2$s';
break;
case 'right' :
$format = '%2$s%1$s';
break;
case 'left_space' :
$format = '%1$s %2$s';
break;
case 'right_space' :
$format = '%2$s %1$s';
break;
default:
$format = '%1$s%2$s';
}
$thousands_sep = wp_specialchars_decode( stripslashes(self::get_general_option('price_thousand_sep')),ENT_QUOTES);
$decimal_sep = wp_specialchars_decode( stripslashes(self::get_general_option('price_decimal_sep')),ENT_QUOTES);
$num_decimals = self::get_general_option('price_num_decimals');
$price = floatval( $price );
if(!$html) {
return self::number_format( $price, $num_decimals, '.', '', $currency_code );
}
$price = self::number_format( $price, $num_decimals, $decimal_sep, $thousands_sep, $currency_code );
if('text' === $html) {
return sprintf( $format, $currency_symbol, $price );
}
//$price = preg_replace( '/' . preg_quote( self::get_general_option('price_decimal_sep'), '/' ) . '0++$/', '', $price );
$return = '<span class="amount">' . sprintf( $format, $currency_symbol, $price ) . '</span>';
return $return;
}
兑换率为:1€ = 119.33XPF
如何编辑代码以显示价格,例如:
11933000XPF(100000 欧元)
谢谢。
您有欧元价格的浮动值。如果您的转换率是固定值,只需像这样转换:
$price_xpf = $price * 119.33;
价格的格式与欧元价格的格式完全类似。
仅用于显示,请执行以下操作:
$return = '<span class="amount">'. sprintf( $format,"XPF",$price_xpf ) ."(". sprintf( $format, $currency_symbol, $price ) . ')</span>';
对于任何其他改编,最基本的编程技能都会有所帮助。
我需要一些帮助。 在 Wordpress 房地产网站上,我想在以欧元为单位的价格旁边显示以 XPF 为单位的价格。
价格函数为:
public static function format_price($price,$html = true){
$return = '';
$currency_code = self::get_general_option('currency');
$currency_symbol = self::get_currency_symbol($currency_code);
$currency_position = self::get_general_option('currency_position');
switch ( $currency_position ) {
case 'left' :
$format = '%1$s%2$s';
break;
case 'right' :
$format = '%2$s%1$s';
break;
case 'left_space' :
$format = '%1$s %2$s';
break;
case 'right_space' :
$format = '%2$s %1$s';
break;
default:
$format = '%1$s%2$s';
}
$thousands_sep = wp_specialchars_decode( stripslashes(self::get_general_option('price_thousand_sep')),ENT_QUOTES);
$decimal_sep = wp_specialchars_decode( stripslashes(self::get_general_option('price_decimal_sep')),ENT_QUOTES);
$num_decimals = self::get_general_option('price_num_decimals');
$price = floatval( $price );
if(!$html) {
return self::number_format( $price, $num_decimals, '.', '', $currency_code );
}
$price = self::number_format( $price, $num_decimals, $decimal_sep, $thousands_sep, $currency_code );
if('text' === $html) {
return sprintf( $format, $currency_symbol, $price );
}
//$price = preg_replace( '/' . preg_quote( self::get_general_option('price_decimal_sep'), '/' ) . '0++$/', '', $price );
$return = '<span class="amount">' . sprintf( $format, $currency_symbol, $price ) . '</span>';
return $return;
}
兑换率为:1€ = 119.33XPF
如何编辑代码以显示价格,例如: 11933000XPF(100000 欧元)
谢谢。
您有欧元价格的浮动值。如果您的转换率是固定值,只需像这样转换:
$price_xpf = $price * 119.33;
价格的格式与欧元价格的格式完全类似。
仅用于显示,请执行以下操作:
$return = '<span class="amount">'. sprintf( $format,"XPF",$price_xpf ) ."(". sprintf( $format, $currency_symbol, $price ) . ')</span>';
对于任何其他改编,最基本的编程技能都会有所帮助。