当前位置: 首页>>代码示例>>PHP>>正文


PHP CUtil::getLocatorApiCurrencyCode方法代码示例

本文整理汇总了PHP中CUtil::getLocatorApiCurrencyCode方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtil::getLocatorApiCurrencyCode方法的具体用法?PHP CUtil::getLocatorApiCurrencyCode怎么用?PHP CUtil::getLocatorApiCurrencyCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUtil的用法示例。


在下文中一共展示了CUtil::getLocatorApiCurrencyCode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCurrencyBasedAmount

 public static function getCurrencyBasedAmount($base_amount, $usd_amount, $base_currency, $return_as_arr = false)
 {
     if ($usd_amount != "") {
         $amt = $usd_amount;
         $currency_symbol = "USD";
         $currency_symbol_font = "\$";
         $fetched_api_currency = "";
         $return_arr = compact('amt', 'currency_symbol', 'currency_symbol_font');
         $currency_code = \Config::get("webshoppack::site_cookie_prefix") . "_selected_currency";
         if (CUtil::getCookie($currency_code) == "") {
             $fetched_api_currency = CUtil::getLocatorApiCurrencyCode();
         }
         if (\Config::get("webshoppack::currency_is_multi_currency_support") == "true") {
             if (CUtil::getCookie($currency_code) != "" || $fetched_api_currency != "") {
                 $currency_details = array();
                 //Check whether the currency in coookie is Active status
                 if ($fetched_api_currency != "") {
                     $currency_details = CUtil::chkIsValidCurrency($fetched_api_currency);
                 } else {
                     $currency_details = CUtil::chkIsValidCurrency(CUtil::getCookie($currency_code));
                 }
                 if (count($currency_details) > 0) {
                     if ($fetched_api_currency != "") {
                         if ($base_currency == $fetched_api_currency) {
                             $amt = $base_amount;
                             $currency_symbol = $currency_details["currency_code"];
                             $currency_symbol_font = $currency_details["currency_symbol"];
                             $return_arr = compact('amt', 'currency_symbol', 'currency_symbol_font');
                             if ($currency_symbol == "INR") {
                                 $currency_symbol_font = "<em class=\"clsWebRupe\">" . $currency_details["currency_symbol"] . "</em>";
                             }
                         } else {
                             if ($currency_details["currency_code"] != "USD") {
                                 //Currency 2 = currency1 x exchange rate.
                                 $amt = $amt * $currency_details["exchange_rate"];
                                 $currency_symbol = $currency_details["currency_code"];
                                 $currency_symbol_font = $currency_details["currency_symbol"];
                                 $return_arr = compact('amt', 'currency_symbol', 'currency_symbol_font');
                                 if ($currency_symbol == "INR") {
                                     $currency_symbol_font = "<em class=\"clsWebRupe\">" . $currency_details["currency_symbol"] . "</em>";
                                 }
                             }
                         }
                     } else {
                         if ($base_currency == CUtil::getCookie($currency_code)) {
                             //$amt = $base_amount.toDouble;
                             $amt = $base_amount;
                             $currency_symbol = $currency_details["currency_code"];
                             $currency_symbol_font = $currency_details["currency_symbol"];
                             $return_arr = compact('amt', 'currency_symbol', 'currency_symbol_font');
                             if ($currency_symbol == "INR") {
                                 $currency_symbol_font = "<em class=\"clsWebRupe\">" . $currency_details["currency_symbol"] . "</em>";
                             }
                         } else {
                             if ($currency_details["currency_code"] != "USD") {
                                 //Currency 2 = currency1 x exchange rate.
                                 $amt = $amt * $currency_details["exchange_rate"];
                                 $currency_symbol = $currency_details["currency_code"];
                                 $currency_symbol_font = $currency_details["currency_symbol"];
                                 $return_arr = compact('amt', 'currency_symbol', 'currency_symbol_font');
                                 if ($currency_symbol == "INR") {
                                     $currency_symbol_font = "<em class=\"clsWebRupe\">" . $currency_details["currency_symbol"] . "</em>";
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $formatted_amt = "";
         $formatted_amt = number_format($amt, 2, '.', '');
         $formatted_amt = str_replace(".00", "", $formatted_amt);
         $formatted_amt = str_replace("Rs.", "", $formatted_amt);
         //	$currencyFormatter = NumberFormat.getCurrencyInstance(new Locale("en", "IN"));
         //	formatted_amt = currencyFormatter.format(amt);
         //	formatted_amt = formatted_amt.replace(".00","");
         //	formatted_amt = formatted_amt.replace("Rs.","");
         //	return "<span class=\"clsPriSym\">"+currency_symbol+"</span>" + " " + currency_symbol_font + formatted_amt;
         if ($return_as_arr) {
             return $return_arr;
         } else {
             //return "<small class=\"clsPriSym\">".$currency_symbol. '</small> <strong>' . $currency_symbol_font . $formatted_amt.'</strong>';
             return '<strong>' . $currency_symbol_font . ' ' . $formatted_amt . '</strong>';
         }
     }
     return "";
 }
开发者ID:agriya,项目名称:webshoppack,代码行数:87,代码来源:CUtil.php


注:本文中的CUtil::getLocatorApiCurrencyCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。