How to merge first name and last name into one field in WooCommerce checkout

Because the default name is first and last name at the time of WordPress checkout, it is not in line with the habits of Chinese people, but in addition to adding the plug-in program adjustment order in Functions.php under the theme directory, you can also install the visual adjustment order Hidden fields, but what this chapter describes is to simply merge the last name into a column in the checkout field.

The principle is very simple, that is, when the customer logs in, the customer’s first name + first name is pulled in to cover the last name field of the checkout field.

1. Determine if the member is logged in, if there is a login, the member's last name will be retrieved
2. Use wp_get_current_user to get the login member information
3. Get user_lastname, user_firstname
4. Use jQuery to put the first name and last name into the value of billing_last_name
*/
add_filter('woocommerce_before_checkout_billing_form','apply_username_field',10);
function apply_username_field() {
  if ( is_user_logged_in() ) {
     $current_user = wp_get_current_user();
     //If the billing surname is not empty
     if ($current_user->billing_last_name!='') {
     	  //If the billing surname is already integrated
        if (strrpos($current_user->billing_last_name.'^',$current_user->billing_first_name)) {
           //Just take the bill last name field
           $lastname = $current_user->billing_last_name;
        }
        else {
        	 //Just take the bill last name field
           $lastname = $current_user->billing_last_name.$current_user->billing_first_name;
        }
     }
     else {
     //If the bill is not empty, the first shopping
     	  //If the registered surname is already integrated
        if (strrpos($current_user->user_lastname.'^',$current_user->user_firstname)) {
        	//Just take the registered last name field
          $lastname = $current_user->user_lastname;
        }
        else {
        	//Combine the registered last name and first name fields
          $lastname = $current_user->user_lastname.$current_user->user_firstname;
        }
     }

     $billing_phone=$current_user->billing_phone;
     //If the billing phone does not include 09
     if (substr($billing_phone,0,2)!='09') {
     	  //Get registered mobile phone
        $billing_phone=$current_user->mobile_number;
     }

     $billing_email=$current_user->billing_email;
     //If the bill E-Mail does not contain @
     if (!strrpos($billing_email.'^','@')) {
     	  //Get from registeration
        $billing_email=$current_user->user_email;
     }

     $output = '
     ';
     echo $output;
  }
}

In this way, the customer’s name is continuous, but this example does not hide the checkout name field, except for the hidden method.
WordPress: Hide address field when picking up goods at “7-11” checkout

You can also install this plugin WooCommerce Checkout Field Editor
This plug-in can be visually adjusted directly, hiding unwanted checkout fields and adjusting the order of the fields