I don't know how to add username field in registration page. There is no settings about this also. Used to be there is a setting about adding a username field but not now how could i add username field in woocommerce registration i already tried to code but it doesn't work. I tried to add the code like this;
add_action( 'woocommerce_register_form_start', 'custom_woocommerce_register_username' ); function custom_woocommerce_register_username() { ?> <p class="form-row form-row-wide"> <label for="reg_username"><?php _e( 'Username', 'woocommerce' ); ?> <span class="required">*</span></label> <input type="text" class="input-text" name="username" id="reg_username" value="<?php if ( ! empty( $_POST['username'] ) ) echo esc_attr( $_POST['username'] ); ?>" /> </p> <?php } // Kullanıcı adı alanının zorunlu olmasını sağlama add_filter( 'woocommerce_registration_errors', 'custom_woocommerce_registration_errors_username', 10, 3 ); function custom_woocommerce_registration_errors_username( $errors, $username, $email ) { if ( isset( $_POST['username'] ) && empty( $_POST['username'] ) ) { $errors->add( 'username_error', __( 'Username is required!', 'woocommerce' ) ); } return $errors; } // Kayıt sırasında kullanıcı adını kaydetme add_action( 'woocommerce_created_customer', 'custom_save_registration_fields_username' ); function custom_save_registration_fields_username( $customer_id ) { if ( isset( $_POST['username'] ) ) { wp_update_user( array( 'ID' => $customer_id, 'user_login' => sanitize_text_field( $_POST['username'] ) ) ); } }