What's your biggest current challenge? Have your say in Community Polls along the right column.
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

product_id is null in line_items for order API

product_id is null in line_items for order API

sellercrafttest
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)

Liam
Community Manager
3108 344 895

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 Shopify.dev or the Shopify Web Design and Development Blog