Decoding Shopify's Market Catalog Prices: A GraphQL Deep Dive

Understanding Market Catalog Pricing with GraphQL in Shopify

Hey everyone! We've been seeing a lot of questions pop up in the community about accurately fetching and comparing prices from Shopify's market catalogs using GraphQL. It can be a bit tricky, so I wanted to break down a recent discussion and offer some insights.

Recently, user myappsmarket posted about an issue they were facing when trying to retrieve market catalog prices using GraphQL. They tried both productVariants and priceList queries but were getting inconsistent results. Let's dive into what they discovered and how we can approach this problem.

The Initial Problem: Price Discrepancies

myappsmarket shared an example where the prices displayed in their market catalog didn't match the data returned by their GraphQL queries. They provided images and code snippets to illustrate the issue, which is super helpful for understanding the context. Here's the image they shared:

Let's take a look at the GraphQL queries they were using:

Querying Product Variants

query MyQuery {
  productVariants(first: 250, query: "product_id:7154589564985") {
    nodes {
      title
      contextualPricing(context: {country: SA}) {
        price {
          amount
          currencyCode
        }
        compareAtPrice {
          amount
          currencyCode
        }
      }
      product {
        title
      }
    }
  }
}

This query uses productVariants and the contextualPricing field to fetch prices for a specific product in Saudi Arabia (SA). The output showed varying prices for different variants, but some values seemed off.

{
  "data": {
    "productVariants": {
      "nodes": [
        {
          "title": "White / X-Small / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "4.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "White / Small / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "5.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "White / Medium / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "4.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "White / Large / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "42.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "Black / X-Small / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "4.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "Black / Small / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "4.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "Black / Medium / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "4.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "Black / Large / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "4.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "Beige / X-Small / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "4.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "Beige / Small / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "4.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "Beige / Medium / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "4.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": null
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "Beige / Large / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "1.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": {
              "amount": "42.0",
              "currencyCode": "SAR"
            }
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "Beige / Extra Large / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "1.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": {
              "amount": "42.0",
              "currencyCode": "SAR"
            }
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "Black / Extra Large / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "4.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": {
              "amount": "0.0",
              "currencyCode": "SAR"
            }
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        },
        {
          "title": "White / Extra Large / Rubber",
          "contextualPricing": {
            "price": {
              "amount": "42.0",
              "currencyCode": "SAR"
            },
            "compareAtPrice": {
              "amount": "0.0",
              "currencyCode": "SAR"
            }
          },
          "product": {
            "title": "Long Sleeved Tee"
          }
        }
      ]
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 35,
      "actualQueryCost": 5,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1995,
        "restoreRate": 100
      }
    },
    "search": [
      {
        "path": [
          "productVariants"
        ],
        "query": "product_id:7154589564985",
        "parsed": {
          "field": "product_id",
          "match_all": "7154589564985"
        }
      }
    ]
  }
}

Querying Price Lists

query MyQuery {
  priceList(id: "gid://shopify/PriceList/22171975737") {
    prices(first: 250, query: "product_id:7154589564985") {
      nodes {
        price {
          amount
          currencyCode
        }
        compareAtPrice {
          amount
          currencyCode
        }
        variant {
          title
        }
      }
    }
  }
}

Next, they tried querying the priceList directly, using the Price List ID. This approach also yielded unexpected results, with prices in INR (Indian Rupees) instead of SAR (Saudi Riyal) for some variants.

{
  "data": {
    "priceList": {
      "prices": {
        "nodes": [
          {
            "price": {
              "amount": "88.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "White / X-Small / Rubber"
            }
          },
          {
            "price": {
              "amount": "100.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "White / Small / Rubber"
            }
          },
          {
            "price": {
              "amount": "88.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "White / Medium / Rubber"
            }
          },
          {
            "price": {
              "amount": "999.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "White / Large / Rubber"
            }
          },
          {
            "price": {
              "amount": "88.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "Black / X-Small / Rubber"
            }
          },
          {
            "price": {
              "amount": "88.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "Black / Small / Rubber"
            }
          },
          {
            "price": {
              "amount": "88.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "Black / Medium / Rubber"
            }
          },
          {
            "price": {
              "amount": "88.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "Black / Large / Rubber"
            }
          },
          {
            "price": {
              "amount": "88.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "Beige / X-Small / Rubber"
            }
          },
          {
            "price": {
              "amount": "88.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "Beige / Small / Rubber"
            }
          },
          {
            "price": {
              "amount": "88.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": null,
            "variant": {
              "title": "Beige / Medium / Rubber"
            }
          },
          {
            "price": {
              "amount": "13.99",
              "currencyCode": "INR"
            },
            "compareAtPrice": {
              "amount": "999.99",
              "currencyCode": "INR"
            },
            "variant": {
              "title": "Beige / Large / Rubber"
            }
          },
          {
            "price": {
              "amount": "13.99",
              "currencyCode": "INR"
            },
            "compareAtPrice": {
              "amount": "999.99",
              "currencyCode": "INR"
            },
            "variant": {
              "title": "Beige / Extra Large / Rubber"
            }
          },
          {
            "price": {
              "amount": "88.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": {
              "amount": "0.0",
              "currencyCode": "INR"
            },
            "variant": {
              "title": "Black / Extra Large / Rubber"
            }
          },
          {
            "price": {
              "amount": "999.0",
              "currencyCode": "INR"
            },
            "compareAtPrice": {
              "amount": "0.0",
              "currencyCode": "INR"
            },
            "variant": {
              "title": "White / Extra Large / Rubber"
            }
          }
        ]
      }
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 25,
      "actualQueryCost": 5,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1995,
        "restoreRate": 100
      }
    },
    "search": [
      {
        "path": [
          "priceList",
          "prices"
        ],
        "query": "product_id:7154589564985",
        "parsed": {
          "field": "product_id",
          "match_all": "7154589564985"
        }
      }
    ]
  }
}

Possible Solutions and Considerations

While there wasn't a definitive solution posted in the thread, here's what we can infer and some potential troubleshooting steps based on my experience:

  • Verify Market Settings: Double-check your Shopify admin to ensure that the market settings are correctly configured for the target country (in this case, Saudi Arabia). Make sure the correct currency is associated with the market.
  • Price List Assignment: Confirm that the correct price list is assigned to the market you're targeting. It's possible that the query is pulling from a default price list or one that's not specific to the Saudi Arabian market.
  • Check for Overrides: Look for any manual price overrides that might be in place for specific variants within the market catalog. These overrides could be causing the discrepancies.
  • API Version: Ensure you're using the latest Shopify API version. Older versions might have limitations or bugs related to market catalog pricing.
  • Consider Using the Storefront API: For displaying prices on your storefront, the Storefront API might be a better option as it's specifically designed for that purpose and often handles contextual pricing more effectively.

Fetching the correct prices for different markets can definitely be a challenge. It looks like myappsmarket was on the right track with their queries, but there might be some underlying configuration issues or data inconsistencies causing the problem. By systematically checking the market settings, price list assignments, and potential overrides, you should be able to pinpoint the source of the discrepancies and ensure that your GraphQL queries return the correct prices for each market.

Share:

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools