Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
I am using the storefront API with hydrogen and using the cartCreate mutation. I have 20 line items that I’m passing to cartCreate and there is one line item that errors out:
'The merchandise with id gid://shopify/ProductVariant/45060060774721 does not exist.'
This item exists in my store and I don’t see anything wrong with it. Would there be any reason the storefront api wouldn’t see it?
thank you!!!
Solved! Go to the solution
This is an accepted solution.
Figured it out. It was something I did. I have a custom Shopify App (using Admin API) that regularly updates the price of the products and every time it did an update, it changed the ProductVariantID of the products which wasn't intended. I fixed it to make sure I passed the ProductVariantID when doing a productUpdate mutation. Silly me.
When i query it using the Admin GraphQL API, it exists. But using the Storefront GraphQL API, it is null. This is really weird.
I just realized that the ProductVariant ID that was used by the CartLineItem in my cart was non-existent. I have no idea where this ProductVariant ID came from. When doing a query for a productByHandle, I get this ProductVariant ID :
//query
{
productByHandle(handle:"pacifica-beauty-ginger-root-10-in-1-hair-volumizer-spray-root-booster-for-hair-volume-lightweight-formula-for-all-hair-types-vitamins-antioxidants-sulfate-free-silicone-free-vegan"){
variants(first:10){
nodes {
id
}
}
}
}
//output
{
"data": {
"productByHandle": {
"variants": {
"nodes": [
{
"id": "gid://shopify/ProductVariant/45693587161409"
}
]
}
}
},
But looking at my Cart, this is the ProductVariant for that CartLineItem:
{
"id":"gid://shopify/ProductVariant/45576784970049",
"product":{
"handle":"pacifica-beauty-ginger-root-10-in-1-hair-volumizer-spray-root-booster-for-hair-volume-lightweight-formula-for-all-hair-types-vitamins-antioxidants-sulfate-free-silicone-free-vegan",
"title":"Pacifica Beauty, Ginger Root 10 In 1 Hair Volumizer Spray, Root Booster For Hair Volume, Lightweight Formula, For All Hair Types, Vitamins + Antioxidants, Sulfate Free, Silicone Free, Vegan",
"id":"gid://shopify/Product/8337199399233"
}
}
Has anyone ever encountered this discrepancy?
This is an accepted solution.
Figured it out. It was something I did. I have a custom Shopify App (using Admin API) that regularly updates the price of the products and every time it did an update, it changed the ProductVariantID of the products which wasn't intended. I fixed it to make sure I passed the ProductVariantID when doing a productUpdate mutation. Silly me.
I also encountered the same problem, is it solved now?