本文整理汇总了PHP中CUtil::chkIsValidCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP CUtil::chkIsValidCurrency方法的具体用法?PHP CUtil::chkIsValidCurrency怎么用?PHP CUtil::chkIsValidCurrency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtil
的用法示例。
在下文中一共展示了CUtil::chkIsValidCurrency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convertBaseCurrencyToUSD
public static function convertBaseCurrencyToUSD($amount, $base_currency = "", $exchange_rate_allow = false)
{
if ($amount == "") {
$amount = "0";
}
if (doubleval($amount) > 0) {
$amt = $amount;
if ($base_currency != "USD") {
$currency_details = CUtil::chkIsValidCurrency($base_currency);
if (count($currency_details) > 0) {
$exchange_rate = doubleval($currency_details['exchange_rate']);
if ($exchange_rate_allow) {
$exchange_price = $exchange_rate * (doubleval(\Config::get("webshoppack::site_exchange_rate")) * 0.01);
$exchange_rate = $exchange_rate - $exchange_price;
}
$amt = $amt / $exchange_rate;
}
}
return $amt;
}
return $amount;
}
示例2: 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 "";
}