How to determine if an order is for a gift card using GraphQL API

How to determine if an order is for a gift card using GraphQL API

frankmc
Visitor
1 0 0

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!

Replies 4 (4)

HunkyBill
Shopify Partner
4851 60 555

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.

 

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com

codatian
Visitor
2 0 0

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?

HunkyBill
Shopify Partner
4851 60 555

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.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
codatian
Visitor
2 0 0

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