I wrote code to add a custom tab in the WooCommerce setting section page:
add_filter('woocommerce_settings_tabs_array', array($this, 'my_custom_settings_tabs_array'), 99);
add_action('woocommerce_settings_my_custom', array($this, 'action_woocommerce_settings_my_custom'), 10);
add_action('woocommerce_settings_save_my_custom', array($this, 'action_woocommerce_settings_save_my_custom'), 10);
I want to add an image uploader in my custom tab here
public function get_custom_settings()
{
global $current_section;
$settings = array();
// My section 1
$settings = array(
// Title
array(
'title' => __('Table Style Setting', ''),
'type' => 'title',
'id' => 'my_custom_setting_heading'
),
// Text input
array(
'title' => __('Change the text on the top of Table', 'text-domain'),
'type' => 'text',
'desc_tip' => false,
'id' => 'koala_bmsm_general_settings[tb_top_text]',
'css' => 'min-width:300px;'
),
// Section end
array(
'type' => 'sectionend',
'id' => 'custom_settings_overview'
),
);
return $settings;
}
2
Answers
You can add the upload field by adding the given code to
$settings
array.Please let me know if this helps.
You need to make some code modifications like below
1. Add new field in
$settings
array.2. Create Upload file backend code
Please let me know if this could help you.