fix Products, Coupons, and admin pages
This commit is contained in:
@@ -78,16 +78,20 @@ function formipay_default_currency($return='raw') {
|
||||
|
||||
}
|
||||
|
||||
function formipay_global_currency_options() {
|
||||
function formipay_global_currency_options($output = 'options_array') {
|
||||
|
||||
$formipay_settings = get_option('formipay_settings');
|
||||
// $currencies = (false !== boolval($formipay_settings['enable_multicurrency'])) ? formipay_default_currency() : [];
|
||||
$currencies = [];
|
||||
if(false !== boolval($formipay_settings['enable_multicurrency']) && !empty($formipay_settings['multicurrencies'])) {
|
||||
foreach($formipay_settings['multicurrencies'] as $currency){
|
||||
$currency_value = $currency['currency'];
|
||||
$currency_label = formipay_get_currency_data_by_value($currency_value, 'title');
|
||||
$currencies[$currency_value] = $currency_label;
|
||||
if($output === 'options_array'){
|
||||
foreach($formipay_settings['multicurrencies'] as $currency){
|
||||
$currency_value = $currency['currency'];
|
||||
$currency_label = formipay_get_currency_data_by_value($currency_value, 'title');
|
||||
$currencies[$currency_value] = $currency_label;
|
||||
}
|
||||
}elseif($output == 'raw'){
|
||||
$currencies = $formipay_settings['multicurrencies'];
|
||||
}
|
||||
}
|
||||
// if(empty($currencies)){
|
||||
@@ -98,6 +102,49 @@ function formipay_global_currency_options() {
|
||||
|
||||
}
|
||||
|
||||
function get_global_currency_array() {
|
||||
$multicurrency = formipay_is_multi_currency_active();
|
||||
$global_currencies = formipay_global_currency_options('raw');
|
||||
$default_currency = formipay_default_currency();
|
||||
|
||||
$product_currency_group = [];
|
||||
|
||||
$ifSingleCurrency = true;
|
||||
if(boolval($multicurrency)){
|
||||
$ifSingleCurrency = false;
|
||||
if(count($global_currencies) === 1){
|
||||
$ifSingleCurrency = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(false === $ifSingleCurrency){
|
||||
// $currency_sort = [];
|
||||
$default_sort_key = null;
|
||||
foreach($global_currencies as $key => $currency){
|
||||
$currency_value = $currency['currency'];
|
||||
if($currency_value === $default_currency){
|
||||
$default_sort_key = $key;
|
||||
}
|
||||
}
|
||||
$currency_sort = [$default_sort_key => $global_currencies[$default_sort_key]];
|
||||
unset($global_currencies[$default_sort_key]);
|
||||
$global_currencies = $currency_sort + $global_currencies;
|
||||
}else{
|
||||
if(false === boolval($multicurrency)){
|
||||
$global_currencies = [
|
||||
[
|
||||
'currency' => formipay_default_currency(),
|
||||
'decimal_digits' => formipay_default_currency('decimal_digits'),
|
||||
'decimal_symbol' => formipay_default_currency('decimal_symbol'),
|
||||
'thousand_separator' => formipay_default_currency('thousand_separator'),
|
||||
]
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $global_currencies;
|
||||
}
|
||||
|
||||
function formipay_country_array() {
|
||||
|
||||
$json = file_get_contents(FORMIPAY_PATH . 'admin/assets/json/country.json');
|
||||
|
||||
Reference in New Issue
Block a user