A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Dear Shopify Team,
We want to make sure regarding get order query , last week we encountered some error because when we hit get order query, product and variant was null in lineItems data, we need product or variant id in our stock movement process, is it expected that product and variant can be null when we get order? if its expected, where can we get variant/product id for that specific order if the response value is null?
this is X-Request-Id: bba66df1-81b3-437b-8c74-9b1dc8aef2e3 from response
Thanks in advance!
Hi @nadyahutaj2021,
Thank you for reaching out to the Shopify community.
Please share the request payload, I will check if there is anything that needs to be added to the same query payload.
Also, I am sharing a sample GraphQl query for your reference :
{
order(id: "gid://shopify/Order/{order_id}") {
id
lineItems(first: 25) {
edges {
node {
id
product {
id
}
variant {
id
}
}
}
}
}
}
Thank you,
Thank you for the reply, this was our request payload
query {
order(id:"gid://shopify/Order/{order-id}") {
id
displayFinancialStatus
displayFulfillmentStatus
name
discountCode
canMarkAsPaid
canNotifyCustomer
cancelReason
cancelledAt
capturable
closed
confirmed
currencyCode
currentTaxLines {
channelLiable
priceSet {
shopMoney {
amount
}
}
rate
ratePercentage
title
}
currentSubtotalLineItemsQuantity
currentTotalWeight
customerAcceptsMarketing
edited
estimatedTaxes
fulfillable
fullyPaid
hasTimelineComment
merchantEditable
note
physicalLocation {
id
name
address {
address1
address2
country
zip
}
}
presentmentCurrencyCode
refundDiscrepancySet {
shopMoney {
amount
}
}
refundable
requiresShipping
restockable
riskLevel
risks {
display
}
sourceIdentifier
subtotalLineItemsQuantity
subtotalPriceSet {
shopMoney {
amount
}
}
tags
taxesIncluded
test
totalWeight
unpaid
paymentGatewayNames
processedAt
createdAt
updatedAt
closedAt
currentSubtotalPriceSet {
shopMoney {
amount
}
}
currentTotalDutiesSet {
shopMoney {
amount
}
}
currentTotalPriceSet {
shopMoney {
amount
}
}
currentTotalTaxSet {
shopMoney {
amount
}
}
netPaymentSet {
shopMoney {
amount
}
}
originalTotalDutiesSet {
shopMoney {
amount
}
}
originalTotalPriceSet {
shopMoney {
amount
}
}
totalCapturableSet {
shopMoney {
amount
}
}
totalDiscountsSet {
shopMoney {
amount
}
}
totalOutstandingSet {
shopMoney {
amount
}
}
totalPriceSet {
shopMoney {
amount
}
}
totalReceivedSet {
shopMoney {
amount
}
}
totalRefundedSet {
shopMoney {
amount
}
}
totalRefundedShippingSet {
shopMoney {
amount
}
}
totalShippingPriceSet {
shopMoney {
amount
}
}
totalTaxSet {
shopMoney {
amount
}
}
totalTipReceivedSet {
shopMoney {
amount
}
}
billingAddress {
address1
address2
formatted
name
phone
zip
}
customer {
image {
url
}
id
phone
email
note
displayName
addresses {
address1
address2
formattedArea
}
}
billingAddressMatchesShippingAddress
lineItems(first: 50) {
nodes {
id
name
variantTitle
quantity
merchantEditable
unfulfilledQuantity
nonFulfillableQuantity
refundableQuantity
sku
restockable
requiresShipping
taxable
image {
url
}
totalDiscountSet {
shopMoney {
amount
}
}
originalTotalSet {
shopMoney {
amount
}
}
originalUnitPriceSet {
shopMoney {
amount
}
}
unfulfilledDiscountedTotalSet {
shopMoney {
amount
}
}
totalDiscountSet {
shopMoney {
amount
}
}
product {
id
title
status
productType
}
variant {
id
weight
weightUnit
}
}
}
fulfillments {
id
totalQuantity
name
status
displayStatus
originAddress {
address1
address2
countryCode
zip
}
trackingInfo {
company
url
number
}
inTransitAt
estimatedDeliveryAt
deliveredAt
createdAt
updatedAt
fulfillmentLineItems(first: 30) {
nodes {
id
quantity
lineItem {
sku
name
image {
url
}
variant {
id
}
}
}
}
}
fulfillmentOrders(first: 10) {
nodes {
id
assignedLocation {
location {
id
name
}
}
deliveryMethod {
methodType
maxDeliveryDateTime
minDeliveryDateTime
}
fulfillAt
fulfillBy
requestStatus
status
}
}
refunds {
id
note
totalRefundedSet {
shopMoney {
amount
currencyCode
}
}
createdAt
updatedAt
refundLineItems(first: 30) {
nodes {
lineItem {
id
sku
name
product {
id
}
variant {
id
}
image {
url
}
}
restocked
restockType
quantity
priceSet {
shopMoney {
amount
}
}
subtotalSet {
shopMoney {
amount
}
}
totalTaxSet {
shopMoney {
amount
}
}
}
}
}
transactions {
id
gateway
}
shippingAddress {
id
address1
address2
country
province
city
name
phone
zip
formatted
}
}
Hi @nadyahutaj2021,
This is a correct query, I have checked with one of my orders and it works as expected.
Please confirm if you have created the order via Shopify API or from the Shopify checkout.
query {
order(id: "gid://shopify/Order/{your_order_id}") {
id
displayFinancialStatus
displayFulfillmentStatus
name
discountCode
canMarkAsPaid
canNotifyCustomer
cancelReason
cancelledAt
capturable
closed
confirmed
currencyCode
currentTaxLines {
channelLiable
priceSet {
shopMoney {
amount
}
}
rate
ratePercentage
title
}
currentSubtotalLineItemsQuantity
currentTotalWeight
customerAcceptsMarketing
edited
estimatedTaxes
fulfillable
fullyPaid
hasTimelineComment
merchantEditable
note
physicalLocation {
id
name
address {
address1
address2
country
zip
}
}
presentmentCurrencyCode
refundDiscrepancySet {
shopMoney {
amount
}
}
refundable
requiresShipping
restockable
riskLevel
risks {
display
}
sourceIdentifier
subtotalLineItemsQuantity
subtotalPriceSet {
shopMoney {
amount
}
}
tags
taxesIncluded
test
totalWeight
unpaid
paymentGatewayNames
processedAt
createdAt
updatedAt
closedAt
currentSubtotalPriceSet {
shopMoney {
amount
}
}
currentTotalDutiesSet {
shopMoney {
amount
}
}
currentTotalPriceSet {
shopMoney {
amount
}
}
currentTotalTaxSet {
shopMoney {
amount
}
}
netPaymentSet {
shopMoney {
amount
}
}
originalTotalDutiesSet {
shopMoney {
amount
}
}
originalTotalPriceSet {
shopMoney {
amount
}
}
totalCapturableSet {
shopMoney {
amount
}
}
totalDiscountsSet {
shopMoney {
amount
}
}
totalOutstandingSet {
shopMoney {
amount
}
}
totalPriceSet {
shopMoney {
amount
}
}
totalReceivedSet {
shopMoney {
amount
}
}
totalRefundedSet {
shopMoney {
amount
}
}
totalRefundedShippingSet {
shopMoney {
amount
}
}
totalShippingPriceSet {
shopMoney {
amount
}
}
totalTaxSet {
shopMoney {
amount
}
}
totalTipReceivedSet {
shopMoney {
amount
}
}
billingAddress {
address1
address2
formatted
name
phone
zip
}
customer {
image {
url
}
id
phone
email
note
displayName
addresses {
address1
address2
formattedArea
}
}
billingAddressMatchesShippingAddress
lineItems(first: 50) {
nodes {
id
name
variantTitle
quantity
merchantEditable
unfulfilledQuantity
nonFulfillableQuantity
refundableQuantity
sku
restockable
requiresShipping
taxable
image {
url
}
totalDiscountSet {
shopMoney {
amount
}
}
originalTotalSet {
shopMoney {
amount
}
}
originalUnitPriceSet {
shopMoney {
amount
}
}
unfulfilledDiscountedTotalSet {
shopMoney {
amount
}
}
totalDiscountSet {
shopMoney {
amount
}
}
product {
id
title
status
productType
}
variant {
id
weight
weightUnit
}
}
}
fulfillments {
id
totalQuantity
name
status
displayStatus
originAddress {
address1
address2
countryCode
zip
}
trackingInfo {
company
url
number
}
inTransitAt
estimatedDeliveryAt
deliveredAt
createdAt
updatedAt
fulfillmentLineItems(first: 30) {
nodes {
id
quantity
lineItem {
sku
name
image {
url
}
variant {
id
}
}
}
}
}
fulfillmentOrders(first: 10) {
nodes {
id
assignedLocation {
location {
id
name
}
}
deliveryMethod {
methodType
maxDeliveryDateTime
minDeliveryDateTime
}
fulfillAt
fulfillBy
requestStatus
status
}
}
refunds {
id
note
totalRefundedSet {
shopMoney {
amount
currencyCode
}
}
createdAt
updatedAt
refundLineItems(first: 30) {
nodes {
lineItem {
id
sku
name
product {
id
}
variant {
id
}
image {
url
}
}
restocked
restockType
quantity
priceSet {
shopMoney {
amount
}
}
subtotalSet {
shopMoney {
amount
}
}
totalTaxSet {
shopMoney {
amount
}
}
}
}
}
transactions {
id
gateway
}
shippingAddress {
id
address1
address2
country
province
city
name
phone
zip
formatted
}
}
}
Thanks,
Not OP, but we are facing the same issue. we are using admin API to fetch orders on a plus store, and the variant and product and image are being returned as null for a particular order line item.
Check to see if you have the right scope / permission set.
You need the "READ_PRODUCTS" scope selected to get product / variant data inside a line item query.