cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 API (guest carts)

SOLVED

Magento 2 API (guest carts)

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

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2 API (guest carts)

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:

 

  1. guest carts are defined by a regular ID (I mean, a number) as well as a mask key (a string)
  2. 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.

View solution in original post

2 REPLIES 2

Re: Magento 2 API (guest carts)

Re: Magento 2 API (guest carts)

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:

 

  1. guest carts are defined by a regular ID (I mean, a number) as well as a mask key (a string)
  2. 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.