A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Is it possible to determine if an order is for a gift card using the order fields?
https://shopify.dev/api/admin-graphql/2021-10/objects/Order#fields
I believe it may be possible using lineItems and product. But I would prefer not to have to pull that much data.
I am trying to calculate the total sales for a store and I need to remove orders for gift cards.
Any thoughts are appreciated, thanks!
An order has many line items. That means one or more. You ask for them when you ask for orders. Whether there is one line item in an order, or sixty-seven line items in an order, you ask for all of them. Then you check each one to see if it is a gift card. If it is, you can remove that gift card's value from your totals.
Hey Frank did you ever figure this out, or are you looking at every individual line item ID and referencing it against the list of products?
You don't have to reference anything against a list of products. You just examine the line item. It tells you gift_card: true/false. Nothing complicated about it.
Hey HunkyBill I eventually figured it out because that is buried in the rest api documentation, but i didn't see it documented anywhere in the graphql docs which is probably why Frank was confused as well