2016-10-14 7 views
0

私はいくつかの助けが必要です。 Wordpressの不動産ウェブサイトでは、値段の横に価格を€で表示したいと考えています。価格変換

価格関数は次のとおりです。

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€ )

ありがとうございます。

答えて

0

価格の浮動小数点はユーロです。コンバージョン率が固定値である場合にだけ、このように変換します。

$price_xpf = $price * 119.33; 

価格のフォーマットがユーロでの価格の書式とまったく同様に働いています。

だけ表示するために、次の操作を行います。

$return = '<span class="amount">'. sprintf($format,"XPF",$price_xpf) ."(". sprintf($format, $currency_symbol, $price) . ')</span>'; 

最も基本的なプログラミングのスキルが参考になります他の適応について。

+0

ありがとうございました!出来た。 – user3301061