Shopify International Pricing with GraphQL: Navigating Contextual vs. Price Lists
Hey everyone, your Shopify migration expert here, diving into a really interesting discussion that popped up in the community recently. It's a common challenge, especially for store owners expanding globally or building custom storefront experiences: how do you reliably pull market-specific prices using GraphQL?
Our friend myappsmarket kicked off a thread asking for help with this exact issue. They were trying to compare prices from a market catalog against what they were getting through GraphQL, and things weren't quite lining up. Let's break down what happened and, more importantly, how we can navigate this.
The Pricing Puzzle: Why Isn't My GraphQL Matching?
myappsmarket shared a great example with a "Long Sleeved Tee" product. They showed a screenshot of a product variant priced at SAR 1.00 (with an original price of SAR 42.00) in a Saudi Arabian market catalog. But when they tried to fetch this data using GraphQL, they saw different results depending on the query.
Here's the visual they shared:
The core of the problem, as I see it, often comes down to understanding the nuances of Shopify's GraphQL API, especially when dealing with multi-market pricing. There are two main ways to fetch pricing data, and they serve different purposes: contextualPricing and priceList.
Attempt 1: Using productVariants with contextualPricing
myappsmarket first tried using the productVariants query, specifically requesting contextualPricing for a given country context (country: SA for Saudi Arabia). This is a really powerful feature for getting dynamic prices based on where your customer is browsing from.
query MyQuery {
productVariants(first: 250, query: "product_id:7154589564985") {
nodes {
title
contextualPricing(context: {country: SA}) {
price {
amount
currencyCode
}
compareAtPrice {
amount
currencyCode
}
}
product {
title
}
}
}
}
The output for this query, for the highlighted "Beige / Large / Rubber" variant, actually showed:
{
"data": {
"productVariants": {
"nodes": [
...
{
"title": "Beige / Large / Rubber",
"contextualPricing": {
"price": {
"amount": "1.0",
"currencyCode": "SAR"
},
"compareAtPrice": {
"amount": "42.0",
"currencyCode": "SAR"
}
},
"product": {
"title": "Long Sleeved Tee"
}
},
...
]
}
},
"extensions": { ... }
}
Here's the kicker: If you look closely at this output, for the "Beige / Large / Rubber" variant, the price is "1.0" SAR and the compareAtPrice is "42.0" SAR. This perfectly matches the screenshot! So, in this case, the contextualPricing query was actually doing its job right for the specific variant myappsmarket highlighted.
Attempt 2: Querying a Specific priceList
Next, myappsmarket tried using the priceList query, providing a specific id for a price list:
query MyQuery {
priceList(id: "gid://shopify/PriceList/22171975737") {
prices(first: 250, query: "product_id:7154589564985") {
nodes {
price {
amount
currencyCode
}
compareAtPrice {
amount
currencyCode
}
variant {
title
}
}
}
}
}
The output for this query showed something completely different:
{
"data": {
"priceList": {
"prices": {
"nodes": [
...
{
"price": {
"amount": "13.99",
"currencyCode": "INR"
},
"compareAtPrice": {
"amount": "999.99",
"currencyCode": "INR"
},
"variant": {
"title": "Beige / Large / Rubber"
}
},
...
]
}
}
},
"extensions": { ... }
}
Notice the currency here? It's INR (Indian Rupee), not SAR. And the prices are very different (e.g., 13.99 INR vs. 1.0 SAR). This is where the real discrepancy was coming from!
Understanding the Difference: contextualPricing vs. priceList
This community exchange, even with just one initial post, really highlights a crucial distinction in Shopify's GraphQL API for pricing:
-
contextualPricing: This is your go-to for fetching prices that are dynamic and based on the customer's browsing context – typically their country or region. Shopify's multi-currency and multi-market features integrate directly with this. When you set up markets in your Shopify admin,contextualPricingis designed to reflect those market-specific prices, including any localized discounts or adjustments. It's about displaying the right price to the right customer, automatically. -
priceList: Think ofpriceListas a specific, pre-defined catalog of prices. These are often used for wholesale, B2B, or special campaigns where you want to apply a fixed set of prices to certain customers or scenarios, regardless of their dynamic browsing context. EachpriceListhas its own ID and is typically associated with a specific currency and possibly a set of customer segments. You're querying a static set of prices from a specific list, not dynamically adjusted market prices.
So, How Do You Get Market Catalog Prices Correctly?
Based on myappsmarket's experience and the API's design, here's how to ensure you're getting the right prices for your market catalogs:
1. For Dynamic Market-Specific Prices (like a public storefront): Use contextualPricing
If you're building a public-facing storefront and want to display prices that automatically adjust based on the customer's country (as configured in your Shopify Markets settings), contextualPricing is the way to go. It's designed for this exact purpose.
Instructions:
-
Identify the Product Variant: You'll need the
product_id(orvariant_id) for the item you're interested in. -
Specify the Context: Crucially, provide the
contextargument tocontextualPricing. This tells Shopify which market's pricing you want. For example,{country: SA}for Saudi Arabia, or{country: US, currency: USD}if you need to be more specific. -
Query
priceandcompareAtPrice: These fields will give you the current selling price and the original (or 'compare at') price for that specific market.
myappsmarket's first query example is a perfect illustration of this. It correctly pulled the SAR 1.00 and SAR 42.00 prices for the specified variant in Saudi Arabia.
2. For Specific, Pre-Defined Pricing Structures: Use priceList (and Verify its Configuration)
If your goal truly is to pull prices from a *specific* price list (e.g., a wholesale price list you've created), then the priceList query is correct. However, the key is to ensure you're querying the right price list.
Instructions:
-
Know Your Price List ID: Make sure the
idyou're providing to thepriceListquery (e.g.,gid://shopify/PriceList/22171975737) corresponds to the actual price list you intend to query. - Verify Price List Currency and Market Association: Within your Shopify admin, check the settings for that specific price list. What currency is it configured for? Is it assigned to the correct market or customer segment you're expecting? In myappsmarket's case, the queried price list was clearly configured for INR, which is why it returned INR prices, not SAR.
-
Query
priceandcompareAtPricefrom thepricesfield: Once you've got the correct price list, you can fetch the relevant pricing data from its associated prices.
It seems like the `priceList` myappsmarket was querying was simply not the one configured for the Saudi Arabian market with SAR currency. This is a common pitfall – assuming a price list is global or universally applicable when it's actually tied to specific currencies or customer groups.
Ultimately, the key takeaway here is to choose the right GraphQL tool for the job. For dynamic, market-aware pricing on a global storefront, contextualPricing is your best friend. If you're dealing with very specific, pre-defined pricing tiers, then priceList is what you need, but always double-check that you're referencing the correct list with the appropriate currency and market configurations. It's all about understanding what each part of the API is designed to do!
