Skip to content

Conversation

@iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Aug 25, 2025

Closes WOOMOB-1040

Description

This PR adds Store and POS receipt information to the Store section in POS Settings. UI is not handled yet, only fetching store and POS receipt details.

Testing information

  • On a store with Woo 10+ and some POS receipt settings setup, go to POS > ... > Settings. Observe these load upon tapping on the Store section:
Screen.Recording.2025-08-25.at.17.15.01.mov
  • Update PointOfSaleSettingsService.retrievePOSReceiptSettings WooCommerce version to an unsupported version, ie higher.
- shouldShowReceiptInformation = await isPluginSupported(.wooCommerce, minimumVersion: "10.0")
+ shouldShowReceiptInformation = await isPluginSupported(.wooCommerce, minimumVersion: "12.0")
  • Observe that only store details are loaded.
Simulator Screenshot - iPad mini (A17 Pro) - US store - 2025-08-25 at 17 18 44

Question/Feedback

I initially linked this service it to the aggregate model, following the same design as other services, but ultimately this felt a bit overkill at this point for the current state of settings we'll need (all of them in this PR, the rest of the project's i1 is navigation and details in the card reader service) so I went with the simplest way to initialize it within PointOfSaleSettingsView.

Would you suggest a different approach? Should we go through exposing the service through the aggregate model? Happy to handle either for this PR or a separate one.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 25, 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 Numberpr16034-cf78712
Version23.1
Bundle IDcom.automattic.alpha.woocommerce
Commitcf78712
Installation URL2p3aild8u6ffo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@iamgabrielma iamgabrielma added type: task An internally driven task. feature: POS labels Aug 25, 2025
@iamgabrielma iamgabrielma added this to the 23.2 milestone Aug 25, 2025
@iamgabrielma iamgabrielma marked this pull request as ready for review August 25, 2025 10:27
@iamgabrielma iamgabrielma requested a review from jaclync August 25, 2025 10:46
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.

Shared some initial comments, let me know what you think! Also, would be nice having unit tests.

@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.

Generated by 🚫 Danger

@iamgabrielma iamgabrielma requested a review from jaclync August 26, 2025 11:09
@iamgabrielma
Copy link
Contributor Author

iamgabrielma commented Aug 26, 2025

Thanks for the review @jaclync , this is ready for another look. I split the initial service into PointOfSaleSettingsController and PointOfSaleSettingsService, with their respective protocols, previews, and tests. There's some improvements to be made, I left some comments, but is getting a bit bigger so I'll handle those separately.

Base automatically changed from task/WOOMOB-1025-two-panel-settings-view to trunk August 27, 2025 00:38
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.

Thanks for the updates, works as expected :shipit: some unblocking comments just for your consideration.

Just a UX note that the receipt fields shift left after the loading state, as in your screencast in the PR description.

}

public final class PointOfSaleSettingsService: PointOfSaleSettingsServiceProtocol {
public private(set) var siteID: Int64
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this could be let?

Suggested change
public private(set) var siteID: Int64
public let siteID: Int64

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adjusted 61728b2

Comment on lines 81 to 94
@Test func retrievePointOfSaleSettings_passes_correct_siteID_to_settingStoreMethods() async throws {
// Given
let differentSiteID: Int64 = 456
let customSUT = PointOfSaleSettingsService(siteID: differentSiteID,
settingStoreMethods: settingStoreMethods)
settingStoreMethods.retrievePointOfSaleSettingsResult = .success([])

// When
_ = try await customSUT.retrievePointOfSaleSettings()

// Then
#expect(settingStoreMethods.retrievePointOfSaleSettingsCalled)
#expect(settingStoreMethods.retrievePointOfSaleSettingsSiteID == differentSiteID)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this test case felt a bit duplicative, since the settings methods isn't initialized with a site ID and previous cases have tested on the site ID.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True, don't think is needed to check for siteID differences. Updated: 3b82a84

#expect(settingStoreMethods.retrievePointOfSaleSettingsSiteID == differentSiteID)
}

@Test func retrievePointOfSaleSettings_with_complete_pos_settings_then_returns_all_settings() async throws {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could this be merged with retrievePointOfSaleSettings_when_successful_then_returns_expected_settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! 2e5c028

if let defaultSiteName {
return defaultSiteName
} else {
return Localization.storeNotSet
Copy link
Contributor

Choose a reason for hiding this comment

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

super nit:

Suggested change
return Localization.storeNotSet
return Localization.storeNameNotSet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

private let settingsService: PointOfSaleSettingsServiceProtocol
private let siteSettings: [SiteSetting]

init(settingsService: PointOfSaleSettingsServiceProtocol,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe the site ID can be DI'ed to the controller as well? then siteID isn't needed in PointOfSaleSettingsServiceProtocol.

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 think so 🤔 I've logged this one separately for now: WOOMOB-1188

Comment on lines 127 to 129
//#Preview {
// PointOfSaleSettingsStoreDetailView(posSettingsService: PointOfSaleSettingsController())
//}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: let's remove commented out code

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 forgot this one 🤦 . fixed: b7b3bee

import protocol Yosemite.PointOfSaleBarcodeScanServiceProtocol
import enum Yosemite.PointOfSaleBarcodeScanError

import class Yosemite.PointOfSaleSettingsService
Copy link
Contributor

Choose a reason for hiding this comment

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

super nit: is this import still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed! cf78712

import class Yosemite.PointOfSaleSettingsService
import Storage

protocol PointOfSaleSettingsControllerProtocol {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: all the content of the protocol feels like specific to the store settings section PointOfSaleSettingsStoreDetailView, instead of the whole settings. For example, isLoading is just for the store section, but being in the settings controller makes it like it's the loading state for some global state in the settings.

Maybe we can keep the POS settings controller, as there could be other global states in the settings later, and a separate @Observable view model like class to provide the following interface for PointOfSaleSettingsStoreDetailView?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I've added a note on WOOMOB-1188 so signature and dependencies can be adjusted in one go 👍

couponsSearchController: PointOfSaleSearchingItemsControllerProtocol = MockPointOfSaleCouponsController(),
cardPresentPaymentService: CardPresentPaymentFacade = MockCardPresentPaymentService(),
orderController: PointOfSaleOrderControllerProtocol = MockPointOfSaleOrderController(),
settingsController: PointOfSaleSettingsControllerProtocol = PointOfSaleSettingsPreviewController(),
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: we may want a mock version in unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed here d036798

@@ -1,4 +1,5 @@
import SwiftUI
import class Yosemite.PointOfSaleSettingsService
Copy link
Contributor

Choose a reason for hiding this comment

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

super nit: is this import still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not needed! cf78712

@iamgabrielma iamgabrielma enabled auto-merge August 27, 2025 03:49
@iamgabrielma iamgabrielma merged commit 722d258 into trunk Aug 27, 2025
14 checks passed
@iamgabrielma iamgabrielma deleted the task/WOOMOB-1040-POSSettings-store-section branch August 27, 2025 03:58
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.

5 participants