How to get the product detail using product variant id ?

rdewan
Shopify Partner
4 0 0

Hi,
Is there any way to get a product detail using the product variant id? I am using the store front GraphQL. Once I create a Cart and CartLine , there is only product variant id , so in the cart page i would like to show the product info like like name , image etc,

Reply 1 (1)
msoni395
Shopify Partner
1 0 0

 Yes, you can use the productVariant field to get detail of the product variant using its id. Like this:-
{  productVariant(id: "YOUR_PRODUCT_VARIANT_ID")

   { 

      id
      title
      image
       {
           originalSrc
           altText

       }

   }
}