philhawksworth / shopify-11ty

A reference site for exploring the Shopify storefront API with Eleventy
47 stars 8 forks source link

Creating a cart with the Shopify Storefront API always returns null #1

Closed hddm closed 3 years ago

hddm commented 3 years ago

Hi @philhawksworth ,

Thank you so much for writing the blog article "Build your own shop with the Shopify Storefront API, Eleventy, and serverless functions" It helped me a lot to create my custom Shopify front-end. I followed your instructions and everything went well until I tried to create a cart using the createCartWithItem.js function. The API always returns

{
  "data": {
    "cartCreate": {
      "cart": null
    }
  }
}

I ensured that my private shop had the "Read and modify checkouts" option checked to enable _unauthenticated_writecheckouts as specified in Shopify docs

I just wonder if you faced a similar issue while working on this project.

By the way, your blog post made me try Netlify and I managed to set my 11ty marketing website within 1 hour. It is currently hosted in AWS S3/Cloudfront but I will probably host it under Netlify.

Thank you so much for your help,

David

hddm commented 3 years ago

I found out that there was an option to enable the userErrors in the createCart mutation. Now the error says: "The merchandise with id gid://shopify/ProductVariant/35090584273063 does not exist" The product variant ID 35090584273063 exists though so I'm not sure what's happening.

hddm commented 3 years ago

I managed to figure it out. After reading this, since I was under the lite plan, I had upgrade to the basic plan and make the products available for the online store. It was not enough to make the products available for my private app.