update multicurrencies functionality on global level

This commit is contained in:
dwindown
2025-08-25 19:55:38 +07:00
parent 38b6b5cddb
commit ccb2b1aea1
21 changed files with 1240 additions and 476 deletions

View File

@@ -65,7 +65,7 @@ class Init {
'Formipay',
'Formipay',
'manage_options',
'formipay',
FORMIPAY_MENU_SLUG,
'',
FORMIPAY_URL . 'admin/assets/img/White.png',
5

View File

@@ -52,23 +52,6 @@ abstract class Payment {
public function add_form_payment_menu($fields) {
$gateways = apply_filters( 'formipay/form-config/tab:payments/gateways', [] );
$payment_options = [];
if(!empty($gateways)){
foreach($gateways as $gateway){
$id = $gateway['id'];
$label = $gateway['gateway'];
if(isset($gateway['channel'])){
$label .= ' - '.$gateway['channel'];
}
$payment_options[] = [
'id' => $id,
'label' => $label
];
}
}
$payment_fields = [
'payment_section_group' => array(
'type' => 'group_title',
@@ -82,23 +65,6 @@ abstract class Payment {
'submenu' => __( 'General', 'formipay' ),
'value' => 'Payment Methods',
),
'payment_gateways' => array(
'type' => 'sorter',
'label' => __( 'Choose one or any', 'formipay' ),
'options' => array(
array(
'id' => 'inactive',
'name' => __( 'Inactive', 'formipay' ),
'options' => $payment_options,
),
array(
'id' => 'active',
'name' => __( 'Active', 'formipay' ),
'options' => [],
)
),
'submenu' => __( 'General', 'formipay' ),
),
'payment_label' => array(
'type' => 'checkbox',
'label' => __( 'Show Payment Label', 'formipay' ),

View File

@@ -21,6 +21,20 @@ class Settings {
public function theme_option($setups){
$gateways = apply_filters( 'formipay/form-config/tab:payments/gateways', [] );
$payment_checkboxes = [];
if(!empty($gateways)){
foreach($gateways as $gateway){
$id = $gateway['id'];
$label = $gateway['gateway'];
if(isset($gateway['channel'])){
$label .= ' - '.$gateway['channel'];
}
$payment_checkboxes[$id] = $label;
}
}
$general_fields = array(
'business_group' => array(
'type' => 'group_title',
@@ -39,31 +53,98 @@ class Settings {
'label' => __( 'Currency', 'formipay' ),
'group' => 'started'
),
'payment_default_currency' => array(
'enable_multicurrency' => [
'type' => 'checkbox',
'label' => __( 'Enable Multi Currency', 'formipay' )
],
'multicurrencies' => [
'type' => 'repeater',
'label' => __( 'Currencies', 'formipay' ),
'fields' => [
'currency' => array(
'type' => 'select',
'label' => __('Default Currency', 'formipay'),
'value' => 'IDR:::Indonesian rupiah:::Rp',
'options' => formipay_currency_as_options(),
'required' => true,
'searchable' => true,
'is_group_title' => true
),
'decimal_digits' => array(
'type' => 'number',
'label' => __('Decimal Digits', 'formipay'),
'value' => '2',
'required' => true,
),
'decimal_symbol' => array(
'type' => 'text',
'label' => __('Decimal Symbol', 'formipay'),
'value' => '.',
'required' => true,
),
'thousand_separator' => array(
'type' => 'text',
'label' => __('Thousand Separator Symbol', 'formipay'),
'value' => ',',
'required' => true,
),
'payment_gateways' => array(
'type' => 'multi_checkbox',
'label' => __( 'Payment Gateways', 'formipay' ),
'options' => $payment_checkboxes,
'submenu' => __( 'General', 'formipay' ),
),
'payment_gateways_select' => array(
'type' => 'multiselect',
'label' => __( 'Payment Gateways', 'formipay' ),
'options' => $payment_checkboxes,
'submenu' => __( 'General', 'formipay' ),
'placeholder' => 'Select related Payments'
),
],
'required' => true,
'dependency' => [
'key' => 'enable_multicurrency',
'value' => 'not_empty'
]
],
'default_currency' => array(
'type' => 'select',
'label' => __('Default Currency', 'formipay'),
'value' => 'IDR:::Indonesian rupiah:::Rp',
'options' => formipay_currency_as_options(),
'required' => true,
'searchable' => true,
'required' => true,
'searchable' => true
),
'payment_default_currency_decimal_digits' => array(
'default_currency_decimal_digits' => array(
'type' => 'number',
'label' => __('Decimal Digits', 'formipay'),
'value' => '2',
'required' => true,
'dependency' => [
'key' => 'enable_multicurrency',
'value' => 'empty'
]
),
'payment_default_currency_decimal_symbol' => array(
'default_currency_decimal_symbol' => array(
'type' => 'text',
'label' => __('Decimal Symbol', 'formipay'),
'value' => '.',
'required' => true,
'dependency' => [
'key' => 'enable_multicurrency',
'value' => 'empty'
]
),
'payment_default_currency_thousand_separator' => array(
'default_currency_thousand_separator' => array(
'type' => 'text',
'label' => __('Thousand Separator Symbol', 'formipay'),
'value' => ',',
'required' => true,
'dependency' => [
'key' => 'enable_multicurrency',
'value' => 'empty'
],
'group' => 'ended'
),
);
@@ -211,7 +292,11 @@ class Settings {
wp_localize_script( 'admin-setting-script', 'formipay_admin_setting', [
'ajax_url' => admin_url('admin-ajax.php'),
'site_url' => site_url(),
'nonce' => wp_create_nonce('formipay-admin-nonce')
'nonce' => wp_create_nonce('formipay-admin-nonce'),
'multicurrency' => formipay_is_multi_currency_active(),
'all_currencies' => formipay_currency_as_options(),
'global_selected_currencies' => formipay_global_currency_options(),
'default_currency' => formipay_default_currency()
] );
}
}