Updated in November 2017:
- Some bugs were fixed, the available parameters were cleared and added.
- 'Usage' ' .
1) Metabox ( "product" ),
2), ( , ).
, , , .
( 6 ):

:
add_filter( 'woocommerce_product_data_tabs', 'add_shipping_costs_product_data_tab', 99 , 1 );
function add_shipping_costs_product_data_tab( $product_data_tabs ) {
$product_data_tabs['shipping-costs'] = array(
'label' => __( 'Shipping costs', 'my_theme_domain' ),
'target' => 'shipping_costs_product_data',
);
return $product_data_tabs;
}
add_action( 'woocommerce_product_data_panels', 'add_shipping_costs_product_data_fields' );
function add_shipping_costs_product_data_fields() {
global $post;
$post_id = $post->ID;
echo '<div id="shipping_costs_product_data" class="panel woocommerce_options_panel">';
woocommerce_wp_text_input( array(
'id' => '_imput_text',
'placeholder' => __( 'Enter some data', 'theme_domain' ),
'label' => __( 'Imput text Label', 'theme_domain' ),
'description' => __( 'Imput text Description', 'theme_domain' ),
'desc_tip' => true,
) );
woocommerce_wp_textarea_input( array(
'id' => '_input_textarea',
'class' => 'widefat',
'placeholder' => __( 'Enter some data', 'theme_domain' ),
'label' => __( 'Imput textarea Label', 'theme_domain' ),
'description' => __( 'Imput textarea Description', 'theme_domain' ),
'desc_tip' => true,
) );
woocommerce_wp_checkbox( array(
'id' => '_input_checkbox',
'label' => __( 'Imput checkbox Label', 'theme_domain' ),
'description' => __( 'Imput checkbox Description', 'theme_domain' ),
'desc_tip' => true,
) );
woocommerce_wp_radio( array(
'id' => '_imput_radio',
'label' => __(' ', 'my_theme_domain'),
'description' => __( 'Imput Radio Description', 'my_theme_domain' ),
'desc_tip' => true
'options' => array(
'option_value_1' => __('Displayed option 1'),
'option_value_2' => __('Displayed option 2'),
'option_value_3' => __('Displayed option 3'),
),
) );
woocommerce_wp_select( array(
'id' => '_select_field',
'label' => __(' ', 'my_theme_domain'),
'description' => __( 'Imput Radio Description', 'my_theme_domain' ),
'desc_tip' => true
'options' => array(
'' => __('Chose an option'),
'option_value_1' => __('Displayed option 1'),
'option_value_2' => __('Displayed option 2'),
'option_value_3' => __('Displayed option 3')
),
) );
woocommerce_wp_hidden_input( array(
'id' => '_hidden_input',
'class' => 'some_class',
) );
echo '</div>';
}
add_action( 'woocommerce_process_product_meta', 'shipping_costs_process_product_meta_fields_save' );
function shipping_costs_process_product_meta_fields_save( $post_id ){
if( isset( $_POST['_imput_text'] ) )
update_post_meta( $post_id, '_imput_text', esc_attr( $_POST['_imput_text'] ) ) );
if( isset( $_POST['_imput_textarea'] ) )
update_post_meta( $post_id, '_imput_textarea', esc_attr( $_POST['_imput_textarea'] ) ) );
if( isset( $_POST['_imput_checkbox'] ) )
update_post_meta( $post_id, '_imput_checkbox', esc_attr( $_POST['_imput_checkbox'] ) ) );
if( isset( $_POST['_input_radio'] ) )
update_post_meta( $post_id, '_input_radio', esc_attr( $_POST['_input_radio'] ) ) );
if( isset( $_POST['_select_field'] ) )
update_post_meta( $post_id, '_select_field', esc_attr( $_POST['_select_field'] ) ) );
if( isset( $_POST['_hidden_input'] ) )
update_post_meta( $post_id, '_hidden_input', esc_attr( $_POST['_hidden_input'] ) );
}
, functions.php ( ) .
2 3 ( slug).
, , 2.
, get_post_meta() ID:
$custom_field_data = get_post_meta( $post_id, '_custom_field_slug', true );
:
$post_id - ( , , ... post-types).custom_field_slug - (slug) .true false: ( )
. ( )
(_slug_name) slug , Metabox ( "" ).
( input_text ):

: