Legacy Knowledge Base
Published Jun. 30, 2025

Adding options to an item in order creation with POST headless-commerce-admin-order/v1.0/orders API

Written By

Sorin Pop

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

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

 

 

Did this article resolve your issue ?

Legacy Knowledge Base