Add Custom Admin Option For WooCommerce Products

add_action('woocommerce_product_options_general_product_data', array($this, 'wooAddCustomGeneralFields'));
add_action('woocommerce_process_product_meta', array($this, 'wooAddCustomGeneralFieldsSave'));

function wooAddCustomGeneralFields() {
	global $woocommerce, $post;
	echo '';
	// Text Field
	woocommerce_wp_text_input(
		array(
			'id' => '_deal_deadline',
			'label' => 'Deal Deadline',
			'placeholder' => '',
			'desc_tip' => 'true',
		)
	);

	// Text Field
	woocommerce_wp_text_input(
		array(
			'id' => '_deal_min',
			'label' => 'Mininum Order',
			'placeholder' => '',
			'desc_tip' => 'true',
		)
	);

	// Text Field
	woocommerce_wp_text_input(
		array(
			'id' => '_deal_max',
			'label' => 'Maximum Order',
			'placeholder' => '',
			'desc_tip' => 'true',
		)
	);

	$units_sold = get_post_meta( $post->ID, 'total_sales', true );
	
	woocommerce_wp_text_input(
		array(
			'id' => 'total_sales',
			'label' => 'Total Sales',
			'placeholder' => '',
			'desc_tip' => 'true',
			'value' => $units_sold,
			'description' => 'Changing this value may affect how woocommerce work. Just change it when really needed!'
		)
	);

	echo '';
}
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this pageEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *