[WOOMOB-359] Fix customer mapper copying billing address into shipping fields#15575
Open
[WOOMOB-359] Fix customer mapper copying billing address into shipping fields#15575
Conversation
WCCustomerMapper.mapToModel() was mapping dto.billing fields into all shipping address fields instead of dto.shipping. The reverse mapping in mapToDTO() had the same bug. This caused registered customers selected during order creation to always show billing address data in both billing and shipping fields, even when the API returned distinct addresses. Updated tests to use distinct billing/shipping values so the bug would actually be caught.
Collaborator
|
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## trunk #15575 +/- ##
=========================================
Coverage 39.61% 39.61%
Complexity 11330 11330
=========================================
Files 2260 2260
Lines 130516 130516
Branches 18298 18298
=========================================
Hits 51700 51700
Misses 73522 73522
Partials 5294 5294 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Description
Partially addresses WOOMOB-359
WCCustomerMapper.mapToModel()was mappingdto.billingfields into all shipping address fields instead ofdto.shipping. The reverse mapping inmapToDTO()had the same bug — it wrotemodel.billing*fields into theShippingDTO.This meant that when a registered customer was selected during order creation, the app fetched their full data from
/wc/v3/customers/{id}(which returns separate billing and shipping objects), but then threw away the shipping data and duplicated billing into both addresses.What this fixes: Registered customers (those with a WordPress user account,
user_id > 0) now correctly get their shipping address populated from the API response.What this does NOT fix: Guest customers found via the analytics API (
wc-analytics/reports/customers) still show billing data in both address fields. This is because the analytics API returns only a single flat set of address fields — there is no shipping address in the response. Fixing that requires either backend changes or switching to a different API endpoint (see the peaMlT-16R-p2 for details).The existing tests used identical values for billing and shipping, so they never caught this bug. Updated them to use distinct values.
Test Steps
Images/gif
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.