Issue
Symptoms
When two-step checkout is enabled and when we use scripted web services to order an item (by passing in the custom cart with the sys_id of the item as a parameter to n_sc.CartJS), all items in the DEFAULT cart is being ordered instead of the specified item in the request body.
Release
Kingston
Cause
This is a bug in the platform and a PRB1297366 is created to fix the issue.
Resolution
The dev team is working on a fix for this issue at the time of this writing (PRB1297366).
However, we have a workaround to resolve the issue.
WORKAROUND:
we can make use of the OOB REST API named "Buy Item", which has this endpoint,
One modification is required to get over the issue and it is to add this parameter along with other parameters to the request body,
'get_portal_messages': 'true'
Now it will directly order the item specified in the request body rather than all the items in the DEFAULT/portal cart.
To test the endpoint, please navigate to "System Web services" -> "REST" -> "REST API EXPLORER"
2. Select theNamespace -> sn_sc
3. Click on the API named "Buy Item (POST)"
4. Give the sys_id of the item being ordered.
5. Please provide variable values, if any, for the item.
6. Add the quantity (sysparm_quantity) and the above mentioned parameter, 'get_portal_messages': 'true'.
Click send.
Now we can see from the response that it orders only the item being specified and not all the items in the DEFAULT cart.