For the GraphQL DraftOrderLineItem object there is a custom field allowing to determine if the line item is for a custom item or an item with a product variant. See DraftOrderLineItem - GraphQL Admin.
Would it be possible to provide the same information for GraphQL Order LineItem? This would be very helpful.
There is no field that works similar for Order LineItem.
Instead, you can check variant to see if it is custom or product variant.
- if variant is null, it is custom item.
- else, it is product variant.
query GetOrderLineItems {
order(id: YOUR_ORDER_GID) {
lineItems(first: 10) {
edges {
node {
variant {
id
}
}
}
}
}
}
2 Likes
@remy727 thank you for the quick reply. The issue here is how do you distinguish a custom item from an item for which the product variant has been deleted?
@remy727 after further testing on our end and looking at results in REST and GaphQL API the most reliable option is to check if the LineItem variantTitle is null as this cannot be set when creating a custom item.