Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to get the Price of a product in the Markets?

How to get the Price of a product in the Markets?

Finnx
Shopify Partner
1 0 0

Hello everyone,

 

I have a Markets and, I have changed the currency in Markets (eg. TRY)

 

ScreenShot Tool -20240314114843.png

 

When I use Graphql to get product information with price, I use contextualPricing to get price in Markets.

 

 

query product {
  product(id: "gid://shopify/Product/9253881610551") {
    id
    title
    variants(first: 5) {
      edges {
        node {
          id
          title
          contextualPricing(context: {country: TR}) {
            price {
              amount
              currencyCode
            }
            compareAtPrice {
              amount
              currencyCode
            }
          }
        }
      }
    }
  }
}

Result:

 

 

{
  "data": {
    "product": {
      "id": "gid://shopify/Product/9253881610551",
      "title": "0-18 Months Newborn Infant Clothes Set Toddler Baby Girls Floral Tops Brown Short Pants Baby Girls Outfits Newborn Clothing 9394894",
      "variants": {
        "edges": [
          {
            "node": {
              "id": "gid://shopify/ProductVariant/48196263248183",
              "title": "18M",
              "contextualPricing": {
                "price": {
                  "amount": "1.0",
                  "currencyCode": "TRY"
                },
                "compareAtPrice": {
                  "amount": "1.0",
                  "currencyCode": "TRY"
                }
              }
            }
          },
          {
            "node": {
              "id": "gid://shopify/ProductVariant/48196263280951",
              "title": "12M",
              "contextualPricing": {
                "price": {
                  "amount": "1.0",
                  "currencyCode": "TRY"
                },
                "compareAtPrice": {
                  "amount": "1.0",
                  "currencyCode": "TRY"
                }
              }
            }
          },
          {
            "node": {
              "id": "gid://shopify/ProductVariant/48196263313719",
              "title": "6M",
              "contextualPricing": {
                "price": {
                  "amount": "1.0",
                  "currencyCode": "TRY"
                },
                "compareAtPrice": {
                  "amount": "1.0",
                  "currencyCode": "TRY"
                }
              }
            }
          },
          {
            "node": {
              "id": "gid://shopify/ProductVariant/48196263346487",
              "title": "3M",
              "contextualPricing": {
                "price": {
                  "amount": "1.0",
                  "currencyCode": "TRY"
                },
                "compareAtPrice": {
                  "amount": "1.0",
                  "currencyCode": "TRY"
                }
              }
            }
          }
        ]
      }
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 9,
      "actualQueryCost": 7,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1993,
        "restoreRate": 100
      }
    }
  }
}

I get the value of Price in contextualPricing as 1 TRY, completely different from what I have set in Markets.

 

Don't know where I'm going wrong, and how I can get the contextualPricing exactly like in Markets.

 

Thanks, everyone.

Reply 1 (1)

Mia_123
Shopify Partner
3 0 0

Hi,

Maybe you can try to get the market price from storefront  api. And there's a setup manual. https://shopify.dev/docs/storefronts/headless/building-with-the-storefront-api/markets/international...