🔗 Composables
Interfaces
CountryDetectionParams
Properties
Property | Type | Description |
---|---|---|
fallbackShopId? | number | The shop ID to use if there are no shops that match the detected region. When the detected region does not match any available shop, the shop with the fallbackShopId will be suggested instead. This ensures that a valid shop is always suggested, even when no match for the region is found. |
getDetectedCountryCode? | () => ... | ... | ... | An optional function to get the detected country code. |
shouldPromptUser? | (detectedRegion : string , currentRegion : string ) => ... | ... | ... | An optional function to determine whether the user should be prompted to switch shops. |
ModuleOptions
Properties
Property | Type |
---|---|
autoImports? | boolean |
UseCountryDetectionReturn
Properties
Property | Type | Description |
---|---|---|
detectedRegion | Readonly <Ref <... | ...>> | The detected region code (based on the user's location, e.g "US") |
hasPromptedUser | ComputedRef <boolean > | A computed reference indicating whether the user has already been prompted to switch shops (persisted in session storage). |
hasSwitchedShops | ComputedRef <boolean > | A computed reference indicating whether the user has already manually switched shops (persisted in session storage). |
markShopAsSwitched | () => void | A function to mark that the user has manually switched shops. Marking the shop as changed will prevent the user from being prompted to switch shops again. |
markUserAsPrompted | () => void | A function to mark that the user has been prompted to switch shops. |
suggestedShops | ComputedRef <PublicShopConfig []> | An array of shops matching the detected region or the fallback shop. |
suggestionActive | Readonly <Ref <boolean >> | A boolean indicating whether a suggestion for switching shops should be active. |
Variables
module
Functions
useCountryDetection()
A composable that provides logic for detecting the user's country and suggesting shops matching the detected country.
Parameters
Parameter | Type | Description |
---|---|---|
params | CountryDetectionParams | An object containing the parameters for the composable. |
Returns
An object containing reactive data, computed properties and functions for managing country detection: