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"]
});
ParameterTypeRequiredDescription
appIdStringYesApp to switch to. This is the value that switches the app.
primaryAppIdStringNoSent with the switch when it is a non-empty string. A missing or blank value is omitted.
domainStringYesShopify domain, such as your-store.myshopify.com.
storeIdStringYesStore id sent with the switch. A payload that is only { storeId } is rejected.
marketIdStringYesMarket id.
marketsStringYesMarket code, such as AT.
locationStringYesLocation name.
locationIdStringYesLocation id.
currencyStringYesCurrency code, such as EUR.
currencySymbolStringNoSymbol such as €. A missing or blank value is omitted.
languageString[]YesNon-empty array of non-empty language codes, such as ["en"].

Structure of Response

StatusResponse
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 failedThe 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

  1. Use openStore when the block already knows the target store. Use openStoreSwitcher when the shopper should pick.
  2. After a switch, re-read Superfans.variables.store instead of keeping the previous store.
  3. Send the full store context. appId is what switches the app. The other fields travel with that switch.

Caveats

  1. Every required string must be non-empty. language must be a non-empty array of non-empty strings.
  2. primaryAppId and currencySymbol are optional. A missing or blank value is left off the payload, and the switch still runs.
  3. status: "unchanged" means that appId is already current, so native does not reload.
  4. A failed switch rejects and leaves the previous app in place.

Did this page help you?