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

[Woo POS][Products Search] Add POSProduct in Networking #15441

Merged
merged 6 commits into from
Mar 28, 2025

Conversation

joshheald
Copy link
Contributor

@joshheald joshheald commented Mar 27, 2025

Closes: #15439

Description

Adds a POSProduct model and updates the ProductsRemote.loadProductsForPointOfSale function to use it.
Adds a generic ListMapper which can be used for mapping any standard list from the REST API – however it's only used for POSProduct at this point.

We decided to make a new copy of Product for Point of Sale to support the future persistence of the product catalogue: pdfdoF-6Ha-p2#comment-7880, pdfdoF-6Pb-p2. This version of the Product will only contain what we need for Point of Sale.

Steps to reproduce

  1. Launch the app on an iPad
  2. Open Point of Sale
  3. Observe that the Products load
  4. Add products to the cart, including a variation
  5. Observe that you can checkout as expected.

Testing information

I've tested with both site credentials and Jetpack – the mapping behaviour is slightly different between the two as only the Jetpack-tunnelled version of the API response is wrapped in a data envelope.

I checked that we could load multiple pages, reload, create orders, edit orders, and use variable products the same as previously.

I've also checked that the existing Orders and Products features work correctly.

I've tested on an iPad Air running iPadOS 17.7.3, and a simulator running iPadOS 18.2.

Screenshots

POSProduct.in.use.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.

@joshheald joshheald added type: task An internally driven task. feature: POS labels Mar 27, 2025
@joshheald joshheald added this to the 22.1 milestone Mar 27, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Mar 27, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Number29028
VersionPR #15441
Bundle IDcom.automattic.alpha.woocommerce
Commit839b4be
Installation URL0mlb8msaambvg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@joshheald joshheald requested a review from jaclync March 27, 2025 15:51
@joshheald joshheald marked this pull request as ready for review March 27, 2025 15:51
Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

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

LGTM :shipit: Tested both WPCOM login and application password login, products were loaded as before including variable products!

Comment on lines +3 to +5
/// ListMapper: Maps generic WooCommerce REST API Lists
///
struct ListMapper<Output: Decodable>: Mapper {
Copy link
Contributor

Choose a reason for hiding this comment

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

👏 no more copying mapper for new use case! We can create an issue to replace existing mappers and let the mobile team know.

@@ -102,7 +102,7 @@ public final class PointOfSaleItemService: PointOfSaleItemServiceProtocol {
// Maps result to POSItem, and populate the output with:
// - Formatted price based on store's currency settings.
// - Product thumbnail, if any.
private func mapProductsToPOSItems(products: [Product]) -> [POSItem] {
private func mapProductsToPOSItems(products: [POSProduct]) -> [POSItem] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice that this is the only change in POS 👍

@@ -202,11 +202,11 @@ public final class ProductsRemote: Remote, ProductsRemoteProtocol {
/// - Parameters:
/// - siteID: Site for which we'll fetch remote products.
/// - productTypes: A list of product types to be included in the results.
/// - pageNumber: Number of page that should be retrieved.
/// - pageNumber: Number of pages that should be retrieved.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think this parameter is the page index (starting with 1), not the number of pages (total page count)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, you're absolutely right! I was obviously not thinking straight, I'll fix it.

@joshheald joshheald enabled auto-merge March 28, 2025 07:03
@joshheald joshheald merged commit 2198e61 into trunk Mar 28, 2025
13 checks passed
@joshheald joshheald deleted the issue/15439-POSProduct-in-networking branch March 28, 2025 07:24
@joshheald joshheald mentioned this pull request Mar 28, 2025
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: POS type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Woo POS][Products Search] Add POSProduct to Networking
3 participants