Description
Preconditions and environment
- 2.4.7-p1
- Only for configurables
- Based on default instance with sample data
Steps to reproduce
-
Create guest cart with rest api:
Post tohttps://11bfd466f8c258a1113feb50fd641584.instances-prod.magento-community.engineering/rest/V1/guest-carts/
and use that masked id. -
Get the guest cart to determine quote id:
Get tohttps://11bfd466f8c258a1113feb50fd641584.instances-prod.magento-community.engineering/rest/V1/guest-carts/{{masked_id}}
-
Add just 1 configurable to cart:
Post to:https://11bfd466f8c258a1113feb50fd641584.instances-prod.magento-community.engineering/rest/V1/guest-carts/{{masked_id}}/items
with body:
{
"cartItem": {
"sku": "MH02",
"qty": 1,
"quote_id": "{{quote_id}}",
"product_option": {
"extension_attributes": {
"configurable_item_options": [
{
"option_id": "93",
"option_value": 49
},
{
"option_id": "142",
"option_value": 166
}
]
}
},
"extension_attributes": {}
}
}
Note: Use the item_id of the configurable type (not the simple)
PUT to https://11bfd466f8c258a1113feb50fd641584.instances-prod.magento-community.engineering/rest/V1/guest-carts/{{masked_id}}/items/{{item_id}}
with body:
{
"cartItem": {
"sku": "MH02",
"qty": 100,
"quote_id": "{{quote_id}}",
"product_option": {
"extension_attributes": {
"configurable_item_options": [
{
"option_id": "93",
"option_value": 49
},
{
"option_id": "142",
"option_value": 166
}
]
}
},
"extension_attributes": {}
}
}
Now the response of the call is:
{
"message": "The requested qty is not available"
}
Expected result
When doing step 4 the requested qty of 100 should be in the cart after the post request instead of an exception
Actual result
This exception is thrown in step 4:
{
"message": "The requested qty is not available"
}
Additional information
while the actual stock is 100, so this should work. The error is thrown from this file: vendor/magento/module-inventory-sales/Model/IsProductSalableForRequestedQtyCondition/IsSalableWithReservationsCondition.php
and after debugging it is because in this validator the $requestedQty is 101 instead of 100, so the requested quantity from the api call is added to the current quantity in the cart.
In \Magento\Quote\Model\Quote::updateItem on line 1805 there is a $buyRequest->setResetCount(true);
to reset the actual counter, but when the reset_count
is red in the request on line 94 here: \Magento\Quote\Model\Quote\Item\Processor::prepare
there is another check: $item->getId() == $request->getId()
which will be never true because the request does not have the id of the item.
Release note
No response
Triage and priority
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.