Show local prices and languages with @inContext
Get prices in the buyer’s currency and content in their language from the Storefront API by adding @inContext(country, language) to the query.
- API
- Storefront API
- Operations
- @inContext directive, product, localization
- Access scope
- unauthenticated_read_product_listings
- API version
- 2026-10
- Last checked
In short
To show local prices in a headless storefront, add the @inContext directive to the query with the buyer’s country (and language), for example @inContext(country: CH, language: DE). Prices then come back in that market’s currency, and products not published in that market are left out. Without the directive, you get the primary market’s products and prices in the store currency.
How to use it
- Detect the buyer’s country (from the URL, a selector or geolocation) and the language.
- Pass them as variables to LocalProductPrices; the directive sits on the operation, after the variable list.
- Read localization.country.currency to format prices and build the country selector.
- Use the same country as buyerIdentity.countryCode on the cart so cart prices match.
Code
product-prices-in-context.graphqlquery LocalProductPrices($handle: String!, $country: CountryCode!, $language: LanguageCode!)
@inContext(country: $country, language: $language) {
localization {
country {
isoCode
currency {
isoCode
symbol
}
}
language {
isoCode
}
}
product(handle: $handle) {
title
priceRange {
minVariantPrice {
amount
currencyCode
}
}
variants(first: 10) {
nodes {
id
title
price {
amount
currencyCode
}
compareAtPrice {
amount
currencyCode
}
}
}
}
}
product-prices-in-context.variables.json{
"handle": "linen-shirt",
"country": "CH",
"language": "DE"
}
product-prices-in-context.response.json{
"data": {
"localization": {
"country": {
"isoCode": "CH",
"currency": {
"isoCode": "CHF",
"symbol": "CHF"
}
},
"language": {
"isoCode": "DE"
}
},
"product": {
"title": "Leinenhemd",
"priceRange": {
"minVariantPrice": {
"amount": "49.0",
"currencyCode": "CHF"
}
},
"variants": {
"nodes": [
{
"id": "gid://shopify/ProductVariant/1111111111",
"title": "S",
"price": {"amount": "49.0", "currencyCode": "CHF"},
"compareAtPrice": null
}
]
}
}
}
}
Written by Lintel. MIT license: free to use in your own store and in client work.
Limits and edge cases
- The country’s currency must be enabled in the store’s payment settings, and the country must belong to an active market.
- Queries use @inContext; carts store the context in buyerIdentity instead.
- Orders keep the currency they were placed in, whatever context you query them in.
- In Hydrogen, storefront.query fills $country and $language from the i18n settings; you still write the @inContext directive in the query.
Questions
- How do I get prices in another currency with the Storefront API?
- Add @inContext(country: XX) to the query. Prices come back in the currency of the market that country belongs to.
- Why does @inContext still return the store currency?
- The country probably isn’t in an active market with its own currency, or that currency isn’t enabled in the store’s payment settings.
- Does @inContext also translate content?
- Yes, with the language argument. Product titles and descriptions come back in that language where translations exist.
Shopify documentation
- Validated against the Admin or Storefront API schema for version 2026-10 on the date shown. Check the version in your request URL.
- IDs and store addresses in the examples are placeholders. Replace them with your own.
- Admin API calls need an access token from your app. Never put an Admin API token in a storefront or theme.
- MIT license. Use the code in your own store or in client work.
Need this built, tested and maintained for your store? See API integrations.
