- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm facing a really weird behaviour from the API, that I just can't understand.
First of all, I create a guest cart by calling the following endpoint:
POST /V1/guest-carts
This returns me the cart ID, let's say N3EYfSb9lomhlNOO2LKQ5EEAPy7QfAlP.
Then I'm adding a product by using the following endpoint:
guest-carts/{cartId}/items/{itemId}
cartId: N3EYfSb9lomhlNOO2LKQ5EEAPy7QfAlP
itemId: 2346
Indeed, a product is added to the cart... but not the requested product!
Indeed, while I'm passing the item ID 2346 as a path parameter, in the response I'm getting:
item_id: 1983
What's happening here?
Regards,
Dave
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you @Damian Culotta, the link you provided was usefull!
By reading carefully, I picked up 2 crucial points, pretty confusing IMHO. I'm writing them down right here, in case it can help anyone:
- guest carts are defined by a regular ID (I mean, a number) as well as a mask key (a string)
- adding a product to a cart, returns you an item ID (among others). The point is, an item ID is a functionnal ID which is totally different from the product ID
This last point was causing my issue. To delete a product, you have to pass the item ID, not the product ID.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Magento 2 API (guest carts)
Hi @david_iux.
Can you confirm if the explanation here is correct? https://magento.stackexchange.com/questions/106474/what-is-step-by-step-process-for-add-products-to-...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you @Damian Culotta, the link you provided was usefull!
By reading carefully, I picked up 2 crucial points, pretty confusing IMHO. I'm writing them down right here, in case it can help anyone:
- guest carts are defined by a regular ID (I mean, a number) as well as a mask key (a string)
- adding a product to a cart, returns you an item ID (among others). The point is, an item ID is a functionnal ID which is totally different from the product ID
This last point was causing my issue. To delete a product, you have to pass the item ID, not the product ID.