product_id is null in line_items for order API

product_id is null in line_items for order API

Shopify Partner
2 0 0

I'm trying to pull the order's data from the API but the line_item in the photo attached doesn't have product_id. Please advise on how to deal with this or resolve if it is a bug. Thanks.

Free gift.png

Reply 1 (1)

Shopify Staff
2873 312 821

Receiving "null" for `product_id` in `line_items` could be due to a couple of reasons:

  1. The product associated with the line item was deleted: If the product was deleted after the order was created, the line item would not have a `product_id`.

  2. Custom items: If the line item is for shipping costs or you've added custom items using a draft order, they would not have a product_id.

In these situations, you can still identify the line item by its 'line_item_id'. If you need to identify the product, you can use the 'product_title' or 'name' fields.


Hope this helps!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit or the Shopify Web Design and Development Blog