legacy-knowledge-base
公開されました Jun. 30, 2025

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

learn-legacy-article-disclaimer-text

問題

  • APIコールで新規注文を作成し、注文アイテムにオプションを追加しました。

ステップ:

1. ミニサイトを作成する。
2. ビジネスアカウントを作成し、管理者ユーザーを追加する。
3. ミニカタログで商品(例:コーヒー)を作成する。
4. Optionsタブに移動し、新しいオプションを作成する(例:Textタイプのsugar)。
5. channelIdとaccountIdをメモしておき(UIで確認できる)、後のAPIコールで使用する。
6. 以下のAPIのレスポンスから商品のproductIdを取得します:

そして、productIDが必要とされる行でそれを使用する。
7. APIコールのレスポンスから "id "フィールドを取得する:

を使用し、skuIdが必要な行でそれを使用する。
8. APIコールで新規注文を作成する

そしてこんな体:

{"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. 以下のAPIを使用して、発注済み注文のリストを取得する:

を実行し、結果を確認する。
結果: APIリクエストに含まれているにもかかわらず、"options "フィールドは空である。

Environment

  • 7.4

解決策

  • これは意図された行動である。 POSTAPIでオプションを追加できるのは、CommerceOrderが headless.admin.orderを開いている場合のみです。
  • したがって、POST API

    "orderStatus" の一部として以下を追加する:2

did-this-article-resolve-your-issue

legacy-knowledge-base