Skip to content

[Woo POS] Update conditions for showing POS entry point #12783

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 3 commits into from
May 21, 2024

Conversation

jaclync
Copy link
Contributor

@jaclync jaclync commented May 20, 2024

Part of: #12780

Why

As the conditions had been implemented in Android woocommerce/woocommerce-android#11513 and mentioned in the weekly update decisions section p91TBi-bfp-p2#decisions, I'm following the same checks in iOS:

  • tablet device
  • USD currency
  • US store location
  • Woo Payments plugin enabled and user setup complete
  • Feature Flag enabled

How

To consolidate the checks, POSEligibilityChecker was created to check if a store is eligible for POS

  • Tablet device: UIDevice.current.userInterfaceIdiom == .pad as in the beta feature switch
  • USD currency: from ServiceLocator.currencySettings currency settings singleton
  • US store location: from ServiceLocator.selectedSiteSettings.siteSettings site settings singleton
  • Woo Payments plugin enabled and user setup complete: from CardPresentPaymentsOnboardingUseCase.state
    • It just checks the current state without triggering a refresh
    • POS is only eligible if WCPay i the only/preferred plugin in the onboarding completed state
  • Feature Flag enabled: checks the POS entry point feature flag displayPointOfSaleToggle - we can consider renaming it after the decision of whether to keep the feature switch or red dot notification is made p91TBi-beb-p2#comment-12129

Then, POSEligibilityChecker().isEligible() is called when:

  • Determining whether the POS feature switch is available (as the red dot vs. feature switch decision is pending p91TBi-beb-p2#comment-12129)
  • Determining whether to show the POS entry point in HubMenuViewModel - the feature switch could have been enabled before this PR, and the eligibility check should be in place to prevent the entry point from being shown

In HubMenuViewModel, the POS entry point was also updated from a row in the General section to a new section without a title below the store switch to minimize the chance of merge conflicts with #12779.

Testing instructions

There are a few scenarios that @jaclync will test again after approval:

  • Tablet device
    • Go to the Menu tab on iPhone --> no POS row should be shown in the menu tab, and in Experimental Features the POS feature switch should not be shown
    • Go to the Menu tab on iPad --> in Experimental Features the POS feature switch should be shown, and when the switch is enabled, the POS row should be shown in the menu tab if the store is eligible for POS

Continue with an iPad with the POS feature switch enabled for the following cases:

  • USD currency (WC Settings > General)
    • Switch to a store with non-USD currency --> after revisiting the Menu tab, the POS row should not be shown
  • US store location (WC Settings > General)
    • Switch to a store not based in the US --> after revisiting the Menu tab, the POS row should not be shown
  • Woo Payments plugin enabled and user setup complete
    • Switch to a store based in the US and using USD, but the WCPay isn't active or its onboarding isn't complete --> after revisiting the Menu tab, the POS row should not be shown

Screenshots

Simulator.Screen.Recording.-.iPad.Air.5th.generation.-.2024-05-20.at.17.15.55.mp4

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@jaclync jaclync added status: feature-flagged Behind a feature flag. Milestone is not strongly held. feature: POS labels May 20, 2024
@jaclync jaclync added this to the 18.8 milestone May 20, 2024
@dangermattic
Copy link
Collaborator

1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 20, 2024

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

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr12783-47bc24a
Version18.7
Bundle IDcom.automattic.alpha.woocommerce
Commit47bc24a
App Center BuildWooCommerce - Prototype Builds #9143
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@jaclync jaclync marked this pull request as ready for review May 20, 2024 12:51
Copy link
Contributor

@bozidarsevo bozidarsevo left a comment

Choose a reason for hiding this comment

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

🚀

Comment on lines +3 to +6
import class WooFoundation.CurrencySettings
import enum WooFoundation.CountryCode
import protocol Experiments.FeatureFlagService
import struct Yosemite.SiteSetting
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know if there are any performance effects when importing specific structs, enums, classes?

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 don't think there's performance gain from this, but this makes it clear what the exact dependencies are if we ever want to move it to a framework.

@jaclync jaclync merged commit 865419e into trunk May 21, 2024
22 checks passed
@jaclync jaclync deleted the feat/12780-entry-point-conditions branch May 21, 2024 01:54
@iamgabrielma
Copy link
Contributor

Looks good! 💯

Just noting that I didn't see the POS row rendering the first time despite all conditions being true, then I navigated back and forth and rendered correctly. I think is just some different flavour from the existing issue with rows being rendered before the app state is fully sync.

For a different PR: I think we could start to add tests for the eligibility checker since is something that most likely won't change soon.

@jaclync
Copy link
Contributor Author

jaclync commented May 22, 2024

Thanks for reviewing & testing it as well @iamgabrielma!

Just noting that I didn't see the POS row rendering the first time despite all conditions being true, then I navigated back and forth and rendered correctly. I think is just some different flavour from the existing issue with rows being rendered before the app state is fully sync.

I noticed this too, and I'm looking into this today as a subtask of #12779. I think there are two different issues:

  • The same issue where toggling the POS feature switch doesn't show/hide the entry point in the menu, HubMenu onAppear isn't called to set up the menu items
  • The onboarding state isn't fully synced when landing on the Menu tab. I'm going to look into observing the state publishing instead of just getting the current state value

For a different PR: I think we could start to add tests for the eligibility checker since is something that most likely won't change soon.

Yup I agree! There were mentions about uncertainty of the eligibility checks earlier p1716196427643069/1716183208.646519-slack-C070SJRA8DP, so I added a separate subtask to #12780 to update the checks if needed with unit tests. But now from p91TBi-beb-p2#comment-12134 it seems like we're fine with the current checks, so I'll work on adding some tests for it today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: POS status: feature-flagged Behind a feature flag. Milestone is not strongly held.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants