fix(ras-sync): account for missing creation data and first/last name #3677
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
Avoids a fatal and accounts for some missing user meta when building contact data for migrated Woo customers. This seems to be an edge case with migrated/imported users as "naturally created" WP users should always have a
user_registered
value, but we've seen that in rare cases imported users can lack this value.How to test the changes in this Pull Request:
Since it's impossible to delete the
user_registered
value from a user once created, we need to usewp shell
to simulate the conditions for the error.release
, usewp shell
to delete thedate_created
value and the First and Last Name meta fields from the user (replace56
with your test user's ID):wp shell
session, get the contact data and observe a fatal error:wp shell
session, and repeat. This time confirm that the contact data gets built, but without aregistration_date
value:get_contact_from_customer
the billing first/last names are copied to thefirst_name
andlast_name
user meta fields (this happens automatically when a new user is created during the checkout flow). You can check this in the User admin page for this user, or viawp user meta list <user ID>
in WP CLI.Other information: