How to Identify the lineItem Associated with Return Tracking Information Using GraphQL Return Query?

Hi,

When using the return query in Shopify, I can retrieve the return tracking number and shipping carrier information from the reverseFulfillmentOrders > reverseDeliveries > deliverable > tracking field.
However, I’m unable to determine which specific lineItem the return is associated with. It seems that using the ReverseFulfillmentOrder ID only provides the associated ReverseFulfillmentOrderLineItem ID.

Is there a way to determine which lineItem the return tracking information is associated with?

Thanks for your help!

Hi Yoonsoo,

To determine which specific lineItem a return tracking information is associated with, you can use the return query to retrieve the returnLineItems associated with a return. Each returnLineItem can be linked to a fulfillmentLineItem , which in turn is associated with a lineItem . Here’s an example of how you can structure your query:

query GetReturnLineItems($returnId: ID!) {
  return(id: $returnId) {
    returnLineItems(first: 10) {
      edges {
        node {
          fulfillmentLineItem {
            lineItem {
              id
              name
            }
          }
          quantity
          returnReason
        }
      }
    }
  }
}

In this query, replace $returnId with the ID of the return you are interested in. This will give you the lineItem details associated with each returnLineItem.

Additionally, you can use the reverseFulfillmentOrder query to get details about reverseFulfillmentOrderLineItems, which are linked to fulfillmentLineItems and thus to lineItems. Here’s an example:

query GetReverseFulfillmentOrderLineItems($reverseFulfillmentOrderId: ID!) {
  reverseFulfillmentOrder(id: $reverseFulfillmentOrderId) {
    lineItems(first: 10) {
      edges {
        node {
          fulfillmentLineItem {
            lineItem {
              id
              name
            }
          }
          totalQuantity
        }
      }
    }
  }
}

Replace $reverseFulfillmentOrderId with the ID of the reverse fulfillment order you are querying.

These queries will help you map the return tracking information to the specific lineItem it is associated with.

1 Like

Hi Liam,

The answer you provided was incredibly helpful.
Thank you.

1 Like