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 ""; }