-
Notifications
You must be signed in to change notification settings - Fork 121
[Shipping Labels] Fix missing origin address for previously purchased shipping labels #15872
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
Changes from 6 commits
9662997
3f56eb8
ebf45ac
5523d9c
a90f057
8236d66
548904a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,24 @@ | ||
| import Foundation | ||
|
|
||
| extension WooShippingLabelData { | ||
| static func mapDestinations( | ||
| _ destinations: WooShippingLabelDestinations, | ||
| static func mapAddresses( | ||
| origins: WooShippingLabelAddressMap?, | ||
| destinations: WooShippingLabelAddressMap?, | ||
| into labels: [ShippingLabel] | ||
| ) -> [ShippingLabel] { | ||
| return labels.map { label in | ||
| guard | ||
| let shipmentID = label.shipmentID, | ||
| let destinationAddress = destinations[ | ||
| WooShippingShipmentIDFormatter.formattedShipmentID(shipmentID) | ||
| ] ?? destinations[shipmentID] /// Fallback for ids previously submitted without `shipment_<id>` formatting | ||
| else { | ||
| guard let shipmentID = label.shipmentID else { | ||
| return label | ||
| } | ||
|
|
||
| return label.copy(destinationAddress: destinationAddress.toShippingLabelAddress()) | ||
| let formattedID = WooShippingShipmentIDFormatter.formattedShipmentID(shipmentID) | ||
| let originAddress = origins?[formattedID] ?? origins?[shipmentID] | ||
| let destinationAddress = destinations?[formattedID] ?? destinations?[shipmentID] | ||
|
|
||
| return label.copy( | ||
| originAddress: originAddress?.toShippingLabelAddress() ?? .copy, | ||
| destinationAddress: destinationAddress?.toShippingLabelAddress() ?? .copy | ||
| ) | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -374,10 +374,13 @@ private extension WooShippingCreateLabelsView { | |
| Text(Localization.BottomSheet.shipFrom) | ||
| .trackSize(size: $shipmentDetailsShipFromSize) | ||
|
|
||
| if viewModel.canViewLabel, | ||
| let addressLines = viewModel.originAddressLines { | ||
| AddressLinesView(addressLines: addressLines) | ||
| .frame(maxWidth: .infinity, alignment: .leading) | ||
| if viewModel.canViewLabel { | ||
| AddressLinesView( | ||
| addressLines: viewModel.originAddressLines ?? | ||
| /// Fallback to `originAddress` in case if `originAddressLines` are missing | ||
| [viewModel.originAddress] | ||
|
||
| ) | ||
| .frame(maxWidth: .infinity, alignment: .leading) | ||
| } else { | ||
| VStack(alignment: .leading) { | ||
| Button { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider applying the same fix as suggested here to support the array case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implemented in a separate PR: [Shipping Labels] Handle address array in selected_destination and selected_origin