fix Products, Coupons, and admin pages
This commit is contained in:
@@ -175,12 +175,11 @@ class Product {
|
||||
wp_enqueue_style( 'product-details', FORMIPAY_URL . 'admin/assets/css/admin-product-editor.css', [], FORMIPAY_VERSION, 'all' );
|
||||
wp_enqueue_script( 'product-details', FORMIPAY_URL . 'admin/assets/js/admin-product-editor.js', ['jquery', 'vue.js'], FORMIPAY_VERSION, true );
|
||||
wp_localize_script( 'product-details', 'product_details', [
|
||||
'multicurrency' => formipay_is_multi_currency_active(),
|
||||
// 'all_currencies' => formipay_currency_as_options(),
|
||||
'global_selected_currencies' => formipay_global_currency_options(),
|
||||
'global_currencies' => formipay_global_currency_options('raw'),
|
||||
'default_currency' => formipay_default_currency(),
|
||||
'default_currency_title' => formipay_default_currency('title'),
|
||||
'default_currency_symbol' => formipay_default_currency('symbol'),
|
||||
'default_currency_decimal_digits' => formipay_default_currency('decimal_digits'),
|
||||
'default_currency_decimal_symbol' => formipay_default_currency('decimal_symbol'),
|
||||
'default_currency_thousand_separator' => formipay_default_currency('thousand_separator'),
|
||||
'product_type' => formipay_get_post_meta($product_id, 'product_type') ?: 'digital',
|
||||
'product_is_physical' => formipay_get_post_meta($product_id, 'product_type') == 'physical',
|
||||
'product_pricing_method' => $pricing_method, // Pass pricing method to JS
|
||||
@@ -192,12 +191,16 @@ class Product {
|
||||
'th_price' => __('Regular Price', 'formipay'),
|
||||
'th_sale' => __('Sale Price', 'formipay'),
|
||||
'th_weight' => __('Weight', 'formipay'),
|
||||
'th_prices_overall' => __('Prices', 'formipay'), // New header for manual mode
|
||||
'manual_price_hint' => __('Prices set manually below', 'formipay'), // New hint for manual mode cell
|
||||
'child_th_currency' => __('Currency', 'formipay'), // Child table header
|
||||
'child_th_regular' => __('Regular Price', 'formipay'), // Child table header
|
||||
'child_th_sale' => __('Sale Price', 'formipay'), // Child table header
|
||||
'no_variations' => __( 'No variations available', 'formipay' )
|
||||
'th_prices_overall' => __('Prices', 'formipay'),
|
||||
'manual_price_hint' => __('Prices set manually below', 'formipay'),
|
||||
'child_th_currency' => __('Currency', 'formipay'),
|
||||
'child_th_regular' => __('Regular Price', 'formipay'),
|
||||
'child_th_sale' => __('Sale Price', 'formipay'),
|
||||
'no_currencies' => __( 'No currencies available', 'formipay' ),
|
||||
'no_variations' => __( 'No variations available', 'formipay' ),
|
||||
'child_placeholder_regular' => __( 'Enter Regular Price', 'formipay' ),
|
||||
'child_placeholder_sale' => __( 'Enter Sale Price', 'formipay' ),
|
||||
'error_missing_default_price' => __( 'Please fill Regular Price for default currency (%1$s) in variation "%2$s".', 'formipay' ),
|
||||
]
|
||||
] );
|
||||
}
|
||||
@@ -279,103 +282,157 @@ class Product {
|
||||
$product_details_group[$last_product_details_group]['group'] = 'ended';
|
||||
|
||||
// Product Currency Group
|
||||
$product_currency_group = array(
|
||||
'setting_product_pricing' => array(
|
||||
// $product_currency_group = array(
|
||||
// 'setting_product_pricing' => array(
|
||||
// 'type' => 'group_title',
|
||||
// 'label' => __( 'Pricing', 'formipay' ),
|
||||
// 'description' => __( 'Carefully set these options below.', 'formipay' ),
|
||||
// 'group' => 'started',
|
||||
// ),
|
||||
// 'product_pricing_method' => array(
|
||||
// 'type' => 'radio',
|
||||
// 'label' => __('Product Pricing Method', 'formipay'),
|
||||
// 'options' => array(
|
||||
// 'manual' => 'Manual Price Set',
|
||||
// 'auto' => 'Auto via Currency Exchange API'
|
||||
// ),
|
||||
// 'value' => 'manual',
|
||||
// 'required' => true
|
||||
// ),
|
||||
// 'product_regular_price' => array(
|
||||
// 'type' => 'number',
|
||||
// 'label' => sprintf( __('Regular Price (%s)', 'formipay'), formipay_default_currency('symbol') ),
|
||||
// 'value' => 0,
|
||||
// 'step' => 0.01,
|
||||
// 'required' => true,
|
||||
// 'dependency' => [
|
||||
// 'key' => 'product_pricing_method',
|
||||
// 'value' => 'auto'
|
||||
// ]
|
||||
// ),
|
||||
// 'product_sale_price' => array(
|
||||
// 'type' => 'number',
|
||||
// 'label' => sprintf( __('Sale Price (%s)', 'formipay'), formipay_default_currency('symbol') ),
|
||||
// 'value' => 0,
|
||||
// 'step' => 0.01,
|
||||
// 'dependency' => [
|
||||
// 'key' => 'product_pricing_method',
|
||||
// 'value' => 'auto'
|
||||
// ]
|
||||
// ),
|
||||
// 'product_prices' => [
|
||||
// 'type' => 'repeater',
|
||||
// 'label' => __( 'Prices', 'formipay' ),
|
||||
// 'description' => __( 'You can set price with multiple currency', 'formipay' ),
|
||||
// 'fields' => [
|
||||
// 'regular_price' => array(
|
||||
// 'type' => 'number',
|
||||
// 'label' => __('Regular Price', 'formipay'),
|
||||
// 'value' => 0,
|
||||
// 'step' => 0.01,
|
||||
// 'required' => true
|
||||
// ),
|
||||
// 'sale_price' => array(
|
||||
// 'type' => 'number',
|
||||
// 'label' => __('Sale Price', 'formipay'),
|
||||
// 'value' => 0,
|
||||
// 'step' => 0.01
|
||||
// ),
|
||||
// 'currency' => array(
|
||||
// 'type' => 'select',
|
||||
// 'label' => __('Currency', 'formipay'),
|
||||
// 'value' => 'IDR:::Indonesian rupiah:::Rp',
|
||||
// 'options' => formipay_currency_as_options(),
|
||||
// 'required' => true,
|
||||
// 'searchable' => true,
|
||||
// 'is_group_title' => true
|
||||
// ),
|
||||
// 'currency_decimal_digits' => array(
|
||||
// 'type' => 'number',
|
||||
// 'label' => __('Decimal Digits', 'formipay'),
|
||||
// 'value' => '2',
|
||||
// 'required' => true
|
||||
// ),
|
||||
// 'currency_decimal_symbol' => array(
|
||||
// 'type' => 'text',
|
||||
// 'label' => __('Decimal Symbol', 'formipay'),
|
||||
// 'value' => '.',
|
||||
// 'required' => true
|
||||
// ),
|
||||
// 'currency_thousand_separator' => array(
|
||||
// 'type' => 'text',
|
||||
// 'label' => __('Thousand Separator Symbol', 'formipay'),
|
||||
// 'value' => ',',
|
||||
// 'required' => true
|
||||
// ),
|
||||
// ],
|
||||
// 'dependency' => [
|
||||
// 'key' => 'product_pricing_method',
|
||||
// 'value' => 'manual'
|
||||
// ]
|
||||
// ],
|
||||
// );
|
||||
|
||||
$global_currencies = get_global_currency_array();
|
||||
$default_currency = formipay_default_currency();
|
||||
|
||||
foreach($global_currencies as $currency){
|
||||
$default_currency_symbol = formipay_get_currency_data_by_value($default_currency, 'symbol');
|
||||
$currency_symbol = formipay_get_currency_data_by_value($currency['currency'], 'symbol');
|
||||
$currency_title = ucwords(formipay_get_currency_data_by_value($currency['currency'], 'title'));
|
||||
$decimal_digits = intval($currency['decimal_digits']);
|
||||
$step = $decimal_digits * 10;
|
||||
$step = $step > 0 ? 1 / $step : 1;
|
||||
$product_currency_group['setting_product_pricing_'.$currency_symbol] = array(
|
||||
'type' => 'group_title',
|
||||
'label' => __( 'Pricing', 'formipay' ),
|
||||
'description' => __( 'Carefully set these options below.', 'formipay' ),
|
||||
'group' => 'started',
|
||||
),
|
||||
'product_pricing_method' => array(
|
||||
'type' => 'radio',
|
||||
'label' => __('Product Pricing Method', 'formipay'),
|
||||
'options' => array(
|
||||
'manual' => 'Manual Price Set',
|
||||
'auto' => 'Auto via Currency Exchange API'
|
||||
'label' => sprintf(
|
||||
__( '<img src="%s" width="18" /> Pricing in %s (%s)', 'formipay' ),
|
||||
formipay_get_flag_by_currency($currency['currency']),
|
||||
$currency_title,
|
||||
$currency_symbol
|
||||
),
|
||||
'value' => 'manual',
|
||||
'required' => true
|
||||
),
|
||||
'product_regular_price' => array(
|
||||
'group' => 'started',
|
||||
);
|
||||
$product_currency_group['setting_product_price_regular_'.$currency_symbol] = array(
|
||||
'type' => 'number',
|
||||
'label' => sprintf( __('Regular Price (%s)', 'formipay'), formipay_default_currency('symbol') ),
|
||||
'value' => 0,
|
||||
'step' => 0.01,
|
||||
'required' => true,
|
||||
'dependency' => [
|
||||
'key' => 'product_pricing_method',
|
||||
'value' => 'auto'
|
||||
]
|
||||
),
|
||||
'product_sale_price' => array(
|
||||
'label' => __( 'Regular Price', 'formipay' ),
|
||||
'step' => $step,
|
||||
'min' => 0,
|
||||
'placeholder' => __( 'Auto', 'formipay' )
|
||||
);
|
||||
$product_currency_group['setting_product_price_sale_'.$currency_symbol] = array(
|
||||
'type' => 'number',
|
||||
'label' => sprintf( __('Sale Price (%s)', 'formipay'), formipay_default_currency('symbol') ),
|
||||
'value' => 0,
|
||||
'step' => 0.01,
|
||||
'dependency' => [
|
||||
'key' => 'product_pricing_method',
|
||||
'value' => 'auto'
|
||||
]
|
||||
),
|
||||
'product_prices' => [
|
||||
'type' => 'repeater',
|
||||
'label' => __( 'Prices', 'formipay' ),
|
||||
'description' => __( 'You can set price with multiple currency', 'formipay' ),
|
||||
'fields' => [
|
||||
'regular_price' => array(
|
||||
'type' => 'number',
|
||||
'label' => __('Regular Price', 'formipay'),
|
||||
'value' => 0,
|
||||
'step' => 0.01,
|
||||
'required' => true
|
||||
),
|
||||
'sale_price' => array(
|
||||
'type' => 'number',
|
||||
'label' => __('Sale Price', 'formipay'),
|
||||
'value' => 0,
|
||||
'step' => 0.01
|
||||
),
|
||||
'currency' => array(
|
||||
'type' => 'select',
|
||||
'label' => __('Currency', 'formipay'),
|
||||
'value' => 'IDR:::Indonesian rupiah:::Rp',
|
||||
'options' => formipay_currency_as_options(),
|
||||
'required' => true,
|
||||
'searchable' => true,
|
||||
'is_group_title' => true
|
||||
),
|
||||
'currency_decimal_digits' => array(
|
||||
'type' => 'number',
|
||||
'label' => __('Decimal Digits', 'formipay'),
|
||||
'value' => '2',
|
||||
'required' => true
|
||||
),
|
||||
'currency_decimal_symbol' => array(
|
||||
'type' => 'text',
|
||||
'label' => __('Decimal Symbol', 'formipay'),
|
||||
'value' => '.',
|
||||
'required' => true
|
||||
),
|
||||
'currency_thousand_separator' => array(
|
||||
'type' => 'text',
|
||||
'label' => __('Thousand Separator Symbol', 'formipay'),
|
||||
'value' => ',',
|
||||
'required' => true
|
||||
),
|
||||
],
|
||||
'dependency' => [
|
||||
'key' => 'product_pricing_method',
|
||||
'value' => 'manual'
|
||||
]
|
||||
],
|
||||
);
|
||||
'label' => __( '🎉 Sale Price', 'formipay' ),
|
||||
'step' => $step,
|
||||
'min' => 0,
|
||||
'placeholder' => __( 'Auto', 'formipay' ),
|
||||
'group' => 'ended'
|
||||
);
|
||||
|
||||
if(count($global_currencies) > 1){
|
||||
if($default_currency_symbol === $currency_symbol){
|
||||
$product_currency_group['setting_product_pricing_'.$currency_symbol]['description'] = sprintf(
|
||||
__( 'This is your default currency. <a href="%s" target="_blank">Change in Settings</a>', 'formipay' ),
|
||||
admin_url('/admin.php?page=formipay-settings')
|
||||
);
|
||||
$product_currency_group['setting_product_price_regular_'.$currency_symbol]['required'] = true;
|
||||
$product_currency_group['setting_product_price_regular_'.$currency_symbol]['placeholder'] = __( 'Enter Regular Price...', 'formipay' );
|
||||
$product_currency_group['setting_product_price_sale_'.$currency_symbol]['placeholder'] = __( 'Enter Sale Price...', 'formipay' );
|
||||
}else{
|
||||
$product_currency_group['setting_product_pricing_'.$currency_symbol]['description'] = sprintf(
|
||||
__( 'System will calculate the price in %s based on exchange rate against %s when you leave these empty.', 'formipay' ),
|
||||
$currency_symbol, $default_currency_symbol
|
||||
);
|
||||
}
|
||||
}else{
|
||||
$product_currency_group['setting_product_pricing_'.$currency_symbol]['label'] = __( 'Product Prices', 'formipay' );
|
||||
$product_currency_group['setting_product_price_regular_'.$currency_symbol]['placeholder'] = __( 'Enter Regular Price...', 'formipay' );
|
||||
$product_currency_group['setting_product_price_sale_'.$currency_symbol]['placeholder'] = __( 'Enter Sale Price...', 'formipay' );
|
||||
}
|
||||
}
|
||||
|
||||
$product_currency_group = apply_filters( 'formipay/product-settings/tab:general/group:product-currency', $product_currency_group );
|
||||
|
||||
$last_product_currency_group = array_key_last($product_currency_group);
|
||||
$product_currency_group[$last_product_currency_group]['group'] = 'ended';
|
||||
|
||||
|
||||
$general_all_fields = array_merge($product_details_group, $product_currency_group);
|
||||
|
||||
$general_all_fields = apply_filters( 'formipay/product-settings/tab:general', $general_all_fields );
|
||||
@@ -420,47 +477,16 @@ class Product {
|
||||
'variation_label' => [
|
||||
'type' => 'text',
|
||||
'label' => __( 'Title', 'formipay' ),
|
||||
'description' => __( 'e.g. Color, Size, etc', 'formipay' ),
|
||||
'description' => __( 'e.g. Red, XL, etc', 'formipay' ),
|
||||
'required' => true,
|
||||
'is_group_title' => true
|
||||
],
|
||||
'variation_value_type' => [
|
||||
'type' => 'select',
|
||||
'label' => __( 'Value Type', 'formipay' ),
|
||||
'options' => [
|
||||
'text' => __( 'Text', 'formipay' ),
|
||||
'number' => __( 'Number', 'formipay' ),
|
||||
'color' => __( 'Color', 'formipay' ),
|
||||
],
|
||||
'value' => 'text'
|
||||
],
|
||||
'variation_value_text' => [
|
||||
'variation_value' => [
|
||||
'type' => 'text',
|
||||
'label' => __( 'Value', 'formipay' ),
|
||||
'required' => true,
|
||||
'dependency' => array(
|
||||
'key' => 'variation_value_type',
|
||||
'value' => 'text'
|
||||
),
|
||||
],
|
||||
'variation_value_number' => [
|
||||
'type' => 'number',
|
||||
'label' => __( 'Value', 'formipay' ),
|
||||
'required' => true,
|
||||
'dependency' => array(
|
||||
'key' => 'variation_value_type',
|
||||
'value' => 'number'
|
||||
),
|
||||
],
|
||||
'variation_value_color' => [
|
||||
'type' => 'color',
|
||||
'label' => __( 'Value', 'formipay' ),
|
||||
'required' => true,
|
||||
'dependency' => array(
|
||||
'key' => 'variation_value_type',
|
||||
'value' => 'color'
|
||||
),
|
||||
],
|
||||
'description' => __( 'e.g. red, xl, etc', 'formipay' ),
|
||||
'required' => true
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user