Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I'm trying to create a new checkout using the new storefront API, I'm using the checkoutCreate mutation, and I'm passing in the lineItems argument the correct variant id where I'm getting from here (see the image bellow), and I get alwaise an error with the message Variant is invalid
@abdelhakim were you able to resolve it ?
@mak no still have the same issue
Which variantid you have used?.. You should not use variantid as like in shopify admin(in numbers such as 343345222). You should use variantid returned by fetching variant using store front API ( such as Zedfrigrenjdfkjknkrgkrgkrngrg=)
Hi Muthu,
Following is the request I made where Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzk2NzU4MzM0MTY= is the variant ID used which I got from Shopify's Admin as mentioned by @abdelhakim
mutation{
checkoutCreate(input:{
email:"mak@example.com",
allowPartialAddresses:true,
shippingAddress:{
city:"Toronto",
province:"ON",
country:"Canada"
},
lineItems:{
variantId:"Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0Lzk2NzU4MzM0MTY=",
quantity:1
}
})
}
Hi mak,
Have you published the product to the sales channel? this is required to access the product and its variants
Hi Muthu,
Yes, I've published the product to all the sales channel.
Hello @abdelhakim & @mak!
I took a look at your problem and it seems like you are using a Product ID, and not a Product Variant ID!
When you are fetching products, make sure you get all variants for the products by querying them like this:
query {
shop{
products(first: 5) {
edges {
node {
variants(first: 5) {
edges {
node {
id
}
}
}
}
}
}
}
}
Let me know if that fixes your problem!
To learn more visit the Shopify Help Center or the Community Blog.
@muthu "Have you published the product to the sales channel? this is required to access the product and its variants"
Thanks for the answer.