Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
89348f1
Add missing properties
itsmeichigo Jul 31, 2025
25ccab4
Make some entities conform to ListItemConvertible with default implem…
itsmeichigo Jul 31, 2025
5825c4c
Replace full product objects in product list
itsmeichigo Jul 31, 2025
07f9d23
Fix swiftlint issue
itsmeichigo Jul 31, 2025
df8c1a5
Merge branch 'woomob-619-xcode-warnings-performing-io-on-the-main-thr…
itsmeichigo Aug 1, 2025
177a232
Move conversion from full object to separate file
itsmeichigo Aug 1, 2025
2e10b2f
Update tests
itsmeichigo Aug 1, 2025
8fefa69
Merge branch 'woomob-619-xcode-warnings-performing-io-on-the-main-thr…
itsmeichigo Aug 1, 2025
58de948
Unify logic for createStockText
itsmeichigo Aug 1, 2025
7962628
Revert changes made to PaginatedListSelectorViewController
itsmeichigo Aug 1, 2025
1385645
Revert changes made to SearchUICommand and related files
itsmeichigo Aug 1, 2025
3cdd596
Revert redundant changes
itsmeichigo Aug 1, 2025
c508d42
Remove redundant conformance
itsmeichigo Aug 1, 2025
ca151c9
Update release notes
itsmeichigo Aug 1, 2025
2eeae10
Merge branch 'woomob-619-xcode-warnings-performing-io-on-the-main-thr…
itsmeichigo Aug 5, 2025
cc94596
Add ProductListItem on the view layer
itsmeichigo Aug 5, 2025
6051068
Merge branch 'woomob-619-xcode-warnings-performing-io-on-the-main-thr…
itsmeichigo Aug 5, 2025
c612ea0
Remove added tests for ResultsController
itsmeichigo Aug 5, 2025
1c90859
Merge branch 'woomob-619-xcode-warnings-performing-io-on-the-main-thr…
itsmeichigo Aug 5, 2025
ce5913b
Add workaround for using simplified objects for display in list items
itsmeichigo Aug 5, 2025
42ff794
Fix swiftlint
itsmeichigo Aug 5, 2025
3c03c14
Merge branch 'trunk' into woomob-619-product-list-update
itsmeichigo Aug 7, 2025
30e5dec
Remove unused properties
itsmeichigo Aug 7, 2025
47c60a6
Merge branch 'trunk' into woomob-619-product-list-update
itsmeichigo Aug 7, 2025
54706cd
Ignore periphery for OrderDetailsProduct initializer
itsmeichigo Aug 7, 2025
21bb2e8
Restore initializer for ProductDetailsCellViewModel
itsmeichigo Aug 7, 2025
39a54d1
Remove unused property
itsmeichigo Aug 7, 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
6 changes: 5 additions & 1 deletion Modules/Sources/Fakes/Networking.generated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1162,13 +1162,17 @@ extension Networking.ProductListItem {
sku: .fake(),
price: .fake(),
virtual: .fake(),
manageStock: .fake(),
stockQuantity: .fake(),
stockStatusKey: .fake(),
reviewsAllowed: .fake(),
averageRating: .fake(),
ratingCount: .fake(),
images: .fake(),
addOns: .fake()
addOns: .fake(),
variations: .fake(),
bundleStockStatus: .fake(),
bundleStockQuantity: .fake()
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1982,13 +1982,17 @@ extension Networking.ProductListItem {
sku: NullableCopiableProp<String> = .copy,
price: CopiableProp<String> = .copy,
virtual: CopiableProp<Bool> = .copy,
manageStock: CopiableProp<Bool> = .copy,
stockQuantity: NullableCopiableProp<Decimal> = .copy,
stockStatusKey: CopiableProp<String> = .copy,
reviewsAllowed: CopiableProp<Bool> = .copy,
averageRating: CopiableProp<String> = .copy,
ratingCount: CopiableProp<Int> = .copy,
images: CopiableProp<[ProductImage]> = .copy,
addOns: CopiableProp<[ProductAddOn]> = .copy
addOns: CopiableProp<[ProductAddOn]> = .copy,
variations: CopiableProp<[Int64]> = .copy,
bundleStockStatus: NullableCopiableProp<ProductStockStatus> = .copy,
bundleStockQuantity: NullableCopiableProp<Int64> = .copy
) -> Networking.ProductListItem {
let siteID = siteID ?? self.siteID
let productID = productID ?? self.productID
Expand All @@ -1998,13 +2002,17 @@ extension Networking.ProductListItem {
let sku = sku ?? self.sku
let price = price ?? self.price
let virtual = virtual ?? self.virtual
let manageStock = manageStock ?? self.manageStock
let stockQuantity = stockQuantity ?? self.stockQuantity
let stockStatusKey = stockStatusKey ?? self.stockStatusKey
let reviewsAllowed = reviewsAllowed ?? self.reviewsAllowed
let averageRating = averageRating ?? self.averageRating
let ratingCount = ratingCount ?? self.ratingCount
let images = images ?? self.images
let addOns = addOns ?? self.addOns
let variations = variations ?? self.variations
let bundleStockStatus = bundleStockStatus ?? self.bundleStockStatus
let bundleStockQuantity = bundleStockQuantity ?? self.bundleStockQuantity

return Networking.ProductListItem(
siteID: siteID,
Expand All @@ -2015,13 +2023,17 @@ extension Networking.ProductListItem {
sku: sku,
price: price,
virtual: virtual,
manageStock: manageStock,
stockQuantity: stockQuantity,
stockStatusKey: stockStatusKey,
reviewsAllowed: reviewsAllowed,
averageRating: averageRating,
ratingCount: ratingCount,
images: images,
addOns: addOns
addOns: addOns,
variations: variations,
bundleStockStatus: bundleStockStatus,
bundleStockQuantity: bundleStockQuantity
)
}
}
Expand Down
21 changes: 20 additions & 1 deletion Modules/Sources/Networking/Model/Product/ProductListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public struct ProductListItem: GeneratedCopiable, Equatable, GeneratedFakeable {
public let price: String
public let virtual: Bool

public let manageStock: Bool
public let stockQuantity: Decimal? // Core API reports Int or null; some extensions allow decimal values as well
public let stockStatusKey: String // instock, outofstock, backorder

Expand All @@ -27,6 +28,16 @@ public struct ProductListItem: GeneratedCopiable, Equatable, GeneratedFakeable {

public let addOns: [ProductAddOn] //TODO: migrate AddOns to MetaData

public let variations: [Int64]

// MARK: Product Bundle properties

/// Stock status of this bundle, taking bundled product quantity requirements and limitations into account. Applicable for bundle-type products only.
public let bundleStockStatus: ProductStockStatus?

/// Quantity of bundles left in stock, taking bundled product quantity requirements into account. Applicable for bundle-type products only.
public let bundleStockQuantity: Int64?

/// Computed Properties
///
public var productStatus: ProductStatus {
Expand All @@ -51,13 +62,17 @@ public struct ProductListItem: GeneratedCopiable, Equatable, GeneratedFakeable {
sku: String?,
price: String,
virtual: Bool,
manageStock: Bool,
stockQuantity: Decimal?,
stockStatusKey: String,
reviewsAllowed: Bool,
averageRating: String,
ratingCount: Int,
images: [ProductImage],
addOns: [ProductAddOn]) {
addOns: [ProductAddOn],
variations: [Int64],
bundleStockStatus: ProductStockStatus?,
bundleStockQuantity: Int64?) {
self.siteID = siteID
self.productID = productID
self.name = name
Expand All @@ -66,13 +81,17 @@ public struct ProductListItem: GeneratedCopiable, Equatable, GeneratedFakeable {
self.sku = sku
self.price = price
self.virtual = virtual
self.manageStock = manageStock
self.stockQuantity = stockQuantity
self.stockStatusKey = stockStatusKey
self.reviewsAllowed = reviewsAllowed
self.averageRating = averageRating
self.ratingCount = ratingCount
self.images = images
self.addOns = addOns
self.variations = variations
self.bundleStockStatus = bundleStockStatus
self.bundleStockQuantity = bundleStockQuantity
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ extension Storage.Product: ListItemConvertible {
name = item.name
productTypeKey = item.productTypeKey
statusKey = item.statusKey
manageStock = item.manageStock
sku = item.sku
price = item.price
virtual = item.virtual
Expand All @@ -241,6 +242,9 @@ extension Storage.Product: ListItemConvertible {
reviewsAllowed = item.reviewsAllowed
averageRating = item.averageRating
ratingCount = Int64(item.ratingCount)
variations = item.variations
bundleStockQuantity = item.bundleStockQuantity as? NSNumber
bundleStockStatus = item.bundleStockStatus?.rawValue
}

public func toListItem() -> Yosemite.ProductListItem {
Expand All @@ -252,6 +256,11 @@ extension Storage.Product: ListItemConvertible {
quantity = Decimal(string: stockQuantity)
}

var productBundleStockStatus: ProductStockStatus?
if let bundleStockStatus {
productBundleStockStatus = ProductStockStatus(rawValue: bundleStockStatus)
}

return ProductListItem(siteID: siteID,
productID: productID,
name: name,
Expand All @@ -260,12 +269,16 @@ extension Storage.Product: ListItemConvertible {
sku: sku,
price: price,
virtual: virtual,
manageStock: manageStock,
stockQuantity: quantity,
stockStatusKey: stockStatusKey,
reviewsAllowed: reviewsAllowed,
averageRating: averageRating,
ratingCount: Int(ratingCount),
images: productImages,
addOns: addOnsArray.map { $0.toReadOnly() })
addOns: addOnsArray.map { $0.toReadOnly() },
variations: variations ?? [],
bundleStockStatus: productBundleStockStatus,
bundleStockQuantity: bundleStockQuantity as? Int64)
}
}
4 changes: 4 additions & 0 deletions Modules/Sources/Yosemite/Tools/ResultsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,8 @@ public extension ResultsController where T: ListItemConvertible {

return listItemObjects ?? []
}

func listItem(at indexPath: IndexPath) -> T.ListItemType {
return controller.object(at: indexPath).toListItem()
}
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

}
Loading