thegeneralyst/AnopaDocs
Market

Market Selector

Renders a market/region selector dropdown that syncs with Shopify markets and updates prices across the site.

What it does

Market Selector renders a market/region selector that lets shoppers choose their preferred market or region. It automatically fetches all active markets from Shopify via the Storefront API and displays them in a dropdown. When a market is selected, it writes the selected market (handle, currency, country code) into a shared active market store.

All market-aware pricing components (such as APVariantPrice, APCartSubtotal, and AP_CartItemsDisplay) listen to this shared store. When the active market changes, these components automatically re-fetch and re-render prices in the correct currency and format.

Canvas shows dummy market options so designers can work without a live Shopify connection.

How to set it up

  1. Add AP_MarketSelector to your global layout, typically in the site navigation or footer.
  2. No product ID or manual configuration of markets is required; the component fetches available markets from Shopify on mount.
  3. Use the exposed font, color, border, and background controls to style the dropdown so it matches your theme.
  4. The component persists the last selected market to localStorage, so the shopper’s choice is remembered across page navigations and reloads.

Key behaviours

  • Fetches all active Shopify markets on mount via the Storefront API.
  • Displays the markets in a dropdown, optionally showing a country flag emoji next to each market name.
  • Writes the selected market (handle, currency, country code) to a shared active market store.
  • All market-aware price components react automatically to store updates and refresh their data.
  • Canvas uses dummy market options for design-time previews.
  • Persists the last selected market to localStorage so the selection survives navigation and refresh.

Property Controls

ControlTypeDefaultDescription
LabelStringShip to:Prefix text displayed before the selected market name in the selector.
Show FlagBooleantrueToggle to show or hide the country flag emoji next to the market name.
FontFont14pxTypography settings for the selector text (size, weight, family).
Text ColorColor#111111Text color used for the label and selected market name.
BackgroundColor#ffffffBackground color of the dropdown selector.
BorderBordernoneBorder style applied around the selector (width, style, color).
Border RadiusBorderRadius0pxCorner rounding applied to the selector dropdown.