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] Set selected package from "Add Package" flow #14558

Merged
merged 3 commits into from
Nov 29, 2024

Conversation

rachelmcr
Copy link
Contributor

Part of: #14522

Description

We want to display the selected package from the "Select a Package" section on the main shipping label screen in the Woo Shipping label creation flow.

This PR connects the "Select a Package" flow with the main screen's view model, so the selected package can be used on the main screen.

For now, this loads the label rates in the Shipping Services section. A future PR will also add the UI to display the selected package details and allow the shipment weight to be updated.

How

  • In WooShippingPackageAndRatePlaceholder, the WooShippingAddPackageView passes back the package data for the selected package. Now, that placeholder view has an onSelectPackage closure to handle that data.
  • In WooShippingCreateLabelsViewModel, we now have a selectPackage(_:) method that accepts package data.
    • The new method is passed to the WooShippingPackageAndRatePlaceholder view.
    • When this method is called, it transforms the package data into ShippingLabelPackageSelected, which is used to make calls to the backend that require the selected package. This method also loads the shipping rates for the selected package.
  • Changes to support custom packages in calls to the backend:
    • In WooShippingAddCustomPackageViewModel we now set the ID for a custom package as the package name. The backend expects the custom package ID to be its name.
    • If the custom package doesn't have a name set (i.e. if it hasn't been saved as a template) we use the default ID of 0 when encoding it for remote requests. This is to match the endpoint behavior discussed with the extension team (see p1731538721371119-slack-C05VBLKHHV1).

Testing information

Prerequisite: The Woo Shipping extension is active on your store and you have at least one order eligible for a shipping label (with processing status and at least one physical product).

  1. Enable the revampedShippingLabelCreation feature flag.
  2. Build and run the app.
  3. Go to the Orders tab.
  4. Select an order eligible for a shipping label.
  5. Tap "Create Shipping Label."
  6. Tap "Select a package."
  7. Enter custom package details or select a carrier package, and then tap "Add a package."
  8. Confirm you are taken back to the main shipping label screen and the Shipping Service section appears and loads rates for your selected package.

Screenshots

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-11-28.at.18.02.18.mp4

  • 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 Nov 28, 2024
@rachelmcr rachelmcr added this to the 21.3 milestone Nov 28, 2024
Base automatically changed from issue/14522-handle-selected-package-changes to trunk November 28, 2024 18:07
@rachelmcr rachelmcr force-pushed the issue/14522-set-selected-package branch from 83a0c38 to 225937c Compare November 28, 2024 18:14
@rachelmcr
Copy link
Contributor Author

@bozidarsevo I wanted to get your review on this PR because it's linking the package data from the WooShippingAddPackageView to the main screen. Please let me know if you have any suggestions or concerns about how the package data is being handled here.

I'm also happy to wait to merge this PR until #14499 is merged, to deal with any conflicts.

@wpmobilebot
Copy link
Collaborator

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 Numberpr14558-225937c
Version21.2
Bundle IDcom.automattic.alpha.woocommerce
Commit225937c
App Center BuildWooCommerce - Prototype Builds #11843
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

Copy link
Contributor

@bozidarsevo bozidarsevo left a comment

Choose a reason for hiding this comment

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

I think we can merge this PR before mine, it will be easier to update conflicts in mine (if there will be some) 👍

@@ -25,7 +29,7 @@ struct WooShippingPackageAndRatePlaceholder: View {
.roundedBorder(cornerRadius: Layout.borderCornerRadius, lineColor: Color(.border), lineWidth: Layout.borderLineWidth, dashed: true)
.sheet(isPresented: $showAddPackage) {
WooShippingAddPackageView { packageData in
// TODO: use packageData
onSelectPackage(packageData)
Copy link
Contributor

Choose a reason for hiding this comment

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

Happy that we can finally remove this TODO 🥳

@rachelmcr rachelmcr merged commit 7960591 into trunk Nov 29, 2024
14 checks passed
@rachelmcr rachelmcr deleted the issue/14522-set-selected-package branch November 29, 2024 10:37
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.

3 participants