How to identify a Tip line item with Graphql Order API?

The GraphQL Order API returns the tip (that’s added in Shopify checkout) as a line item, but does not show it as a line item in the order details page.

In the REST API there was a “tip” field on the line item, but it doesn’t exist in GraphQL.

The only identifier I could find is product title “Tip”, but that could also be the name of a regular product title.

Could someone please tell me how to identify if the line item is a tip entered during checkout?

Thanks

Hey @joesideas ,

This is an interesting one. I created an order with a TIP to see what would be returned and while there isn’t a field for TIP on the line item, I do notice that fields like product and sku will return NULL on the line item

{
                        "id": "gid://shopify/LineItem/39772252373014",
                        "name": "Tip",
                        "sku": null,
                        "title": "Tip",
                        "vendor": null,
                        "sellingPlan": null,
                        "restockable": false,
                        "requiresShipping": false,
                        "product": null
                    }

I also created a product called TIP, and when applied on the same order, the TIP product does return products, vendor, sku, etc, so this can be a way to differentiate.

The order object also has a totalTipReceivedSet that you can use to help identify orders with Tips.

Would that work for you?

This is a good idea. I was thinking there should be some way to explicitly identify a tip, but I think by adding these extra fields and if name is Tip and those fields are blank, that should mean it’s a tip.

Thanks, I like this and appreciate your effort and help. :folded_hands:

1 Like