Changing the order of custom fields in the dashboard for Woocommerce variable products

enter image description here

I followed this quick/well laid out wordpress tutorial for adding custom fields to WooCommerce variations.

WooCommerce Custom Fields for Variations

Everything worked great…

However the method for inserting the field into the dashboard (product edit) area doesn’t mention how to change the order of the field as seen in the dashboard.
.

// Add Variation Settings
add_action( 'woocommerce_product_after_variable_attributes', 'variation_settings_fields', 10, 3 );
// Save Variation Settings
add_action( 'woocommerce_save_product_variation', 'save_variation_settings_fields', 10, 2 );

function variation_settings_fields( $loop, $variation_data, $variation ) {
    // Text Field
    woocommerce_wp_text_input( 
        array( 
            'id'          => '_text_field[' . $variation->ID . ']', 
            'label'       => __( 'My Text Field', 'woocommerce' ), 
            'placeholder' => 'http://',
            'desc_tip'    => 'true',
            'description' => __( 'Enter the custom value here.', 'woocommerce' ),
            'value'       => get_post_meta( $variation->ID, '_text_field', true )
        )
    );

}

function save_variation_settings_fields( $post_id ) {
    // Text Field
    $text_field = $_POST['_text_field'][ $post_id ];
    if( ! empty( $text_field ) ) {
        update_post_meta( $post_id, '_text_field', esc_attr( $text_field ) );
    }
}

Any help would be much appreciated!

Read more here:: Changing the order of custom fields in the dashboard for Woocommerce variable products

Leave a Reply

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