Repository navigation
Guest cart API ignoring cartId in url for some methods #14086
Description
Preconditions
- Magento 2.2.3
Steps to reproduce
I am following the API documentation to create guest cart and add item to it:
POST https://yourdomain/rest/default/V1/guest-carts(with empty body) creates cart for you and return cartId in bodyGET https://yourdomain/rest/default/V1/guest-carts/:cartIdto check you cart is createdPOST https://yourdomain/rest/default/V1/guest-carts/:cartId/itemswith body
{
"cartItem": {
"sku": "WS12-M-Orange",
"qty": 3
}
}
to add item to your cart, but error is returned instead of adding cart to item
Expected result
In step 3, I was expecting the added item to be returned. Instead of that, error is returned.
Actual result
{
"message": "No such entity with %fieldName = %fieldValue",
"parameters": {
"fieldName": "cartId",
"fieldValue": null
},
"trace": "..."
}
Further research
I discovered: If you send the cartId in quote_id field in body at step 3, the method would work. So the body would be:
{
"cartItem": {
"sku": "WS12-M-Orange",
"qty": 3,
"quote_id": ":cartId"
}
}
And the results is cart item, no error. The cartId in url is completly ignored. If you use send request with some dummy string instead of cartId in URL (with the body with quote_id field), it actually works.
So request like
POST https://yourdomain/rest/default/V1/guest-carts/some_dummy_string_insetead_of_cartId/items
works. But it should not! And the mandatory quote_id in body is also wrong I think. The only cartId needed to add the item to the cart should be the one from URL (which is not used at all at the moment).
The same problem is present on other methods in guest-cart.
Activity
magento-engcom-team commentedon Mar 14, 2018
@midlan, thank you for your report.
We've acknowledged the issue and added to our backlog.
elzekool commentedon Mar 17, 2018
I've created a PR for this issue. Investigating this a little further I found a related issue for the normal cart API. In the case /V1/carts/mine/items is used it allows adding/editing items to a quote different then the actual customer quote.
m2-assistant commentedon Jan 3, 2020
Hi @engcom-Bravo. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
1. Add/Edit
Component: XXXXXlabel(s) to the ticket, indicating the components it may be related to.2. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.- If the issue is reproducible on
2.4-developbranch, please, add the labelReproduced on 2.4.x.- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
3. If the issue is not relevant or is not reproducible any more, feel free to close it.
3 remaining items
magento-engcom-team commentedon Jan 3, 2020
✅ Confirmed by @engcom-Bravo
Thank you for verifying the issue. Based on the provided information internal tickets
MC-30200were createdIssue Available: @engcom-Bravo, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
m2-assistant commentedon Mar 3, 2020
Hi @engcom-Charlie. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:
1. Add/Edit
Component: XXXXXlabel(s) to the ticket, indicating the components it may be related to.2. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.- If the issue is reproducible on
2.4-developbranch, please, add the labelReproduced on 2.4.x.- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
3. If the issue is not relevant or is not reproducible any more, feel free to close it.
magento-engcom-team commentedon Mar 12, 2020
Hi @midlan. Thank you for your report.
The issue has been fixed in #27172 by @engcom-Charlie in 2.4-develop branch
Related commit(s):
The fix will be available with the upcoming 2.4.0 release.
ENGCOM-7075: magento#14086: Guest cart API ignoring cartId in url for…
ENGCOM-7075: magento#14086: Guest cart API ignoring cartId in url for…
🔃 [Magento Community Engineering] Community Contributions - 2.4-devel…
ENGCOM-7075: magento#14086: Guest cart API ignoring cartId in url for…
ENGCOM-7075: magento#14086: Guest cart API ignoring cartId in url for…