__('Form', 'formipay'),
'singular_name' => __('Form', 'formipay'),
'menu_name' => 'Formipay',
'add_new' => __('Add New', 'formipay'),
'add_new_item' => __('Add New Form', 'formipay'),
'edit' => __('Edit', 'formipay'),
'edit_item' => __('Edit Form', 'formipay'),
'new_item' => __('New Form', 'formipay'),
'view' => __('View', 'formipay'),
'view_item' => __('View Form', 'formipay'),
'search_items' => __('Search Form', 'formipay'),
'not_found' => __('No forms found', 'formipay'),
'not_found_in_trash' => __('No forms found in trash', 'formipay'),
'parent' => __('Form Parent', 'formipay')
);
$args = array(
'label' => 'Formipay',
'description' => __('Form builder to initiate any payment purpose', 'formipay'),
'labels' => $labels,
'public' => false,
'supports' => array( 'title', ),
'hierarchical' => true,
// 'taxonomies' => array( 'formipay-form-category' ),
'has_archive' => true,
'rewrite' => array( 'slug' => 'form' ),
'show_ui' => true,
'show_in_menu' => false,
'show_in_rest' => false,
'query_var' => false,
);
register_post_type( 'formipay-form', $args );
}
public function menu() {
add_submenu_page(
'formipay',
__( 'Forms', 'formipay' ),
__( 'Forms', 'formipay' ),
'manage_options',
'formipay',
[$this, 'formipay_form'] ,
5
);
}
public function formipay_form() {
include_once FORMIPAY_PATH . 'admin/page-forms.php';
}
public function metaboxes($post) {
global $current_screen;
add_meta_box(
'formipay_canvas',
'Formipay',
[$this, 'render_formipay_metabox'],
'formipay-form',
'advanced',
'high'
);
if($current_screen->post_type == 'formipay-form' && $current_screen->base == 'post'){
add_meta_box(
'form_shortcode',
'Shortcode',
[$this, 'render_shortcode_metabox'],
'formipay-form',
'side',
'high'
);
}
}
public function cpt_post_fields_box($boxes) {
$boxes['formipay_form_settings'] = array(
'post_type' => array('formipay-form'),
'label' => __('Config', 'formipay'),
);
return $boxes;
}
public function cpt_post_fields_content($fields) {
$fields['formipay_form_settings'] = array();
$fields = apply_filters( 'formipay/form-config', $fields );
return $fields;
}
public function settings_config($fields) {
// Group : Fields
$field_group = array(
'setting_field_group' => array(
'type' => 'group_title',
'label' => __( 'Field', 'formipay' ),
'group' => 'started'
),
'label_visibility' => array(
'type' => 'select',
'label' => __('Label Visibility', 'formipay'),
'options' => array(
'show' => 'Show',
'hide' => 'Hide',
),
'value' => 'show'
),
'field_placeholder' => array(
'type' => 'select',
'label' => __( 'Placeholder', 'formipay' ),
'options' => array(
'placeholder' => __( 'Placeholder', 'formipay' ),
'label' => __( 'Label', 'formipay' )
),
'value' => 'label'
),
'required_field_sign' => array(
'type' => 'select',
'label' => __( 'Required Field Sign', 'formipay' ),
'options' => array(
'asterisk' => __('Asterisk', 'formipay'),
'text' => __( 'Text', 'formipay' )
),
'value' => 'asterisk'
),
'required_field_text' => array(
'type' => 'text',
'label' => __( 'Required Field Text', 'formipay' ),
'value' => __('(required)', 'formipay'),
'dependency' => array(
'key' => 'required_field_sign',
'value' => 'text'
)
),
'required_field_color' => array(
'type' => 'color',
'label' => __( 'Required Field Sign/Text Color', 'formipay' ),
'value' => 'rgba(255, 0, 0, 1)',
'required' => true
),
'empty_required_text_field' => array(
'type' => 'hint_textarea',
'label' => __( 'Empty Required Text Field', 'formipay' ),
'value' => __( 'Ups! {{field}} is required.', 'formipay' ),
'hints' => array(
'field' => __( 'Current Field', 'formipay' )
),
'description' => __('Type {{field}} to get the label of the field', 'formipay'),
'required' => true
),
'empty_required_select_field' => array(
'type' => 'hint_textarea',
'label' => __( 'Empty Required Select Field', 'formipay' ),
'value' => __( 'Select an option of {{field}} is required.', 'formipay' ),
'hints' => array(
'field' => __( 'Current Field', 'formipay' )
),
'description' => __('Type {{field}} to get the label of the field', 'formipay'),
'required' => true
// 'group' => 'ended'
)
);
$field_group = apply_filters( 'formipay/form-settings/tab:settings/group:fields', $field_group );
$last_field_group = array_key_last($field_group);
$field_group[$last_field_group]['group'] = 'ended';
// Group Summary
$summary_group = array(
'setting_field' => array(
'type' => 'group_title',
'label' => __( 'Summary', 'formipay' ),
'group' => 'started'
),
'order_review_title' => array(
'type' => 'text',
'label' => __( 'Order Review Title', 'formipay' ),
'value' => 'Order Review',
// 'group' => 'ended'
),
);
$summary_group = apply_filters( 'formipay/form-settings/tab:settings/group:summary', $summary_group );
$last_summary_group = array_key_last($summary_group);
$summary_group[$last_summary_group]['group'] = 'ended';
$settings_all_fields = array_merge($field_group, $summary_group);
$settings_all_fields = apply_filters( 'formipay/form-settings/tab:settings', $settings_all_fields );
$fields['formipay_form_settings']['settings'] = array(
'name' => __('Settings', 'formipay'),
'fields' => $settings_all_fields
);
return $fields;
}
public function appearance_config($fields) {
// Schedule Group
$schedule_group = array(
'conditional_schedule_group' => array(
'type' => 'group_title',
'label' => __( 'Schedule', 'formipay' ),
'description' => __( 'You can control start to end date for showing this form.', 'formipay' ),
'submenu' => __( 'Display Logic', 'formipay' ),
'group' => 'started'
),
'schedule_toggle' => array(
'type' => 'checkbox',
'label' => __( 'Activate Schedule', 'formipay' ),
'submenu' => __( 'Display Logic', 'formipay' ),
),
'daterange' => array(
'type' => 'dates',
'label' => __( 'Date Range', 'formipay' ),
'dependency' => array(
'key' => 'schedule_toggle',
'value' => 'not_empty'
),
'submenu' => __( 'Display Logic', 'formipay' ),
'required' => true
),
'waiting_message' => array(
'type' => 'editor',
'label' => __( 'Waiting Message', 'formipay' ),
'value' => 'This form will be available on .....',
'dependency' => array(
'key' => 'schedule_toggle',
'value' => 'not_empty'
),
'submenu' => __( 'Display Logic', 'formipay' ),
'required' => true
),
'expired_message' => array(
'type' => 'editor',
'label' => __( 'Expired Message', 'formipay' ),
'value' => 'This form is no longer available.',
'dependency' => array(
'key' => 'schedule_toggle',
'value' => 'not_empty'
),
'submenu' => __( 'Display Logic', 'formipay' ),
'required' => true
)
);
$schedule_group = apply_filters( 'formipay/form-settings/tab:appearance/group:schedule', $schedule_group );
$last_schedule_group = array_key_last($schedule_group);
$schedule_group[$last_schedule_group]['group'] = 'ended';
// Layout Group
$layout_group = array(
'form_layout_columns' => array(
'type' => 'image_select',
'label' => __( 'Layout Column', 'formipay' ),
'width' => 100,
'height' => 100,
'value' => 1,
'options' => array(
1 => array(
'alt' => '1 Column',
'img' => FORMIPAY_URL . 'admin/assets/img/formipay_layout_1.png'
),
2 => array(
'alt' => '2 Columns',
'img' => FORMIPAY_URL . 'admin/assets/img/formipay_layout_2.png'
),
),
'submenu' => __('Layout', 'formipay'),
'description' => __( 'Choose your preferred layout. 2 columns layout will separates the order review box and submit button to the right side but will not applied when you have page break inner the form. ', 'formipay' ),
),
'form_static_elements_sort' => array(
'type' => 'sorter',
'label' => __( 'Static Elements Sort', 'formipay' ),
'options' => array(
array(
'id' => 'inactive',
'name' => __( 'Inactive', 'formipay' ),
'options' => apply_filters('formipay/admin-editor/layout/static-elements-sort', [
[
'id' => 'submit_response_notice',
'label' => __( 'Submit Response Notice', 'formipay' ),
]
]),
),
array(
'id' => 'active',
'name' => __( 'Active', 'formipay' ),
'options' => array(
array(
'id' => 'payment_methods',
'label' => __( 'Payment Methods', 'formipay' ),
),
array(
'id' => 'order_review',
'label' => __( 'Order Review', 'formipay' )
),
array(
'id' => 'submit_button',
'label' => __( 'Submit Button', 'formipay' ),
'icon' => 'fa fa-exclamation',
'class' => 'disable'
)
)
)
),
'submenu' => __('Layout', 'formipay'),
'required' => true
),
'form_display_as' => array(
'type' => 'image_select',
'label' => __( 'Display as', 'formipay' ),
'width' => 100,
'height' => 100,
'value' => 'div',
'options' => array(
'div' => array(
'alt' => 'On Page',
'img' => FORMIPAY_URL . 'admin/assets/img/formipay_layout_2.png'
),
'popup' => array(
'alt' => 'Popup',
'img' => FORMIPAY_URL . 'admin/assets/img/formipay_display_popup.png'
)
),
'submenu' => __('Layout', 'formipay'),
'description' => __( 'Choose your preferred layout. Display as popup will show the button only on the page, and the form will be shown after button click.', 'formipay' ),
)
);
// Popup Group
$popup_group = array(
'popup_button_group' => array(
'type' => 'group_title',
'label' => __( 'Popup Button', 'formipay' ),
'submenu' => __( 'Layout', 'formipay' ),
'description' => __( 'Popup button is the only element that will be shown until it clicked and pop a modal, not the button inner the form.', 'formipay' ),
'dependency' => array(
'key' => 'form_display_as',
'value' => 'popup'
),
'group' => 'started'
),
'popup_click_selector' => array(
'type' => 'checkbox',
'label' => __( 'Define selector instead build a button', 'formipay' ),
'description' => __( 'If active, you only need to input a class or ID of the target element. So on click the element will trigger open the popup.', 'formipay' ),
'dependency' => array(
'key' => 'form_display_as',
'value' => 'popup'
),
'submenu' => __( 'Layout', 'formipay' ),
),
'popup_trigger_selector' => array(
'type' => 'text',
'label' => __( 'Selector', 'formipay' ),
'description' => __( 'Example: #buy for element ID or .paynow for element class', 'formipay' ),
'dependency' => array(
array(
'key' => 'form_display_as',
'value' => 'popup'
),
array(
'key' => 'popup_click_selector',
'value' => 'not_empty'
)
),
'dependencies' => '&&',
'submenu' => __( 'Layout', 'formipay' ),
),
'popup_button_text' => array(
'type' => 'text',
'label' => __('Trigger Button Text', 'formipay'),
'value' => __( 'Order Now', 'formipay' ),
'dependency' => array(
array(
'key' => 'form_display_as',
'value' => 'popup'
),
array(
'key' => 'popup_click_selector',
'value' => 'empty'
)
),
'dependencies' => '&&',
'submenu' => __( 'Layout', 'formipay' ),
'required' => true
),
'popup_button_bg_color' => array(
'type' => 'link_color',
'label' => __('Background Color', 'formipay'),
'dependency' => array(
array(
'key' => 'form_display_as',
'value' => 'popup'
),
array(
'key' => 'popup_click_selector',
'value' => 'empty'
)
),
'dependencies' => '&&',
'submenu' => __( 'Layout', 'formipay' ),
'required' => true
),
'popup_button_text_color' => array(
'type' => 'link_color',
'label' => __('Text Color', 'formipay'),
'dependency' => array(
array(
'key' => 'form_display_as',
'value' => 'popup'
),
array(
'key' => 'popup_click_selector',
'value' => 'empty'
)
),
'dependencies' => '&&',
'submenu' => __( 'Layout', 'formipay' ),
'required' => true
),
'popup_button_border_color' => array(
'type' => 'link_color',
'label' => __('Border Color', 'formipay'),
'dependency' => array(
array(
'key' => 'form_display_as',
'value' => 'popup'
),
array(
'key' => 'popup_click_selector',
'value' => 'empty'
)
),
'dependencies' => '&&',
'submenu' => __( 'Layout', 'formipay' ),
'required' => true
),
'popup_button_width' => array(
'type' => 'select',
'label' => __('Button Width', 'formipay'),
'options' => array(
'fullwidth' => __( 'Fullwidth', 'formipay' ),
'fit-content' => __( 'Fit Content', 'formipay' )
),
'value' => 'fullwidth',
'submenu' => __( 'Layout', 'formipay' ),
'dependency' => array(
array(
'key' => 'form_display_as',
'value' => 'popup'
),
array(
'key' => 'popup_click_selector',
'value' => 'empty'
)
),
'dependencies' => '&&',
'required' => true
),
'popup_button_alignment' => array(
'type' => 'radio',
'label' => __('Button Alignment', 'formipay'),
'options' => array(
'left' => ' Left',
'center' => ' Center',
'right' => ' Right',
),
'value' => 'center',
'submenu' => __( 'Layout', 'formipay' ),
'dependency' => array(
array(
'key' => 'form_display_as',
'value' => 'popup'
),
array(
'key' => 'popup_button_width',
'value' => 'fit-content'
),
array(
'key' => 'popup_click_selector',
'value' => 'empty'
)
),
'dependencies' => '&&',
'group' => 'ended',
'required' => true
),
'popup_wrapper_group' => array(
'type' => 'group_title',
'label' => __( 'Popup Wrapper', 'formipay' ),
'submenu' => __( 'Layout', 'formipay' ),
'description' => __( 'Your form will be included in this wrapper.', 'formipay' ),
'dependency' => array(
'key' => 'form_display_as',
'value' => 'popup'
),
'group' => 'started'
),
'popup_content_wrapper_width' => array(
'type' => 'text',
'label' => __('Width', 'formipay'),
'value' => '600',
'submenu' => __( 'Layout', 'formipay' ),
'dependency' => array(
'key' => 'form_display_as',
'value' => 'popup'
),
'required' => true,
'description' => __( 'Set the width in pixel (px)', 'formipay' )
),
'popup_content_wrapper_title' => array(
'type' => 'text',
'label' => __('Title', 'formipay'),
'value' => 'Checkout',
'submenu' => __( 'Layout', 'formipay' ),
'dependency' => array(
'key' => 'form_display_as',
'value' => 'popup'
),
'required' => true
),
'popup_content_wrapper_backdrop_color' => array(
'type' => 'color',
'label' => __('Backdrop Color', 'formipay'),
'value' => 'rgba(0, 0, 0, .75)',
'submenu' => __( 'Layout', 'formipay' ),
'dependency' => array(
'key' => 'form_display_as',
'value' => 'popup'
),
'required' => true
)
);
$popup_group = apply_filters( 'formipay/form-settings/tab:appearance/group:popup', $popup_group );
$last_popup_group = array_key_last($popup_group);
$popup_group[$last_popup_group]['group'] = 'ended';
// Multistep Group
$multistep_group = array(
'setting_multistep_point_group' => array(
'type' => 'group_title',
'label' => __( 'Multistep Point', 'formipay' ),
'description' => __( 'Multistep points are located on the top of the form. This setting only applied if you have page breaks in the form.', 'formipay' ),
'submenu' => __( 'Multistep', 'formipay' ),
'group' => 'started'
),
'multistep_point_shape' => array(
'type' => 'image_select',
'label' => __( 'Point Shape', 'formipay' ),
'options' => array(
'rectangle' => array(
'alt' => __( 'Rectangle', 'formipay' ),
'img' => FORMIPAY_URL . 'admin/assets/img/multistep_point_shape_rectangle.png'
),
'rounded' => array(
'alt' => __( 'Rounded', 'formipay' ),
'img' => FORMIPAY_URL . 'admin/assets/img/multistep_point_shape_rounded.png'
),
'circle' => array(
'alt' => __( 'Circle', 'formipay' ),
'img' => FORMIPAY_URL . 'admin/assets/img/multistep_point_shape_circle.png'
),
),
'value' => 'circle',
'submenu' => __( 'Multistep', 'formipay' ),
),
'multistep_point_symbol' => array(
'type' => 'image_select',
'label' => __( 'Point Symbol', 'formipay' ),
'options' => array(
'index' => array(
'alt' => __( 'Incremental', 'formipay' ),
'img' => FORMIPAY_URL . 'admin/assets/img/multistep_sort.png'
),
'icon' => array(
'alt' => __( 'Icon', 'formipay' ),
'img' => FORMIPAY_URL . 'admin/assets/img/multistep_icon.png'
)
),
'value' => 'index',
'submenu' => __( 'Multistep', 'formipay' )
),
'multistep_point_icons' => array(
'type' => 'repeater',
'label' => __( 'Point Icon', 'formipay' ),
'fields' => array(
'field_id' => array(
'type' => 'text',
'label' => __( 'Field ID', 'formipay' ),
'description' => __( 'Copy one of your page break field ID to match the icon', 'formipay' ),
'is_group_title' => true,
'required' => true
),
'script' => array(
'type' => 'textarea',
'label' => __( 'Icon Script', 'formipay' ),
'description' => sprintf( 'Choose your preferred icon from Icon Sets and copy its SVG code', 'formipay' ),
'required' => true
)
),
'dependency' => array(
'key' => 'multistep_point_symbol',
'value' => 'icon'
),
'submenu' => __( 'Multistep', 'formipay' )
)
);
$multistep_group = apply_filters( 'formipay/form-settings/tab:appearance/group:multistep', $multistep_group );
$last_multistep_group = array_key_last($multistep_group);
$multistep_group[$last_multistep_group]['group'] = 'ended';
// Multistep Button Group
$multistep_button_group = array(
'setting_multistep_button_group' => array(
'type' => 'group_title',
'label' => __( 'Multistep Button', 'formipay' ),
'description' => __( 'Multistep buttons are located on the top of the form. This setting only applied if you have page breaks in the form.', 'formipay' ),
'submenu' => __( 'Multistep', 'formipay' ),
'group' => 'started'
),
'multistep_btn_next_text' => array(
'type' => 'text',
'label' => __( 'Next Button Text', 'formipay' ),
'value' => __( 'Next', 'formipay' ),
'submenu' => __( 'Multistep', 'formipay' ),
'required' => true
),
'multistep_btn_prev_text' => array(
'type' => 'text',
'label' => __( 'Prev Button Text', 'formipay' ),
'value' => __( 'Prev', 'formipay' ),
'submenu' => __( 'Multistep', 'formipay' ),
'required' => true
),
'multistep_btn_size' => array(
'type' => 'select',
'label' => __( 'Size', 'formipay' ),
'options' => array(
'smaller_than_submit' => __( 'Smaller than submit button', 'formipay' ),
'same_as_submit' => __( 'Same as submit button', 'formipay' ),
'larger_than_submit' => __( 'Larger than submit button', 'formipay' )
),
'value' => 'same_as_submit',
'submenu' => __( 'Multistep', 'formipay' )
)
);
$multistep_button_group = apply_filters( 'formipay/form-settings/tab:appearance/group:multistep-button', $multistep_button_group );
$last_multistep_button_group = array_key_last($multistep_button_group);
$multistep_button_group[$last_multistep_button_group]['group'] = 'ended';
// Submit Button Group
$submit_button_group = array(
'setting_submit_button' => array(
'type' => 'group_title',
'label' => __( 'Submit Button', 'formipay' ),
'description' => __( 'All settings are only affect to form submit button, unless background and text color.', 'formipay' ),
'submenu' => __( 'Submit Button', 'formipay' ),
'group' => 'started'
),
'button_text' => array(
'type' => 'text',
'label' => __('Text', 'formipay'),
'placeholder' => 'Submit',
'value' => 'Submit',
'submenu' => __( 'Submit Button', 'formipay' ),
'required' => true
),
'button_processing_text' => array(
'type' => 'text',
'label' => __('Processing Text', 'formipay'),
'placeholder' => 'Processing',
'value' => 'Processing...',
'submenu' => __( 'Submit Button', 'formipay' ),
'required' => true
),
'button_bg_color' => array(
'type' => 'link_color',
'label' => __('Background Color', 'formipay'),
'submenu' => __( 'Submit Button', 'formipay' ),
'value' => [
'regular' => '#587FE4',
'hover' => '#2357df',
'active' => '#2357df',
],
'required' => true
),
'button_text_color' => array(
'type' => 'link_color',
'label' => __('Text Color', 'formipay'),
'submenu' => __( 'Submit Button', 'formipay' ),
'value' => [
'regular' => '#ffffff',
'hover' => '#ffffff',
'active' => '#ffffff',
],
'required' => true
),
'button_border_color' => array(
'type' => 'link_color',
'label' => __('Border Color', 'formipay'),
'submenu' => __( 'Submit Button', 'formipay' ),
'value' => [
'regular' => '#587FE4',
'hover' => '#2357df',
'active' => '#2357df',
],
'required' => true
),
'button_width' => array(
'type' => 'select',
'label' => __('Width', 'formipay'),
'options' => array(
'fullwidth' => 'Fullwidth',
'fit-content' => 'Fit Content'
),
'value' => 'fullwidth',
'submenu' => __( 'Submit Button', 'formipay' ),
),
'button_position' => array(
'type' => 'radio',
'label' => __('Alignment', 'formipay'),
'options' => array(
'left' => ' Left',
'center' => ' Center',
'right' => ' Right',
),
'value' => 'right',
'dependency' => array(
'key' => 'button_width',
'value' => 'fit-content'
),
'required' => true,
'submenu' => __( 'Submit Button', 'formipay' )
)
);
$submit_button_group = apply_filters( 'formipay/form-settings/tab:appearance/group:submit-button', $submit_button_group );
$last_submit_button_group = array_key_last($submit_button_group);
$submit_button_group[$last_submit_button_group]['group'] = 'ended';
$appearance_all_fields = array_merge($schedule_group, $layout_group, $popup_group, $multistep_group, $multistep_button_group, $submit_button_group);
$appearance_all_fields = apply_filters( 'formipay/form-settings/tab:appearance', $appearance_all_fields );
$fields['formipay_form_settings']['appearance'] = array(
'name' => __('Appearance', 'formipay'),
'fields' => $appearance_all_fields
);
return $fields;
}
public function cart_config($fields) {
$cart_behavior = [
'cart_behavior_group' => [
'type' => 'group_title',
'label' => __( 'Cart Behavior', 'formipay' ),
'group' => 'started',
'description' => __( 'This will affect to the cart items that calculated in the form.', 'formipay' )
],
'added_to_cart_items' => [
'type' => 'checkbox',
'label' => __( 'Add cart items to order items.', 'formipay' ),
'description' => __( 'Form will check if cart has items and add them to the order items.', 'formipay' ),
]
];
$cart_behavior = apply_filters( 'formipay/form-settings/tab:cart/group:behavior', $cart_behavior );
$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' => __( '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' )
],
'static_products' => [
'type' => 'autocomplete',
'post_type' => ['formipay-product'],
'label' => __( 'Assign Product', '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' => __( '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',
'label' => __( 'Item Label', 'formipay' ),
'required' => true,
'is_group_title' => true
],
'quantity' => [
'type' => 'number',
'label' => __( 'Item Quantity', 'formipay' ),
'value' => 1,
'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. Change in Settings', '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);
$cart_items[$last_cart_items]['group'] = 'ended';
$cart_fields = array_merge($cart_behavior, $cart_items);
$fields['formipay_form_settings']['cart_items'] = array(
'name' => __('Cart Items', 'formipay'),
'fields' => $cart_fields
);
return $fields;
}
public function donation_config($fields) {
$donation_set = [
'donation_group' => [
'type' => 'group_title',
'label' => __( 'Donation', 'formipay' ),
'group' => 'started',
'description' => sprintf(__( '⚠️ When enabled, the donation amount will override the total price at checkout.
All products or order items attached to this form will be charged according to the donation amount specified here, regardless of their individual prices.
This allows donors to contribute a custom or preset donation amount instead of paying the sum of product prices.', 'formipay' ))
],
'donation_active' => [
'type' => 'checkbox',
'label' => __( 'Activate', 'formipay' ),
],
'donation_amount_preset' => [
'type' => 'repeater',
'label' => __( 'Amount Presets', 'formipay' ),
'description' => __( 'This will be sorted as clickable button to set the donation amount on checkout.', 'formipay' ),
'fields' => [
'preset_amount' => [
'type' => 'number',
'label' => __( 'Value', 'Formipay' ),
'step' => 0.01,
'required' => true
],
'preset_label' => [
'type' => 'text',
'label' => __( 'Label', 'formipay' ),
'is_group_title' => true,
'required' => true
]
],
'dependency' => [
'key' => 'donation_active',
'value' => 'not_empty'
]
],
'donation_custom_amount_label' => [
'type' => 'text',
'label' => __( 'Custom Amount Label', 'formipay' ),
'value' => __( 'Other Amount', 'formipay' ),
'description' => __( 'Leave this empty to disable other amount button.', 'formipay' ),
'dependency' => [
'key' => 'donation_active',
'value' => 'not_empty'
]
]
];
$donation_set = apply_filters( 'formipay/form-settings/tab:cart/group:donation', $donation_set );
$last_donation_set = array_key_last($donation_set);
$donation_set[$last_donation_set]['group'] = 'ended';
$fields['formipay_form_settings']['donation'] = array(
'name' => __('Donation', 'formipay'),
'fields' => $donation_set
);
return $fields;
}
public function submission_config($fields) {
$hints = formipay_editor_hints();
$success_response_hints = apply_filters( 'formipay/admin-editor/config/success-response-hints', [
'order_id' => __( 'Order ID', 'formipay' ),
'order_status' => __( 'Order Status', 'formipay' )
] );
// Submit Response Group
$submit_response_group = array(
'submit_response_group' => array(
'type' => 'group_title',
'label' => __( 'Submit Response', 'formipay' ),
'description' => __( 'After clicking the submit button, visitor will get notice message that tells the submission is success or failed, before the action triggered.', 'formipay' ),
'group' => 'started'
),
'response_type' => array(
'type' => 'select',
'label' => __( 'Response Type', 'formipay' ),
'options' => array(
'notice' => __( 'Notice', 'formipay' ),
'popup' => __( 'Popup', 'formipay' )
),
'value' => 'notice',
'required' => true
),
'success_response_content' => array(
'type' => 'hint_textarea',
'label' => __( 'Success Response Content', 'formipay' ),
'value' => 'Order #{{order_id}} has been created.',
'hints' => $success_response_hints
),
'failed_response_content' => array(
'type' => 'hint_textarea',
'label' => __( 'Failed Response Content', 'formipay' ),
'value' => 'Failed on submiting data. Please try again.',
'hints' => [
'error_message' => __( 'System Error Message', 'formipay' )
],
)
);
$submit_response_group = apply_filters( 'formipay/form-settings/tab:submission/group:submit-response', $submit_response_group );
$last_submit_response_group = array_key_last($submit_response_group);
$submit_response_group[$last_submit_response_group]['group'] = 'ended';
// Submit Action Group
$submit_action_group = array(
'submit_confirmation_group' => array(
'type' => 'group_title',
'label' => __( 'Submit Action', 'formipay' ),
'description' => __( 'Action will triggered to process the submitted data further.', 'formipay' ),
'group' => 'started'
),
'submit_action_type' => array(
'type' => 'select',
'label' => __('Action Type', 'formipay'),
'options' => array(
'thankyou' => __( 'Thank-you Screen', 'formipay'),
'redirect' => __( 'Redirect to custom URL', 'formipay' ),
'whatsapp' => __( 'Redirect to WhatsApp', 'formipay' )
),
'value' => 'thankyou',
),
'redirect_url' => array(
'type' => 'text',
'label' => __( 'Redirect URL', 'formipay' ),
'dependency' => array(
'key' => 'submit_action_type',
'value' => 'redirect'
)
),
'whatsapp_message' => array(
'type' => 'hint_textarea',
'label' => __( 'Content', 'formipay' ),
'hints' => $hints,
'dependency' => array(
'key' => 'submit_action_type',
'value' => 'whatsapp'
),
),
'whatsapp_admin' => array(
'type' => 'text',
'label' => __( 'Send to WhatsApp Number', 'formipay' ),
'dependency' => array(
'key' => 'submit_action_type',
'value' => 'whatsapp'
),
'description' => sprintf( 'Use country code without + sign.
True: 62812xx
False: +62812xx', 'formipay' )
),
'thankyou_screen_width' => array(
'type' => 'number',
'label' => __( 'Screen Width', 'formipay' ),
'value' => '600',
'dependency' => array(
'key' => 'submit_action_type',
'value' => 'thankyou'
),
),
'thankyou_screen_content' => array(
'type' => 'tinymce',
'label' => __( 'Content', 'formipay' ),
'value' => '
Here is your order details:
{{form_submission}}
Your order status is {{order_status}}
{{payment_details}}