Skip to content

Commit 3993404

Browse files
committed
Remove locale based country and currency code site settings because they break IPP screenshot for ineligible countries. Enable POS tab by overriding FeatureFlagAction.isRemoteFeatureFlagEnabled based on locale region instead.
1 parent 58acf98 commit 3993404

File tree

2 files changed

+8
-56
lines changed

2 files changed

+8
-56
lines changed

Modules/Sources/Yosemite/Model/Mocks/Graphs/ScreenshotsObjectGraph.swift

Lines changed: 2 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ struct ScreenshotObjectGraph: MockObjectGraph {
7272
createSiteSetting(settingID: "woocommerce_default_country",
7373
label: "Country and State",
7474
settingDescription: "The country and state or province, if any, in which your business is located.",
75-
value: Self.countryValue(for: Locale.current.identifier),
75+
value: "US:CA",
7676
settingGroupKey: "general"),
7777
createSiteSetting(settingID: "woocommerce_currency",
7878
label: "Currency",
7979
settingDescription: "This controls what currency prices are listed at in the catalog and which currency gateways will take payments in.",
80-
value: Self.currencyCode(for: Locale.current.identifier),
80+
value: CurrencyCode.USD.rawValue,
8181
settingGroupKey: "general")
8282
]
8383

@@ -332,58 +332,6 @@ struct ScreenshotObjectGraph: MockObjectGraph {
332332
init(date: Date = .init()) {
333333
self.date = date
334334
}
335-
336-
/// Maps the given locale to an appropriate country value for the site setting for all locales in Fastfile IOS_LOCALES.
337-
/// Uses the same format as WooCommerce's default country setting: "COUNTRY:STATE".
338-
private static func countryValue(for locale: String) -> String {
339-
// Map locales to country values based on IOS_LOCALES from Fastfile
340-
let localeToCountryMap: [String: String] = [
341-
"ar-SA": "SA", // Saudi Arabia
342-
"de-DE": "DE", // Germany
343-
"en-US": "US:CA", // United States, California
344-
"es-ES": "ES", // Spain
345-
"fr-FR": "FR", // France
346-
"he": "IL", // Israel (Hebrew)
347-
"id": "ID", // Indonesia
348-
"it": "IT", // Italy
349-
"ja": "JP", // Japan
350-
"ko": "KR", // South Korea
351-
"nl-NL": "NL", // Netherlands
352-
"pt-BR": "BR", // Brazil
353-
"ru": "RU", // Russia
354-
"sv": "SE", // Sweden
355-
"tr": "TR", // Turkey
356-
"zh-Hans": "CN", // China (Simplified Chinese)
357-
"zh-Hant": "TW" // Taiwan (Traditional Chinese)
358-
]
359-
return localeToCountryMap[locale] ?? "US:CA" // Default to US:CA.
360-
}
361-
362-
/// Maps the given locale to an appropriate currency code for the site setting for all locales in Fastfile IOS_LOCALES.
363-
/// Uses the CurrencyCode enum rawValues.
364-
private static func currencyCode(for locale: String) -> String {
365-
// Map locales to currency codes based on IOS_LOCALES from Fastfile
366-
let localeToCurrencyMap: [String: CurrencyCode] = [
367-
"ar-SA": .SAR, // Saudi Riyal
368-
"de-DE": .EUR, // Euro
369-
"en-US": .USD, // US Dollar
370-
"es-ES": .EUR, // Euro
371-
"fr-FR": .EUR, // Euro
372-
"he": .ILS, // Israeli Shekel
373-
"id": .IDR, // Indonesian Rupiah
374-
"it": .EUR, // Euro
375-
"ja": .JPY, // Japanese Yen
376-
"ko": .KRW, // South Korean Won
377-
"nl-NL": .EUR, // Euro
378-
"pt-BR": .BRL, // Brazilian Real
379-
"ru": .RUB, // Russian Ruble
380-
"sv": .SEK, // Swedish Krona
381-
"tr": .TRY, // Turkish Lira
382-
"zh-Hans": .CNY, // Chinese Yuan
383-
"zh-Hant": .TWD // Taiwan Dollar
384-
]
385-
return localeToCurrencyMap[locale]?.rawValue ?? CurrencyCode.USD.rawValue // Default to USD.
386-
}
387335
}
388336

389337
extension ScreenshotObjectGraph {

Modules/Sources/Yosemite/Model/Mocks/MockStoresManager.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Combine
2+
import Foundation
23
import Storage
34

45
public class MockStoresManager: StoresManager {
@@ -165,8 +166,11 @@ public class MockStoresManager: StoresManager {
165166
case let action as FeatureFlagAction:
166167
switch action {
167168
case let .isRemoteFeatureFlagEnabled(_, _, completion):
168-
// One of the requirements for the POS tab to show up.
169-
completion(true)
169+
// Only enables POS feature for eligible countries from locale.
170+
let locale = Locale.current
171+
let countryCode = locale.region?.identifier ?? ""
172+
let isEligibleCountry = countryCode == "US" || countryCode == "GB"
173+
completion(isEligibleCountry)
170174
}
171175
default:
172176
fatalError("Unable to handle action: \(action.identifier) \(String(describing: action))")

0 commit comments

Comments
 (0)