Skip to content

[WOOMOB-359] Fix customer mapper copying billing address into shipping fields#15575

Open
kidinov wants to merge 2 commits intotrunkfrom
issue/WOOMOB-359-fix-customer-shipping-mapper
Open

[WOOMOB-359] Fix customer mapper copying billing address into shipping fields#15575
kidinov wants to merge 2 commits intotrunkfrom
issue/WOOMOB-359-fix-customer-shipping-mapper

Conversation

@kidinov
Copy link
Copy Markdown
Contributor

@kidinov kidinov commented Mar 27, 2026

Description

Partially addresses WOOMOB-359

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 — it wrote model.billing* fields into the Shipping DTO.

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

  1. On a WooCommerce site, ensure you have a registered customer with different billing and shipping addresses
  2. Start a new order creation
  3. Tap "Add customer details"
  4. Select the registered customer (the one with a username shown)
  5. Verify that Shipping Address shows the actual shipping data
  6. Verify that Billing Address shows the actual billing data
  7. Confirm the two addresses are different

Images/gif

Screenshot 2026-03-27 at 15 13 17 image
  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

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.
@kidinov kidinov added type: bug A confirmed bug. feature: order creation Related to the Order Creation feature labels Mar 27, 2026
@kidinov kidinov added this to the 24.6 milestone Mar 27, 2026
@kidinov kidinov requested a review from samiuelson March 27, 2026 14:19
@kidinov kidinov modified the milestones: 24.6, 24.5 Mar 27, 2026
@kidinov kidinov requested a review from malinajirka March 27, 2026 14:21
@kidinov kidinov marked this pull request as ready for review March 27, 2026 14:22
@wpmobilebot
Copy link
Copy Markdown
Collaborator

App Icon📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Build Number736
Version24.4-rc-1
Application IDcom.woocommerce.android.prealpha
Commit7507085
Installation URL67ikd83g05cdg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.61%. Comparing base (4594cda) to head (7507085).
⚠️ Report is 3 commits behind head on trunk.

Files with missing lines Patch % Lines
...s/android/fluxc/model/customer/WCCustomerMapper.kt 50.00% 0 Missing and 9 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: order creation Related to the Order Creation feature type: bug A confirmed bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants