3
votes

I hope someone can help me!

I'd like to change the customer name order in woocommerce in dashboard.

I use this code and it's works fine but the billing and shipping order name is still in the wrong order:

    function wp_update_display_name ( $user_login, $user ) {
      $user_info = get_userdata($user->ID);
      $first_name = $user_info->first_name;
      $last_name = $user_info->last_name;

      wp_update_user(array('ID' => $user->ID, 'display_name' => $last_name . ' '. $first_name));
}

add_action('wp_login', 'wp_update_display_name', PHP_INT_MAX, 2);

I use a billing software which is connected to Woo via API. The name order is in the wrong order in the billing software too.

Edit: Present state is [firstname] [lastname]. I live in Hungary where the order is [lastname] [firstname].

Please help me, Benjamin

1
What do you mean by "Name Order" What does it look like at present, and what do you expect it to look like? - Dragonthoughts
Present state is [firstname] [lastname]. I live in Hungary where the order is [lastname] [firstname]. I'll edit the post, thanks :) - Kőhidi Benjamin
Similar will apply to names in Asia - Dragonthoughts

1 Answers

2
votes

I had the same issue. First I found this link, but changing the priority only did not help. After some inspection this is what I did:

$checkout_fields['billing']['billing_first_name']['priority'] = 20;  
$checkout_fields['billing']['billing_first_name']['class'][0] = 'form-row-last';
$checkout_fields['billing']['billing_last_name']['priority'] = 10;
$checkout_fields['billing']['billing_last_name']['class'][0] = 'form-row-first';

It worked fine for me!