Support » Plugin: WooCommerce » Adding a new admin settings field type

  • I would like to add a new field type option to the admin settings.

    I applied the action hook along with the following code but I do not see the field type option showing.

    Could I have some assistance please to get this to work. Thank you.

    Code below is what I have so far.

    /* New field type - single_select_product */
    add_action('woocommerce_admin_field_single_select_product', 'single_select_product_field');
    	function single_select_product_field($value){
    			// Single product selects
    			case 'single_select_product' :
    			$args = array(
    						'name' => $value['id'],
    						'id' => $value['id'],
    						'sort_column' => 'menu_order',
    						'sort_order' => 'ASC',
    						'show_option_none' 	=> ' ',
    						'class' => $value['class'],
    						'echo' => false,
    						'selected' => absint(woocommerce_settings_get_option($value['id'])),
    						'post_type' => 'product'
    				$args = wp_parse_args($value['args'], $args);
    			?><tr valign="top" class="single_select_product">
    				<th scope="row" class="titledesc"><?php echo esc_html($value['title']); ?> <?php echo $tip; ?></th>
    				<td class="forminp">
    				<?php echo str_replace(' id=', " data-placeholder='".__('Select a product&hellip;', 'wc_auctions')."' style='".$value['css']."' class='".$value['class']."' id=", wp_dropdown_pages($args)); ?> <?php echo $description; ?>

  • The topic ‘Adding a new admin settings field type’ is closed to new replies.