WooCommerce - excelling eCommerce
Adding a new admin settings field type (1 post)

  1. Sebastien Dumont
    Posted 2 years ago #

    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; ?>


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

  • RSS feed for this topic
  • Started 2 years ago by Sebastien Dumont
  • This topic is not resolved
  • WordPress version: 3.5.2