When using the graphql storefront api, I can create an empty checkout, but if I try to create a checkout with items, or add items to an existing checkout, the checkout comes back null.
This works:
mutation { checkoutCreate(input: {}) { checkout { id webUrl lineItems(first: 5) { edges { node { title quantity } } } } } }
which returns
{ "data": { "checkoutCreate": { "checkout": { "id": "Z2lkOi8vc2hvcGlmeS9DaGVja291dC80NGFkMzA1NzEyNmVjMTY0YzU0ODE0MGQ1OWU1ZjcyYj9rZXk9ZDNlNjRkNzU2ODg2NDdiNzJmNDViNzcwYjYyYWQ3MTM=", "webUrl": "https://knowyourh2o.myshopify.com/25164513346/checkouts/44ad3057126ec164c548140d59e5f72b?key=d3e64d75688647b72f45b770b62ad713", "lineItems": { "edges": [] } } } } }
But this fails:
mutation { checkoutCreate(input: { lineItems: [{ variantId: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zMjE0ODUzODYyMjAxOA==", quantity: 1 }] }) { checkout { id webUrl lineItems(first: 5) { edges { node { title quantity } } } } } }
which returns:
{ "data": { "checkoutCreate": { "checkout": null } } }
I can't for the life of me figure out what he issue is. The variantID is correct as verified by the below query to the admin by using the variantID:
query { node(id: "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0VmFyaWFudC8zMjE0ODUzODYyMjAxOA==") { ... on ProductVariant { id } } }
which returns:
{ "data": { "node": { "id": "gid://shopify/ProductVariant/32148538622018" } }, "extensions": { "cost": { "requestedQueryCost": 1, "actualQueryCost": 1, "throttleStatus": { "maximumAvailable": 1000, "currentlyAvailable": 999, "restoreRate": 50 } } } }
Can anyone point me in the right direction?
Thank you!
Solved! Go to the solution
This is an accepted solution.
Figured it out. Total newbie problem. The product was not yet made available to the sales channel.
User | Count |
---|---|
16 | |
12 | |
7 | |
6 | |
5 |