Issue
- I have created a new order with an API call, which includes also adding options to the order item, but when I query the order, I see that the options are not there
Steps:
1. Create a Minium site.
2. Create a business account and add the admin user to it.
3. In the minium catalog create a product (e.g. coffee).
4. Go to its Options tab and create a new option (e.g. sugar, of type Text).
5. Write down the channelId and accountId (you can find them on the UI) and accordingly use them in the API call to follow.
6. Get the productId of your product from the response of the following API:
GET localhost:8080/o/headless-commerce-delivery-catalog/v1.0/channels/32351/products?accountId=33816
and use it down the line where productID is needed.
7. Get the "id" field from the response of API call:
GET http://localhost:8080/o/headless-commerce-delivery-catalog/v1.0/channels/32351/products/33821/skus?accountId=33816
and use it down the line where skuId is needed.
8. Create a new order with API call
POST localhost:8080/o/headless-commerce-admin-order/v1.0/orders
and a body like this:
{"accountId":33816, "channelId":32351, "orderItems": [ { "options":"[{\"key\":\"sugar\",\"required\":false,\"value\":[\"no\"]}]", "quantity":1, "skuId":33824, "productId":33821 } ], "printedNote":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse at tellus non nulla venenatis fringilla vel sit amet sem. Maecenas.", "currencyCode":"USD" }
9. Obtain a list of placed orders by using the following API:
GET localhost:8080/o/headless-commerce-admin-order/v1.0/orders?nestedFields=orderItems
and inspect the result.
Result: the "options" field is empty, despite being included in the API request.
Environment
- 7.4
Resolution
- This is intended behavior. We only allow adding of options in the POST API if the CommerceOrder is open in
headless.admin.order
- Therefore, add the following as part of your POST API
"orderStatus": 2