Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Cannot add LineItem to cart with MerchandiseID from ProductVariant

Cannot add LineItem to cart with MerchandiseID from ProductVariant

_chath_s_
Tourist
5 0 6

Hi I am trying to add line items to the customer cart from STOREFRONT API as below with the merchandiseId (type ID) of the productVariant received from products query.: 

 

 

 

{
    "cartId": "Z2lkOi8vc2hvcGlmeS9DYXJ0L2U2ZmEyZjI0OTZmNGJhNjBmZWZmZWFlZWYxMTQyMzAx",
    "lines": [
        {
            "quantity": 1,
            "merchandiseId": "gid://shopify/ProductVariant/{id received from products query}"
        }
    ]
}

 

 

 

 

I am getting the below error:

 

The merchandise with id gid://shopify/ProductVariant/0 does not exist.

 

 

However, this does work if I provide the merchandiseId to be a string (same as whats in the url of the admin panel as below underlined in "yellow")
Screenshot 2022-02-15 at 12.01.22 PM.png
I am not sure how I can get this "string" type id, instead of the "ID" type id from the products query.

Reply 1 (1)

Maxzhou
Shopify Partner
6 0 0

I also encountered the same problem, is it solved now?