docs

runtime/composables

Interfaces

CountryDetectionParams

Properties

PropertyTypeDescription
fallbackShopId?numberThe 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.

UseCountryDetectionReturn

Properties

PropertyTypeDescription
detectedRegionReadonly<Ref<... | ..., ... | ...>>The detected region code (based on the user's location, e.g "US")
hasPromptedUserComputedRef<boolean>A computed reference indicating whether the user has already been prompted to switch shops (persisted in session storage).
hasSwitchedShopsComputedRef<boolean>A computed reference indicating whether the user has already manually switched shops (persisted in session storage).
markUserAsPrompted() => voidA function to mark that the user has been prompted to switch shops.
suggestedShopsComputedRef<PublicShopConfig>An array of shops matching the detected region or the fallback shop.
suggestionActiveReadonly<Ref<boolean, boolean>>A boolean indicating whether a suggestion for switching shops should be active.

Functions

useCountryDetection()

function useCountryDetection(params): UseCountryDetectionReturn

A composable that provides logic for detecting the user's country and suggesting shops matching the detected country.

Parameters

ParameterTypeDescription
paramsCountryDetectionParamsAn object containing the parameters for the composable.

Returns

UseCountryDetectionReturn

An object containing reactive data, computed properties and functions for managing country detection: