Skip to content

Shipping Labels: Show shipment details on order details screen #15889

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

Merged
merged 34 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
a320b96
Register hosting cell for shipment details
itsmeichigo Jul 9, 2025
04be29a
Make refund completion handler reusable
itsmeichigo Jul 9, 2025
b2de8cd
Display new cells for woo shipping shipments
itsmeichigo Jul 9, 2025
2bb36e4
Add cancel button for customs form printing view
itsmeichigo Jul 9, 2025
b266b5b
Update title mode for customs form printing view
itsmeichigo Jul 9, 2025
a1370da
Navigate to the correct shipment when tapping Create shipping labels
itsmeichigo Jul 10, 2025
4069d95
Register hosting cell for shipment details
itsmeichigo Jul 9, 2025
e016d65
Make refund completion handler reusable
itsmeichigo Jul 9, 2025
53a1dad
Display new cells for woo shipping shipments
itsmeichigo Jul 9, 2025
2a985b7
Add cancel button for customs form printing view
itsmeichigo Jul 9, 2025
574cbf0
Update title mode for customs form printing view
itsmeichigo Jul 9, 2025
1229d89
Navigate to the correct shipment when tapping Create shipping labels
itsmeichigo Jul 10, 2025
8a62624
Fix build failures
itsmeichigo Jul 14, 2025
83bcf79
Merge branch 'woomob-754-ui-updates' of github.com:woocommerce/woocom…
itsmeichigo Jul 14, 2025
d288124
Hide label creation CTA if shipments are available
itsmeichigo Jul 14, 2025
a71288c
Show checkmark on fulfilled shipments
itsmeichigo Jul 14, 2025
2e62051
Ensure UI is updated after requesting refund
itsmeichigo Jul 14, 2025
7febdf6
Update shipment and order after purchasing label
itsmeichigo Jul 14, 2025
99df170
Remove modals from shipment cells
itsmeichigo Jul 14, 2025
05a5fb4
Remove unused variable
itsmeichigo Jul 15, 2025
031e6fc
Simplify layout for shipment details cell
itsmeichigo Jul 15, 2025
0c31b47
Handle refund action
itsmeichigo Jul 15, 2025
5453538
Handle printing customs form
itsmeichigo Jul 15, 2025
3dcfee8
Handle viewing shipment items
itsmeichigo Jul 15, 2025
90aecfa
Remove unused itemsDataSource
itsmeichigo Jul 15, 2025
9aa0612
Merge branch 'trunk' into woomob-754-ui-updates
itsmeichigo Jul 15, 2025
fc36d4f
Update background color for refund text
itsmeichigo Jul 15, 2025
c1d02d8
Upsert shipments after updating shipments
itsmeichigo Jul 15, 2025
5994c8e
Update unit tests for WooShippingStore to verify persistence logic
itsmeichigo Jul 15, 2025
5200d88
Update release notes
itsmeichigo Jul 15, 2025
fb0d3d0
Add test for checking shipment section
itsmeichigo Jul 15, 2025
7414f16
Fix incorrect section category
itsmeichigo Jul 16, 2025
6fa79d4
Update preselection logic for create label form to avoid ambiguity
itsmeichigo Jul 16, 2025
504e7b3
Merge branch 'trunk' into woomob-754-ui-updates
itsmeichigo Jul 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -400,9 +400,13 @@ private extension OrderDetailsViewController {
printNavigationController.viewControllers = [printViewController]
present(printNavigationController, animated: true)
case .createShippingLabel(let shipmentIndex):
navigateToCreateShippingLabelForm(shipmentIndex: shipmentIndex)
let preselection: WooShippingCreateLabelSelection? = {
guard let shipmentIndex else { return nil }
return .shipment(index: shipmentIndex)
}()
navigateToCreateShippingLabelForm(preSelection: preselection)
case .openShippingLabelForm(let shippingLabel):
navigateToCreateShippingLabelForm(shippingLabel: shippingLabel)
navigateToCreateShippingLabelForm(preSelection: .shippingLabel(label: shippingLabel))
case .viewShipmentItems(let shipment):
showShipmentItems(shipment: shipment)
case .refundShippingLabel(let shippingLabel):
Expand All @@ -422,7 +426,7 @@ private extension OrderDetailsViewController {
}
}

func navigateToCreateShippingLabelForm(shippingLabel: ShippingLabel? = nil, shipmentIndex: Int? = nil) {
func navigateToCreateShippingLabelForm(preSelection: WooShippingCreateLabelSelection? = nil) {
guard viewModel.dataSource.isEligibleForWooShipping else {
// Navigate to legacy shipping label creation form if Woo Shipping extension is not supported.
let shippingLabelFormVC = ShippingLabelFormViewController(order: viewModel.order)
Expand Down Expand Up @@ -452,8 +456,7 @@ private extension OrderDetailsViewController {
}

let shippingLabelCreationVM = WooShippingCreateLabelsViewModel(order: viewModel.order,
selectedShipmentIndex: shipmentIndex,
selectedShippingLabel: shippingLabel,
preselection: preSelection,
onLabelPurchase: { [weak self] markOrderComplete in
if markOrderComplete {
self?.markOrderCompleteFromShippingLabels()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ import Combine
import struct Networking.WooShippingAccountSettings
import enum Networking.DotcomError

enum WooShippingCreateLabelSelection {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

case shipment(index: Int)
case shippingLabel(label: ShippingLabel)

var selectedShippingLabel: ShippingLabel? {
switch self {
case .shipment: nil
case .shippingLabel(let label): label
}
}
}

/// Provides view data for `WooShippingCreateLabelsView`.
///
final class WooShippingCreateLabelsViewModel: ObservableObject {
Expand Down Expand Up @@ -195,8 +207,7 @@ final class WooShippingCreateLabelsViewModel: ObservableObject {

/// Initialize the view model with or without an existing shipping label.
init(order: Order,
selectedShipmentIndex: Int? = nil,
selectedShippingLabel: ShippingLabel? = nil,
preselection: WooShippingCreateLabelSelection? = nil,
currencySettings: CurrencySettings = ServiceLocator.currencySettings,
shippingSettingsService: ShippingSettingsService = ServiceLocator.shippingSettingsService,
stores: StoresManager = ServiceLocator.stores,
Expand All @@ -222,10 +233,10 @@ final class WooShippingCreateLabelsViewModel: ObservableObject {
self.splitShipmentsViewModel = splitShipmentsViewModel
self.shipments = splitShipmentsViewModel.shipments

if let selectedShippingLabel {
if let label = preselection?.selectedShippingLabel {
destinationAddressStatus = .verified
destinationAddress = selectedShippingLabel.destinationAddress.toWooShippingAddress()
originAddress = selectedShippingLabel.originAddress.formattedInlineAddress ?? ""
destinationAddress = label.destinationAddress.toWooShippingAddress()
originAddress = label.originAddress.formattedInlineAddress ?? ""
} else {
destinationAddress = getDestinationAddress(order: order, address: order.shippingAddress)
loadDestinationAddress()
Expand All @@ -244,11 +255,15 @@ final class WooShippingCreateLabelsViewModel: ObservableObject {
// After shipment configs are updated, shipments are updated with purchased label details.
// Update the selected tab now by checking the initial selected shipment index if available.
// Otherwise, compare the purchased labels with the initial selected label.
if let selectedShipmentIndex {
self.selectedShipmentIndex = selectedShipmentIndex
} else if let selectedShippingLabel,
let matchingIndex = shipments.firstIndex(where: { $0.purchasedLabel?.shippingLabelID == selectedShippingLabel.shippingLabelID }) {
self.selectedShipmentIndex = matchingIndex
switch preselection {
case .shipment(let index):
self.selectedShipmentIndex = index
case .shippingLabel(let label):
if let matchingIndex = shipments.firstIndex(where: { $0.purchasedLabel?.shippingLabelID == label.shippingLabelID }) {
self.selectedShipmentIndex = matchingIndex
}
case .none:
break
}
}
}
Expand Down