Invoice creation fails for configurable items when using the Adobe Commerce REST API
Invoice creation using the Adobe Commerce REST API fails for configurable products, where the item does not appear on the invoice and validation errors do not trigger. To fix this issue, reference the item ID of the configurable (parent) product instead of the simple (child) product in the invoice request.
Description description
Environment
Adobe Commerce
Issue/Symptoms
- Invoices created through the API do not include configurable products.
- No error message appears when only child (simple) item IDs are used.
- Including both parent and child item IDs with zero quantity for the parent returns The invoice can’t be created without products.
- Simple products invoice successfully.
Resolution resolution
To fix this issue, follow these steps:
-
Identify the item ID of the configurable (parent) product from the order by querying the
sales_order_itemtable.code language-none select item_id, sku, product_type from sales_order_item; 208 simple_skuA configurable 211 simple_skuA simple 214 simple_skuB configurable 217 simple_skuB simple 220 simple_skuC simple 223 simple_skuD simple -
Create the invoice through the REST API by including only the item ID of the configurable parent product in the request payload.
Note: Do not include child (simple) product item IDs, and do not set the quantity to zero for any items.
-
Submit the invoice creation request using the following payload structure:
code language-none curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <token>" \ https://<store_url>/rest/V1/order/<order_id>/invoice { "items": [ { "order_item_id": 208, "qty": 1 }, { "order_item_id": 220, "qty": 1 }, { "order_item_id": 223, "qty": 1 } ] } -
Verify that the created invoice includes line items for all intended configurable products.
Note
If multiple variations of a configurable product exist within an order, use each relevant parent item ID corresponding to those variations when creating invoices.
select item_id, sku, product_type from sales_order_item;
226 simple_skuA configurable
229 simple_skuA simple
232 simple_skuB configurable
235 simple_skuB simple
In this example, the payload to invoice variant B of the SKU simple_skuB uses the parent item ID 232.