Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Shipping labels] Add WooShippingAddressField to represent an address field #14949

Merged
merged 8 commits into from
Jan 23, 2025

Conversation

rachelmcr
Copy link
Contributor

Part of: #13781

Description

This PR does not change the current behavior, but it encapsulates the logic for an address field in the Woo Shipping flow into WooShippingAddressField. This new type holds the field's type, its value, whether it's required, the method for validating its value, and whether it has a validation error. (This requires quite a few lines of changes to support moving the logic to the new type.)

This change simplifies how the view handles these fields: we can pass each field to its corresponding AddressTextField or AddressSelection view and use the field to populate those child views.

In the view model, each field is now a WooShippingAddressField (rather than a String for the field value). The view model is now focused on defining the rules for validating each field and handling special cases where one field depends on another (e.g. name and company fields, or state and country fields).

These changes will facilitate the validation UI behavior outlined in #14943 and hopefully make it easier to understand and maintain the logic around each field.

Testing information

For now, the validation logic isn't yet used in the UI. However, you can confirm that UI works the same as before:

  1. Ensure the latest production version of WooCommerce Shipping (Version 1.3.2) is installed, activated, and set up on your store.
  2. Create or open an order with at least one physical product and the processing status.
  3. Tap "Create Shipping Label" in order details.
  4. Open the "Shipment details" bottom sheet.
  5. Tap the "Ship from" origin address.
  6. Tap the edit (pencil) icon on one of the origin addresses.
  7. In the edit address sheet, confirm the name is marked as required unless a company is entered.
  8. Confirm the company is marked as required unless a name is entered.
  9. Confirm the state is marked as required when a country with states is selected (e.g. USA), and is optional for countries without states.
  10. Confirm all field labels and values are displayed as expected.

Screenshots

Opening the form Optional company Optional name Required state Optional state
Simulator Screenshot - iPhone 16 Pro - 2025-01-22 at 18 09 05 Simulator Screenshot - iPhone 16 Pro - 2025-01-22 at 18 09 08 Simulator Screenshot - iPhone 16 Pro - 2025-01-22 at 18 09 18 Simulator Screenshot - iPhone 16 Pro - 2025-01-22 at 18 09 39 Simulator Screenshot - iPhone 16 Pro - 2025-01-22 at 18 09 26

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

@rachelmcr rachelmcr added the feature: shipping labels Related to creating, ordering, or printing shipping labels. label Jan 22, 2025
@rachelmcr rachelmcr added this to the 21.5 milestone Jan 22, 2025
@dangermattic
Copy link
Collaborator

2 Warnings
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
⚠️ This PR is assigned to the milestone 21.5. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 22, 2025

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

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr14949-f6f9c2e
Version21.4
Bundle IDcom.automattic.alpha.woocommerce
Commitf6f9c2e
App Center BuildWooCommerce - Prototype Builds #12651
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@toupper toupper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚢 :shipit:

@rachelmcr rachelmcr merged commit b7e8651 into trunk Jan 23, 2025
12 checks passed
@rachelmcr rachelmcr deleted the issue/13781-address-field-type branch January 23, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: shipping labels Related to creating, ordering, or printing shipping labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants