Skip to content

Commit 396948d

Browse files
authored
Shipping Labels: Filter virtual products from the default shipment (#16127)
2 parents 83960f2 + 23b1515 commit 396948d

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

Modules/Sources/Yosemite/Model/Storage/Order+ReadOnlyConvertible.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ extension Storage.Order: ReadOnlyConvertible {
8282
let orderCustomFields = customFields?.map { $0.toReadOnly() } ?? [Yosemite.MetaData]()
8383
let orderGiftCards = appliedGiftCards?.map { $0.toReadOnly() } ?? [Yosemite.OrderGiftCard]()
8484
let orderShippingLabels = shippingLabels?.map { $0.toReadOnly() } ?? [Yosemite.ShippingLabel]()
85-
let orderShipments = shipments?.map { $0.toReadOnly() } ?? [Yosemite.WooShippingShipment]()
8685

8786
return Order(siteID: siteID,
8887
orderID: orderID,

RELEASE-NOTES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
23.3
55
-----
6+
- [*] Order details: Display only physical items in the Shipping Labels section. [https://github.com/woocommerce/woocommerce-ios/pull/16127]
67
- [internal] Address deprecated view modifiers usage following iOS17 API updates [https://github.com/woocommerce/woocommerce-ios/pull/16080]
78

89
23.2

WooCommerce/Classes/ViewModels/Order Details/OrderDetailsDataSource.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,13 +1241,18 @@ extension OrderDetailsDataSource {
12411241
siteID: order.siteID,
12421242
orderID: order.orderID,
12431243
index: "0",
1244-
items: order.items.map { item in
1245-
var subItems: [String] = []
1246-
for index in 0..<item.quantity.intValue {
1247-
subItems.append("\(item.itemID)-sub-\(index)")
1244+
items: order.items
1245+
.filter { item in
1246+
let matchingProduct = products.first(where: { $0.productID == item.productOrVariationID })
1247+
return matchingProduct?.virtual == false
12481248
}
1249-
return WooShippingShipmentItem(id: item.itemID, subItems: subItems)
1250-
},
1249+
.map { item in
1250+
var subItems: [String] = []
1251+
for index in 0..<item.quantity.intValue {
1252+
subItems.append("\(item.itemID)-sub-\(index)")
1253+
}
1254+
return WooShippingShipmentItem(id: item.itemID, subItems: subItems)
1255+
},
12511256
shippingLabel: nil
12521257
)]
12531258
}()

0 commit comments

Comments
 (0)