• Hi!! I have added a custom field for products in the dashboard, but I’m wondering is there way to change the ordering of it. Now it goes below the other fields.

    This is my code in functions.php

    // Display Fields
    add_action( 'woocommerce_product_options_inventory_product_data', 'woo_add_custom_inventory_fields' );
    
    // Save Fields
    add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' );
    
    function woo_add_custom_inventory_fields() {
    
      global $woocommerce, $post;
      
      echo '<div class="options_group">';
      
      // Text Field
      woocommerce_wp_text_input( 
      array( 
        'id'          => '_text_field', 
        'label'       => __( 'My custom field', 'woocommerce' ), 
        'placeholder' => '12345',
        'desc_tip'    => 'true',
        'description' => __( 'My Custom field description', 'woocommerce' ) 
      )
    );
      
      echo '</div>';
      
    }
    
    function woo_add_custom_general_fields_save( $post_id ){
      
      // Text Field
      $woocommerce_text_field = $_POST['_text_field'];
      if( !empty( $woocommerce_text_field ) )
        update_post_meta( $post_id, '_text_field', esc_attr( $woocommerce_text_field ) );
    }
    
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change field order of custom fields in dashboard’ is closed to new replies.