Skip to content

Commit 023d0d1

Browse files
committed
check for woo version when rendering store receipts
1 parent 8fd076b commit 023d0d1

File tree

1 file changed

+81
-17
lines changed

1 file changed

+81
-17
lines changed

WooCommerce/Classes/POS/Presentation/Settings/PointOfSaleSettingsStoreDetailView.swift

Lines changed: 81 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import Yosemite
12
import SwiftUI
23

34
struct PointOfSaleSettingsStoreDetailView: View {
45
@Environment(\.dismiss) private var dismiss
6+
@State private var shouldShowReceiptInformation = false
57

68
var storeName: String {
79
guard let site = ServiceLocator.stores.sessionManager.defaultSite else {
@@ -21,23 +23,57 @@ struct PointOfSaleSettingsStoreDetailView: View {
2123
var body: some View {
2224
NavigationStack {
2325
VStack(alignment: .leading) {
24-
Text("Store Information")
25-
.font(.title2)
26-
27-
Text("Store name")
28-
Text(storeName)
29-
.font(.caption)
30-
.foregroundStyle(.secondary)
31-
32-
Text("Address")
33-
Text(storeAddress)
34-
.font(.caption)
35-
.foregroundStyle(.secondary)
36-
37-
Text("Email")
38-
Text(storeEmail)
39-
.font(.caption)
40-
.foregroundStyle(.secondary)
26+
Group {
27+
Text("Store Information")
28+
.font(.title2)
29+
30+
Text("Store name")
31+
Text(storeName)
32+
.font(.caption)
33+
.foregroundStyle(.secondary)
34+
35+
Text("Address")
36+
Text(storeAddress)
37+
.font(.caption)
38+
.foregroundStyle(.secondary)
39+
40+
Text("Email")
41+
Text(storeEmail)
42+
.font(.caption)
43+
.foregroundStyle(.secondary)
44+
}
45+
46+
Group {
47+
Spacer()
48+
Text("Receipt Information")
49+
.font(.title2)
50+
Text("Store name")
51+
Text("WIP")
52+
.font(.caption)
53+
.foregroundStyle(.secondary)
54+
55+
Text("Physical address")
56+
Text("WIP")
57+
.font(.caption)
58+
.foregroundStyle(.secondary)
59+
60+
Text("Phone number")
61+
Text("WIP")
62+
.font(.caption)
63+
.foregroundStyle(.secondary)
64+
65+
Text("Email")
66+
Text("WIP")
67+
.font(.caption)
68+
.foregroundStyle(.secondary)
69+
70+
Text("Refund & Returns Policy")
71+
Text("WIP")
72+
.font(.caption)
73+
.foregroundStyle(.secondary)
74+
75+
}
76+
.renderedIf(shouldShowReceiptInformation)
4177
}
4278
.padding()
4379
.toolbar {
@@ -46,6 +82,34 @@ struct PointOfSaleSettingsStoreDetailView: View {
4682
}
4783
}
4884
}
85+
.task {
86+
shouldShowReceiptInformation = await isPluginSupported(.wooCommerce, minimumVersion: "10.0")
87+
/**
88+
TODO - WOOMOB-1160: retrieval for woocommerce_pos_ settings
89+
woocommerce_pos_store_name
90+
woocommerce_pos_store_address
91+
woocommerce_pos_store_phone
92+
woocommerce_pos_store_email
93+
woocommerce_pos_refund_returns_policy
94+
*/
95+
}
96+
}
97+
}
98+
99+
private extension PointOfSaleSettingsStoreDetailView {
100+
@MainActor
101+
func isPluginSupported(_ plugin: Plugin, minimumVersion: String) async -> Bool {
102+
let siteID = ServiceLocator.stores.sessionManager.defaultSite?.siteID ?? 0
103+
let storageManager = ServiceLocator.storageManager
104+
let pluginsService = PluginsService(storageManager: storageManager)
105+
guard let systemPlugin = pluginsService.loadPluginInStorage(siteID: siteID, plugin: plugin, isActive: true),
106+
systemPlugin.active else {
107+
return false
108+
}
109+
110+
let isSupported = VersionHelpers.isVersionSupported(version: systemPlugin.version,
111+
minimumRequired: minimumVersion)
112+
return isSupported
49113
}
50114
}
51115

0 commit comments

Comments
 (0)