Fix: Customer details are incorrect after opening customer search in order creation #16055
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.

WOOMOB-1045
Description
Customer details are incorrect after opening the customer search in order creation.
This issue led me down a confusing path of figuring out how customers work in the WooCommerce iOS app. There are two main types:
WCAnalyticsCustomerfrom thewc-analytics/customerendpoint, andCustomerfrom the/customers/{user_id}endpoint.WCAnalyticsCustomerrepresents customers created when placing an order, whileCustomerrepresents registered site users (wp-admin-> users). These can be linked throughWCAnalyticsCustomer.user_id(which points toCustomer.id), andCustomer.id(which matchesWCAnalyticsCustomer.customerID). Theuser_idis0if the analytics customer is not a registered WordPress user.It gets more complicated on iOS. Even when calling the
wc-analytics/customerendpoint, the app persists data in bothStorage.WCAnalyticsCustomerandStorage.Customer. The nameStorage.Customersuggests it represents aCustomerfrom/customers/, but in practice it is a shared aggregate object combining data from bothWCAnalyticsCustomerandCustomer.The problem is that
Storage.Customeronly has a single identifier,customerID. Sometimes this field stores thecustomerIDvalue, and other times it stores theuserIDvalue. The app uses these values interchangeably, which creates inconsistencies. For example,retrieveCustomerasks for acustomerIDparameter by name, but actually requires the WordPressuserIDto succeed. This kind of mismatch appears throughout theCustomerimplementation in the app. Also, given that both of these types are updated from one another, some data losses in the conversion process are possible.This made it difficult to identify the real cause of the bug. In the end, it came from the fact that we create
Storage.CustomerfromWCAnalyticsCustomerduring order creation with incomplete mapping, and later useStorage.CustomerwithinMenu -> Customers -> Details:wc-analytics/customerscall is madeStorage.Customerentities are deletedStorage.Customeris re-inserted and mapped withwc-analytics/customersdata, but shipping information is not setMenu -> Customerslist showsWCAnalyticsCustomerdata, but when tapping on a customer, the details come fromStorage.Customer(which had been deleted and remapped without shipping information after opening the order).I’m applying a simpler fix first, but I also plan to introduce a larger refactor to bring more clarity to the codebase. Hopefully, this will also uncover other hidden issues in the process:
userIDandcustomerID#16056Do you want me to also make it slightly more structured for a GitHub issue/PR description (with headings like Background, Problem, Root Cause, Fix)? That would make it easier for reviewers to parse.
Steps to reproduce
Testing information
iPad Air 18.5 simulator, tested with WordPress and guest users
Screenshots
Simulator.Screen.Recording.-.iPad.Pro.11-inch.M4.-.2025-08-28.at.23.02.29.mov
RELEASE-NOTES.txtif necessary.