Only set user first and last names when those fields are empty

This commit is contained in:
Claudio Sanches 2019-02-20 13:55:51 -03:00
parent 7fb12465dd
commit efaa723a5b
1 changed files with 3 additions and 3 deletions

View File

@ -989,17 +989,17 @@ class WC_Checkout {
if ( $customer_id && apply_filters( 'woocommerce_checkout_update_customer_data', true, $this ) ) {
$customer = new WC_Customer( $customer_id );
if ( ! empty( $data['billing_first_name'] ) ) {
if ( ! empty( $data['billing_first_name'] ) && '' === $customer->get_first_name() ) {
$customer->set_first_name( $data['billing_first_name'] );
}
if ( ! empty( $data['billing_last_name'] ) ) {
if ( ! empty( $data['billing_last_name'] ) && '' === $customer->get_last_name() ) {
$customer->set_last_name( $data['billing_last_name'] );
}
// If the display name is an email, update to the user's full name.
if ( is_email( $customer->get_display_name() ) ) {
$customer->set_display_name( $data['billing_first_name'] . ' ' . $data['billing_last_name'] );
$customer->set_display_name( $customer->get_first_name() . ' ' . $customer->get_last_name() );
}
foreach ( $data as $key => $value ) {