0
    // Create tab
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' , 99 , 1 );
function add_my_custom_product_data_tab( $product_data_tabs ) {
    $product_data_tabs['my-custom-tab'] = array
    (
        'label' => __( 'XColor', 'my_text_domain' ),
        'target' => 'my_custom_product_data',
    );
    return $product_data_tabs;
}
// Create field
add_action( 'woocommerce_product_data_panels', 'add_my_custom_product_data_fields' );
function add_my_custom_product_data_fields() {
    global $woocommerce, $post;
    ?>
    <!-- id below must match target registered in above add_my_custom_product_data_tab function -->
    <div id="my_custom_product_data" class="panel woocommerce_options_panel">
        <?php
        woocommerce_wp_text_input(
            array(
                'id'          => 'xcolor_html',
                'label'       => __( 'HTML', 'woocommerce' )
            ));
        ?>
    </div>
    <?php
}
// Save field content - this don't work =(( white page
function woo_add_custom_general_fields_save( $post_id )
{
    // Text Field
    $woocommerce_text_field = $_POST['xcolor_html'];
    if (!empty($woocommerce_text_field))
        update_post_meta($post_id, 'xcolor_html', esc_attr($woocommerce_text_field));
}
// Show field content on product page
add_action( 'woocommerce_single_product_summary', 'woocommerce_xcolor', 15 );
function woocommerce_xcolor(){
    echo get_post_meta( get_the_ID(), 'xcolor_html', true );
}

enter image description here

closed as off-topic by fuxia Jan 17 '17 at 4:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

2

What about the save hook? woocommerce_process_product_meta

add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
  • I wish you a good day) – Whisper Jan 17 '17 at 2:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.