Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Jul 4, 2025

Closes WOOMOB-704

Description

This PR adds an eligibility checker that will handle if we should show the POS badge in order list and order details summary. The only requirement is that the minimum WooCommerce version is 9.9.0, as it's where created_via was introduced.

Initially this check was set directly in the cells for simplicity, as we only checked for feature flag, however as soon we introduced checking the WooCommerce version as well, this would trigger an unnecessary trip to disk for each cell render, so I moved the check up to the view models/datasource.

Testing information

  • On a site with WooCommerce 9.9.0+, process a POS order.
  • Navigate to orders
  • You should see the badge both in order list and order details (this takes a bit to load due other async tasks in the task group)
Screen.Recording.2025-07-07.at.12.01.02.mov
  • Turning off pointOfSaleOrdersi1 should hide the POS labels:

Simulator Screenshot - iPad mini (A17 Pro) - US store - 2025-07-07 at 12 14 45

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jul 4, 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 Numberpr15868-43f17d9
Version22.7
Bundle IDcom.automattic.alpha.woocommerce
Commit43f17d9
Installation URL7ld25vd9dvav8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

# Conflicts:
#	WooCommerce/Classes/ViewRelated/Orders/Order Details/Order Summary Section/SummaryTableViewCell.swift

private extension OrderSalesChannelEligibilityChecker {
enum Constants {
static let pluginName = "WooCommerce"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can wait until PluginsService refactoring is done to update this, as won't work as soon as requires the string is the plugin path, rather than the plugin name 👍

@iamgabrielma iamgabrielma added type: task An internally driven task. feature: order details Related to order details. feature: order list Related to the order list. feature: POS labels Jul 7, 2025
@iamgabrielma iamgabrielma added this to the 22.8 milestone Jul 7, 2025
@iamgabrielma iamgabrielma marked this pull request as ready for review July 7, 2025 05:25
@iamgabrielma iamgabrielma requested review from jaclync and staskus July 7, 2025 05:35
@iamgabrielma
Copy link
Contributor Author

@staskus I just realized Jaclyn is AFK, adding you as well as reviewer 🙇

Copy link
Contributor

@staskus staskus left a comment

Choose a reason for hiding this comment

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

Thanks!

I think the solution could be improved, especially given that the labels don't appear by themselves the first time orders view is loading.

I would seriously consider keeping a previous conclusion and relying on the existence of the created_via field to determine whether to show or not to show POS. It would simplify the implementation and make the user experience faster.

subtitleLabel.text = viewModel.subtitle
salesChannelLabel.text = viewModel.salesChannel
salesChannelLabel.isHidden = (salesChannelLabel.text == nil)
if viewModel.isEligibleForDisplayingSalesChannelPOSBadge {
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with this comment https://linear.app/a8c/issue/WOOMOB-704/woo-mobilepos-orders-wc-99-version-check#comment-c873cc1e

It seems simpler just to check the existence of salesChannel label, and no need for additional WooCommerce version checks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems simpler just to check the existence of salesChannel label, and no need for additional WooCommerce version checks?

That's a good point, and I'm definitely leaning back into it.

The intention of adding the eligibility checker now was to remove the badge from the UI in the edge case that they the merchants happen to revert to a non-supported WC version after already having used POS, however, it is true that if they do so the order model in the DB doesn't change, and the order would still have this property (just not for new orders) so there is really no reason to hide pre-existing badges.

This would simplify the design since there is no need for version check in i1, we just check if the property exists in the order and render the badge in consequence 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll discuss with Sam before updating or closing this issue 👍

query: Self.createQuery(siteID: siteID,
filters: filters))
Task {
let checker = OrderSalesChannelEligibilityChecker(featureFlagService: featureFlagService, storageManager: storageManager)
Copy link
Contributor

Choose a reason for hiding this comment

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

It could be good to inject it into OrderListViewModel to have a mocked version within OrderListViewModelTests. I remember encountering a couple of examples where using real implementations slowed down or broke existing tests.

}

return OrderListCellViewModel(order: order, currencySettings: ServiceLocator.currencySettings)
return OrderListCellViewModel(order: order,
Copy link
Contributor

Choose a reason for hiding this comment

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

....(this takes a bit to load due other async tasks in the task group)

It takes time to load, but also the rows are not updated after loading is done. Since we're in the UIKit world, we need to manually reload the data once the performEligibilityCheck finishes loading.

ScreenRecording_07-08-2025.17-33-26_1.MP4

@iamgabrielma
Copy link
Contributor Author

Thanks for the review and suggestions @staskus , we've decided at p1752034631867549-slack-C070SJRA8DP that indeed having a WC version check here isn't necessary, and keeping the previous implementation is fine. I'll close this one 🙇

@staskus
Copy link
Contributor

staskus commented Jul 9, 2025

@iamgabrielma nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: order details Related to order details. feature: order list Related to the order list. feature: POS type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants