GraphQL queries: how to query shop returned items (number of items and sku)

I am looking for the field that holds the data for returned items.

I can’t find anything under orders that suggest a returned item, and under refunds I don’t receive items numbers or skus. Using lineitems under refunds does not return anything.

What is the shopify classification for returned items ?

https://shopify.dev/apps/tools/graphiql-admin-api

Thanks

Hello @Sandra_DaviesGr , I don’t really know much about solving problems but, I have my service provider and he can help you.
He helped me develop my store to its current sales making level at a very low rate.

You can reach out to him and thank me later… https://bit.ly/3vnch7j

Sorry, not sure what to do with that link to WhatApp.

Thanks, but I am simply looking for answer of what should be publicly available information.

You’re welcome, I just wanted to help.
I wish you luck as I wish myself.

Hey @Sandra_DaviesGr - thanks for getting in touch. If you’re looking for returned/refunded items, you are right that it would be searchable through an orders query in GraphQL, you’d want to use a query like this:

{
  order (id:"gid://shopify/Order/[orderid]") {
lineItems (first:3) {
  edges {
    node {
      id
      refundableQuantity
      quantity
    }
  }
}
  }
}

A query like this would show you which line items have been refunded using the “refundablequantity” vs. the “quantity” fields. The “refundablequantity” field would show you how much of the line item is available to be refunded and the “quantity” field shows how much of the lineitem was available when the order was initially made.

Let’s say someone ordered two bars of soap, but returned one. The “quantity” field would show “2” to reflect that there were two bars of that soap lineitem when the order went through originally. Then, the “refundablequantity” field would show “1” reflecting that there is still one bar of soap that’s in the customer’s “hands” which still be returned back to the system.

Hope this helps - let us know if we can clarify anything on our end, happy to help out further if need be.

1 Like

Hi Alan, many thanks for clearing that up. You saved me from getting bold, as I was starting to pull my hair out.

I had found the refundablequantity before and played with it, but at a quick glance always returned quantity 1 and refundablequantity 1, which didn’t make sense to me until now.

" Let’s say someone ordered two bars of soap, but returned one. The “quantity” field would show “2” to reflect that there were two bars of that soap lineitem when the order went through originally. Then, the “refundablequantity” field would show “1” reflecting that there is still one bar of soap that’s in the customer’s “hands” which still be returned back to the system."

@Alan_19

If I could bother you with one more question please.

How can I split my order by lineitems? Or have the split order pricing information linked to each individual lineitem?

What is happening now is that I run my (bulk) query and download the report.

First step (Pyhton Pandas) is to split my data into orders, and lineitems.

My lineitems dataframe will be larger than my orders dataframe based on muliple items per order.

I will have to merge my orders dataframe onto my lineitems dataframe.

As a result I have duplicate orders with individual lineitems.

But since the sales information is linked to the order, each individual lineitem within the same order has the total sales information on its row, and not the individual lineitem sales information.

{
orders(query: “order_date_range”) {
edges {
node {
id
createdAt
currencyCode
totalDiscounts
totalPrice
totalRefunded
totalTax
lineItems(first: 10) {
edges {
node {
id
quantity
refundableQuantity
sku
title
vendor
originalTotal
discountedTotal
discountedUnitPrice
originalUnitPrice
totalDiscount
}
}
}
taxLines {
price
ratePercentage
rate
}
subtotalPrice
subtotalLineItemsQuantity
}
}
}
}

Hi Alan

Appreciate this is 2 years old now but I’m having a related problem whereby I’m not getting the correct refundableQuantity when exchanging an item, but I do if I straight return and refund an item.

My query looks like this:

query {
        orders(first: 10, ${nextLink} query: "updated_at:>'${lastUpdatedISO}' AND return_status:returned") {
          edges {
            node {
              id
              email
              customer {
                firstName
                lastName
              }
              updatedAt
              lineItems(first: 10) {
                edges {
                  node {
                    title
                    vendor
                    quantity
                    refundableQuantity
                    variant {
                      product {
                        id
                      }
                      selectedOptions {
                        name
                        value
                      }
                    }
                  }
                }
              }
            }
            cursor
          }
          pageInfo {
            hasNextPage
            endCursor
          }
        }
      }

I’ve noticed an issue whereby if I do a simple refund, i.e. customer ordered 1 item, and then returned that item, everything works as expected and I get quantity: 1 and refundableQuantity: 0.

[
  {
    id: 'gid://shopify/Order/5669618811048',
    email: 'XXX@XXX.com',
    customer: { firstName: 'XXX', lastName: 'XXX' },
    updatedAt: '2024-06-05T13:45:46Z',
    lineItems: [
      {
        originalStoreId: 'gid://shopify/Product/7549745561768',
        title: 'Alireza Houndstooth Trench Coat',
        vendor: 'Hållbaren',
        quantity: 1,
        refundableQuantity: 0,
        variant: {
          product: { id: 'gid://shopify/Product/7549745561768' },
          selectedOptions: [
            { name: 'Size', value: '6' },
            { name: 'Color', value: 'Black' },
          ],
        },
      },
    ],
  },
];

However, the issue is when I exchange an item, i.e. the customer ordered 1 thing, returns it, and I add a new item to the order in it’s place, I end up with the original item showing quantity: 1 and refundableQuantity: 1 (should be 0), and the new item shows quantity: 1 and refundableQuantity: 1 (as expected). So I’m unable to tell which item was actually refunded here.

[
  {
    "id": "gid://shopify/Order/5658691436712",
    "email": "XXX@XXX.com",
    "customer": { "firstName": "XXX", "lastName": "XXX" },
    "updatedAt": "2024-06-05T13:55:54Z",
    "lineItems": [
      {
        "originalStoreId": "gid://shopify/Product/7549741039784",
        "title": "Aiony Blazer",  // THIS IS THE RETURNED ITEM
        "vendor": "Hållbaren",
        "quantity": 1,
        "refundableQuantity": 1, // STILL SHOWING 1!?
        "variant": {
          "product": { "id": "gid://shopify/Product/7549741039784" },
          "selectedOptions": [
            { "name": "Size", "value": "6" },
            { "name": "Color", "value": "Natural" }
          ]
        }
      },
      {
        "originalStoreId": "gid://shopify/Product/7549741039784",
        "title": "Aiony Blazer", // THIS IS THE EXCHANGE ITEM
        "vendor": "Hållbaren",
        "quantity": 1,
        "refundableQuantity": 1, // OK, AS EXPECTED
        "variant": {
          "product": { "id": "gid://shopify/Product/7549741039784" },
          "selectedOptions": [
            { "name": "Size", "value": "8" },
            { "name": "Color", "value": "Natural" }
          ]
        }
      }
    ]
  }
]

Cheers

Gary