Open Store
Switches the app to a store by app id.
Description
The openStore action switches the native app to the store identified by appId. The block chooses the store and sends the store context with the call.
This is separate from openStoreSwitcher, which only opens the picker and does not switch the store.
Function Signature
await Superfans.actions.openStore({
appId: "app_0n8htm4dw2y58",
primaryAppId: "app_9k2hq1m4n0p11",
domain: "your-store.myshopify.com",
storeId: "27784740935",
marketId: "61434364228",
markets: "AT",
location: "Ostrava",
locationId: "36240392263",
currency: "EUR",
currencySymbol: "€",
language: ["en"]
});| Parameter | Type | Required | Description |
|---|---|---|---|
appId | String | Yes | App to switch to. This is the value that switches the app. |
primaryAppId | String | No | Sent with the switch when it is a non-empty string. A missing or blank value is omitted. |
domain | String | Yes | Shopify domain, such as your-store.myshopify.com. |
storeId | String | Yes | Store id sent with the switch. A payload that is only { storeId } is rejected. |
marketId | String | Yes | Market id. |
markets | String | Yes | Market code, such as AT. |
location | String | Yes | Location name. |
locationId | String | Yes | Location id. |
currency | String | Yes | Currency code, such as EUR. |
currencySymbol | String | No | Symbol such as €. A missing or blank value is omitted. |
language | String[] | Yes | Non-empty array of non-empty language codes, such as ["en"]. |
Structure of Response
| Status | Response |
|---|---|
| Opened | { "status": "opened" } when native switches to a new appId. |
| Already current | { "status": "unchanged" } when that appId is already current and native does not reload. |
| Invalid params | { "errorCode": 400, "errorType": "ERROR_INVALID_INPUT", "errorMessage": "..." } |
| Switch failed | The native error. The previous app stays current. |
Example Usage
try {
const result = await Superfans.actions.openStore({
appId: "app_0n8htm4dw2y58",
domain: "your-store.myshopify.com",
storeId: "27784740935",
marketId: "61434364228",
markets: "AT",
location: "Ostrava",
locationId: "36240392263",
currency: "EUR",
language: ["en"]
});
if (result.status === "opened") {
const store = Superfans.variables.store;
}
} catch (error) {
await Superfans.actions.showToast({
title: "Something went wrong",
message: "Please try again."
});
}Best Practices
- Use
openStorewhen the block already knows the target store. UseopenStoreSwitcherwhen the shopper should pick. - After a switch, re-read
Superfans.variables.storeinstead of keeping the previous store. - Send the full store context.
appIdis what switches the app. The other fields travel with that switch.
Caveats
- Every required string must be non-empty.
languagemust be a non-empty array of non-empty strings. primaryAppIdandcurrencySymbolare optional. A missing or blank value is left off the payload, and the switch still runs.status: "unchanged"means thatappIdis already current, so native does not reload.- A failed switch rejects and leaves the previous app in place.
Updated about 2 hours ago
Did this page help you?