Get WooCommerce product variation attribute terms in admin products general box



PHP Snippet 1:

add_action( 'woocommerce_product_options_general_product_data', 'echo_product_id_sku_general_tab' );
function echo_product_id_sku_general_tab() {
    global $product_object;

    if( $product_object->is_type('variable') ) {
        $count = 1;

        foreach( $product_object->get_children() as $variation_id ) {
            $variation = wc_get_product($variation_id);
            $name      = array();

            foreach( $variation->get_attributes() as $taxonomy => $term_slug ) {
                $name[] = get_term_by( 'slug', $term_slug, $taxonomy )->name;
            }

            echo '<p><strong>'. sprintf( __("Variation %s Name: %s", "woocommerce"), $count, '</strong>' . implode(' - ', $name) ) .'</p>

            <p class="form-field">
            <label>' . sprintf( __("Variation %s ID", "woocommerce"), $count) . '</label>
                <input type="text" value="ID' . $variation_id . '"></input>
            </p>

            <p class="form-field">
                <label>' . sprintf( __("Variation %s SKU", "woocommerce"), $count) . '</label>
                <textarea>' . $variation->get_sku() . '</textarea>
            </p>';
            $count++;
        }
    }
}