Admin Settings in all CPTs are already set. Continue to frontend.
This commit is contained in:
@@ -841,10 +841,13 @@ class Form {
|
||||
$last_cart_behavior = array_key_last($cart_behavior);
|
||||
$cart_behavior[$last_cart_behavior]['group'] = 'ended';
|
||||
|
||||
$global_currencies = get_global_currency_array();
|
||||
$default_currency = formipay_default_currency();
|
||||
|
||||
$cart_items = [
|
||||
'cart_items_group' => [
|
||||
'type' => 'group_title',
|
||||
'label' => __( 'Cart Items', 'formipay' ),
|
||||
'label' => __( 'Additional Order Items', 'formipay' ),
|
||||
'group' => 'started',
|
||||
'description' => __( 'Add static product or custom item to form as default and non-editable item in order items.', 'formipay' )
|
||||
],
|
||||
@@ -852,11 +855,12 @@ class Form {
|
||||
'type' => 'autocomplete',
|
||||
'post_type' => ['formipay-product'],
|
||||
'label' => __( 'Assign Product', 'formipay' ),
|
||||
'description' => __( 'Selected products will added to the order items automatically.', 'formipay' )
|
||||
'description' => __( 'Selected products will be added to the order items automatically, even if it is not added to cart.', 'formipay' )
|
||||
],
|
||||
'static_items' => [
|
||||
'type' => 'repeater',
|
||||
'label' => __( 'Assign Items', 'formipay' ),
|
||||
'label' => __( 'Static Items', 'formipay' ),
|
||||
'description' => __( 'Static items will behave like fee that will affect to order calculation but nothing will be delivered.', 'formipay' ),
|
||||
'fields' => [
|
||||
'label' => [
|
||||
'type' => 'text',
|
||||
@@ -870,16 +874,46 @@ class Form {
|
||||
'value' => 1,
|
||||
'required' => true
|
||||
],
|
||||
'amount' => [
|
||||
'type' => 'number',
|
||||
'label' => __( 'Item Amount', 'formipay' ),
|
||||
'description' => __( 'Will be calculated to item quantity', 'formipay' ),
|
||||
'required' => true
|
||||
]
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
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;
|
||||
$cart_items['static_items']['fields']['amount_'.$currency_symbol] = [
|
||||
'type' => 'number',
|
||||
'step' => $step,
|
||||
'min' => 0,
|
||||
'label' => __( 'Item Price in '.$currency_symbol, 'formipay' ),
|
||||
'description' => __( 'Will be calculated to item quantity', 'formipay' ),
|
||||
'placeholder' => __( 'Auto', 'formipay' )
|
||||
];
|
||||
|
||||
if(count($global_currencies) > 1){
|
||||
if($default_currency_symbol === $currency_symbol){
|
||||
$cart_items['static_items']['fields']['amount_'.$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')
|
||||
);
|
||||
$cart_items['static_items']['fields']['amount_'.$currency_symbol]['required'] = true;
|
||||
$cart_items['static_items']['fields']['amount_'.$currency_symbol]['placeholder'] = __( 'Enter Price...', 'formipay' );
|
||||
}else{
|
||||
$cart_items['static_items']['fields']['amount_'.$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{
|
||||
$cart_items['static_items']['fields']['amount_'.$currency_symbol]['label'] = __( 'Item Price', 'formipay' );
|
||||
$cart_items['static_items']['fields']['amount_'.$currency_symbol]['placeholder'] = __( 'Enter Price...', 'formipay' );
|
||||
}
|
||||
}
|
||||
|
||||
$cart_items = apply_filters( 'formipay/form-settings/tab:cart/group:items', $cart_items );
|
||||
|
||||
$last_cart_items = array_key_last($cart_items);
|
||||
|
||||
Reference in New Issue
Block a user