Storefront API: Cart Retrieve Endpoint Not Returning Line Items

Hi everyone,

I’m using the Shopify Storefront API to retrieve a cart by its ID, but the response doesn’t include the line items. Here’s the query I’m using:


query {
  cart(
    id: "gid://shopify/Cart/Z2NwLXVzLWV4YW1wbGU6MDEyMzQ1Njc4OTAxMjM0NTY3ODkw?key=examplekey1234567890"
  ) {
    id
    createdAt
    updatedAt
    lines(first: 10) {
      edges {
        node {
          id
          quantity
          merchandise {
            ... on ProductVariant {
              id
            }
          }
          attributes {
            key
            value
          }
        }
      }
    }
    attributes {
      key
      value
    }
    cost {
      totalAmount {
        amount
        currencyCode
      }
      subtotalAmount {
        amount
        currencyCode
      }
      totalTaxAmount {
        amount
        currencyCode
      }
      totalDutyAmount {
        amount
        currencyCode
      }
    }
    buyerIdentity {
      email
      phone
      customer {
        id
      }
      countryCode
      deliveryAddressPreferences {
        ... on MailingAddress {
          address1
          address2
          city
          provinceCode
          countryCodeV2
          zip
        }
      }
      preferences {
        delivery {
          deliveryMethod
        }
      }
    }
  }
}

Response. :


{
"lines": {
    "pageInfo": {
            "endCursor": null,
            "hasNextPage": false
               },
         "edges": []
}
}

Even though I’ve added items to the cart, the lines array is empty or missing. I’ve verified that the cart ID is correct and that the items were added successfully.

Has anyone else faced this issue? Could this be a permission or scope problem, or am I missing something in the query?

1 Like

Hey @Jayanthi_Naik, my first thought would be the access scopes. Which scopes does your app have?

Also, is this happening on all carts, or just this cart?

Hey Jayanthi, are you still experiencing this issue, or can I mark this as solved?

Hi @KyleG-Shopify we met similar issue today. We reload all products and after that we always receive lines as empty array. What scope should be applied.? It worked great before we load products again. Any help is really appreciated. Our customer is Bridge Props who uses plus account. So we need to solve it ASAP.

Thanks for letting me know. Just to confirm, you are able to see the line items on one cart but not another? If so that wouldn’t be access scopes.

If the issue is urgent for your client, I would definitely recommend getting in touch with our Plus support team so they can look in to specifics for that client to unblock them.

I’m happy to keep troubleshooting here though as it will help the community running in to similar scenarios. Can you share details on how you are accessing the storefront API. Is it through a custom storefront token, or a token generated through an app? If you can also share the scopes you have granted and examples of your mutations and queries, that can help me replicate.

Thanks!

@KyleG-Shopify There interesting thing. We created another storefront API token and after an hour we start to receive results in lines however previous token still brings us empty array. We are ok to proceed with second tocken as of now but looks really strange.
In any case thanks for your quick response!!!

1 Like