# ProductVariant - admin-graphql - OBJECT Version: 2024-10 ## Description Represents a product variant. ### Access Scopes `read_products` access scope. ## Fields * [availableForSale](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether the product variant is available for sale. * [barcode](/docs/api/admin-graphql/2024-10/scalars/String): String - The value of the barcode associated with the product. * [compareAtPrice](/docs/api/admin-graphql/2024-10/scalars/Money): Money - The compare-at price of the variant in the default shop currency. * [contextualPricing](/docs/api/admin-graphql/2024-10/objects/ProductVariantContextualPricing): ProductVariantContextualPricing! - The pricing that applies for a customer in a given context. * [createdAt](/docs/api/admin-graphql/2024-10/scalars/DateTime): DateTime! - The date and time when the variant was created. * [defaultCursor](/docs/api/admin-graphql/2024-10/scalars/String): String! - A default [cursor](https://shopify.dev/api/usage/pagination-graphql) that returns the single next record, sorted ascending by ID. * [deliveryProfile](/docs/api/admin-graphql/2024-10/objects/DeliveryProfile): DeliveryProfile - The [delivery profile](https://shopify.dev/api/admin-graphql/latest/objects/DeliveryProfile) for the variant. * [displayName](/docs/api/admin-graphql/2024-10/scalars/String): String! - Display name of the variant, based on product's title + variant's title. * [id](/docs/api/admin-graphql/2024-10/scalars/ID): ID! - A globally-unique ID. * [image](/docs/api/admin-graphql/2024-10/objects/Image): Image - The featured image for the variant. * [inventoryItem](/docs/api/admin-graphql/2024-10/objects/InventoryItem): InventoryItem! - The inventory item, which is used to query for inventory information. * [inventoryPolicy](/docs/api/admin-graphql/2024-10/enums/ProductVariantInventoryPolicy): ProductVariantInventoryPolicy! - Whether customers are allowed to place an order for the product variant when it's out of stock. * [inventoryQuantity](/docs/api/admin-graphql/2024-10/scalars/Int): Int - The total sellable quantity of the variant. * [legacyResourceId](/docs/api/admin-graphql/2024-10/scalars/UnsignedInt64): UnsignedInt64! - The ID of the corresponding resource in the REST Admin API. * [metafield](/docs/api/admin-graphql/2024-10/objects/Metafield): Metafield - A [custom field](https://shopify.dev/docs/apps/build/custom-data), including its `namespace` and `key`, that's associated with a Shopify resource for the purposes of adding and storing additional information. * [position](/docs/api/admin-graphql/2024-10/scalars/Int): Int! - The order of the product variant in the list of product variants. The first position in the list is 1. * [price](/docs/api/admin-graphql/2024-10/scalars/Money): Money! - The price of the product variant in the default shop currency. * [privateMetafield](/docs/api/admin-graphql/2024-10/objects/PrivateMetafield): PrivateMetafield - Returns a private metafield by namespace and key that belongs to the resource. * [product](/docs/api/admin-graphql/2024-10/objects/Product): Product! - The product that this variant belongs to. * [requiresComponents](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether a product variant requires components. The default value is `false`. If `true`, then the product variant can only be purchased as a parent bundle with components and it will be omitted from channels that don't support bundles. * [selectedOptions](/docs/api/admin-graphql/2024-10/objects/SelectedOption): SelectedOption! - List of product options applied to the variant. * [sellableOnlineQuantity](/docs/api/admin-graphql/2024-10/scalars/Int): Int! - The total sellable quantity of the variant for online channels. This doesn't represent the total available inventory or capture [limitations based on customer location](https://help.shopify.com/manual/markets/inventory_and_fulfillment). * [sellingPlanGroupCount](/docs/api/admin-graphql/2024-10/scalars/Int): Int! - Count of selling plan groups associated with the product variant. * [sellingPlanGroupsCount](/docs/api/admin-graphql/2024-10/objects/Count): Count - Count of selling plan groups associated with the product variant. * [sku](/docs/api/admin-graphql/2024-10/scalars/String): String - A case-sensitive identifier for the product variant in the shop. Required in order to connect to a fulfillment service. * [storefrontId](/docs/api/admin-graphql/2024-10/scalars/StorefrontID): StorefrontID! - The Storefront GraphQL API ID of the `ProductVariant`. As of the `2022-04` version release, the Storefront GraphQL API will no longer return Base64 encoded IDs to match the behavior of the Admin GraphQL API. Therefore, you can safely use the `id` field's value instead. * [taxCode](/docs/api/admin-graphql/2024-10/scalars/String): String - The tax code for the product variant. * [taxable](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether a tax is charged when the product variant is sold. * [title](/docs/api/admin-graphql/2024-10/scalars/String): String! - The title of the product variant. * [translations](/docs/api/admin-graphql/2024-10/objects/Translation): Translation! - The published translations associated with the resource. * [unitPriceMeasurement](/docs/api/admin-graphql/2024-10/objects/UnitPriceMeasurement): UnitPriceMeasurement - The unit price measurement for the variant. * [updatedAt](/docs/api/admin-graphql/2024-10/scalars/DateTime): DateTime! - The date and time (ISO 8601 format) when the product variant was last modified. ## Connections * [events](/docs/api/admin-graphql/2024-10/connections/EventConnection): EventConnection! * [media](/docs/api/admin-graphql/2024-10/connections/MediaConnection): MediaConnection! * [metafieldDefinitions](/docs/api/admin-graphql/2024-10/connections/MetafieldDefinitionConnection): MetafieldDefinitionConnection! * [metafields](/docs/api/admin-graphql/2024-10/connections/MetafieldConnection): MetafieldConnection! * [presentmentPrices](/docs/api/admin-graphql/2024-10/connections/ProductVariantPricePairConnection): ProductVariantPricePairConnection! * [privateMetafields](/docs/api/admin-graphql/2024-10/connections/PrivateMetafieldConnection): PrivateMetafieldConnection! * [productVariantComponents](/docs/api/admin-graphql/2024-10/connections/ProductVariantComponentConnection): ProductVariantComponentConnection! * [sellingPlanGroups](/docs/api/admin-graphql/2024-10/connections/SellingPlanGroupConnection): SellingPlanGroupConnection! ## Related queries * [productVariant](/docs/api/admin-graphql/2024-10/queries/productVariant) Returns a ProductVariant resource by ID. * [productVariants](/docs/api/admin-graphql/2024-10/queries/productVariants) Returns a list of product variants. ## Related mutations * [productVariantAppendMedia](/docs/api/admin-graphql/2024-10/mutations/productVariantAppendMedia) Appends media from a product to variants of the product. * [productVariantDetachMedia](/docs/api/admin-graphql/2024-10/mutations/productVariantDetachMedia) Detaches media from product variants. * [productVariantJoinSellingPlanGroups](/docs/api/admin-graphql/2024-10/mutations/productVariantJoinSellingPlanGroups) Adds multiple selling plan groups to a product variant. * [productVariantLeaveSellingPlanGroups](/docs/api/admin-graphql/2024-10/mutations/productVariantLeaveSellingPlanGroups) Remove multiple groups from a product variant. * [productVariantRelationshipBulkUpdate](/docs/api/admin-graphql/2024-10/mutations/productVariantRelationshipBulkUpdate) Creates new bundles, updates existing bundles, and removes bundle components for one or multiple bundles. * [productVariantsBulkCreate](/docs/api/admin-graphql/2024-10/mutations/productVariantsBulkCreate) Creates multiple variants in a single product. This mutation can be called directly or via the bulkOperation. * [productVariantsBulkUpdate](/docs/api/admin-graphql/2024-10/mutations/productVariantsBulkUpdate) Updates multiple variants in a single product. This mutation can be called directly or via the bulkOperation. * [quantityPricingByVariantUpdate](/docs/api/admin-graphql/2024-10/mutations/quantityPricingByVariantUpdate) Updates quantity pricing on a price list. You can use the `quantityPricingByVariantUpdate` mutation to set fixed prices, quantity rules, and quantity price breaks. This mutation does not allow partial successes. If any of the requested resources fail to update, none of the requested resources will be updated. Delete operations are executed before create operations. ## Related Unions * [CommentEventEmbed](/docs/api/admin-graphql/2024-10/unions/CommentEventEmbed) The main embed of a comment event. * [MetafieldReference](/docs/api/admin-graphql/2024-10/unions/MetafieldReference) The resource referenced by the metafield value. * [MetafieldReferencer](/docs/api/admin-graphql/2024-10/unions/MetafieldReferencer) Types of resources that may use metafields to reference other resources. ## Examples ### Get a metafield attached to a product variant Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) { productVariant(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } }\",\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"liner_material\",\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n productVariant(id: $ownerId) {\n linerMaterial: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"liner_material\",\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n productVariant(id: $ownerId) {\n linerMaterial: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY\n\nvariables = {\n \"namespace\": \"my_fields\",\n \"key\": \"liner_material\",\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n productVariant(id: $ownerId) {\n linerMaterial: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n {\n variables: {\n \"namespace\": \"my_fields\",\n \"key\": \"liner_material\",\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n productVariant(id: $ownerId) {\n linerMaterial: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}" #### Graphql Input { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/ProductVariant/43729076" } #### Graphql Response { "data": { "productVariant": { "linerMaterial": { "value": "synthetic leather" } } } } ### Get metafields attached to a product variant Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query ProductVariantMetafields($ownerId: ID!) { productVariant(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }\",\n \"variables\": {\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ProductVariantMetafields($ownerId: ID!) {\n productVariant(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query ProductVariantMetafields($ownerId: ID!) {\n productVariant(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query ProductVariantMetafields($ownerId: ID!) {\n productVariant(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductVariantMetafields($ownerId: ID!) {\n productVariant(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n}" #### Graphql Input { "ownerId": "gid://shopify/ProductVariant/43729076" } #### Graphql Response { "data": { "productVariant": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "liner_material", "value": "synthetic leather" } } ] } } } } ### Get pinned metafield definitions associated with a product variant Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { productVariant(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } }\",\n \"variables\": {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n productVariant(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n productVariant(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n productVariant(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n productVariant(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n}" #### Graphql Input { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/ProductVariant/43729076", "first": 10, "sortKey": "PINNED_POSITION" } #### Graphql Response { "data": { "productVariant": { "metafieldDefinitions": { "edges": [ { "node": { "name": "Sole Material", "namespace": "my_fields", "key": "sole_material", "type": { "name": "single_line_text_field" } } }, { "node": { "name": "Liner Material", "namespace": "my_fields", "key": "liner_material", "type": { "name": "single_line_text_field" } } } ] } } } } ### Get the price for a product variant for buyers in Canada Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { productVariant(id: \\\"gid://shopify/ProductVariant/43729076\\\") { contextualPricing(context: {country: CA}) { price { amount currencyCode } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "productVariant": { "contextualPricing": { "price": { "amount": "12.99", "currencyCode": "CAD" } } } } } ### Get the price for a product variant for different countries in the same request Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { productVariant(id: \\\"gid://shopify/ProductVariant/43729076\\\") { CanadaPrice: contextualPricing(context: {country: CA}) { price { amount currencyCode } } USPrice: contextualPricing(context: {country: US}) { price { amount currencyCode } } FrancePrice: contextualPricing(context: {country: FR}) { price { amount currencyCode } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n CanadaPrice: contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n USPrice: contextualPricing(context: {country: US}) {\n price {\n amount\n currencyCode\n }\n }\n FrancePrice: contextualPricing(context: {country: FR}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n CanadaPrice: contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n USPrice: contextualPricing(context: {country: US}) {\n price {\n amount\n currencyCode\n }\n }\n FrancePrice: contextualPricing(context: {country: FR}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n CanadaPrice: contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n USPrice: contextualPricing(context: {country: US}) {\n price {\n amount\n currencyCode\n }\n }\n FrancePrice: contextualPricing(context: {country: FR}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n CanadaPrice: contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n USPrice: contextualPricing(context: {country: US}) {\n price {\n amount\n currencyCode\n }\n }\n FrancePrice: contextualPricing(context: {country: FR}) {\n price {\n amount\n currencyCode\n }\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "productVariant": { "CanadaPrice": { "price": { "amount": "12.99", "currencyCode": "CAD" } }, "USPrice": { "price": { "amount": "10.0", "currencyCode": "USD" } }, "FrancePrice": { "price": { "amount": "4.95", "currencyCode": "EUR" } } } } } ### Receive a single Product Variant Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query GetProductVariant($id: ID!) { productVariant(id: $id) { id title availableForSale barcode compareAtPrice createdAt } }\",\n \"variables\": {\n \"id\": \"gid://shopify/ProductVariant/43729076\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query GetProductVariant($id: ID!) {\n productVariant(id: $id) {\n id\n title\n availableForSale\n barcode\n compareAtPrice\n createdAt\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query GetProductVariant($id: ID!) {\n productVariant(id: $id) {\n id\n title\n availableForSale\n barcode\n compareAtPrice\n createdAt\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/ProductVariant/43729076\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query GetProductVariant($id: ID!) {\n productVariant(id: $id) {\n id\n title\n availableForSale\n barcode\n compareAtPrice\n createdAt\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query GetProductVariant($id: ID!) {\n productVariant(id: $id) {\n id\n title\n availableForSale\n barcode\n compareAtPrice\n createdAt\n }\n}" #### Graphql Input { "id": "gid://shopify/ProductVariant/43729076" } #### Graphql Response { "data": { "productVariant": { "id": "gid://shopify/ProductVariant/43729076", "title": "151cm", "availableForSale": true, "barcode": "12345678", "compareAtPrice": "20.00", "createdAt": "2024-11-12T15:54:57Z" } } } ### Retrieve information for non-existent variant ID Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { productVariant(id: \\\"gid://shopify/ProductVariant/-1\\\") { contextualPricing(context: {country: CA}) { price { amount currencyCode } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n productVariant(id: \"gid://shopify/ProductVariant/-1\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n productVariant(id: \"gid://shopify/ProductVariant/-1\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n productVariant(id: \"gid://shopify/ProductVariant/-1\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n productVariant(id: \"gid://shopify/ProductVariant/-1\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "productVariant": null } }