Hello,
The query below provides me with prices for lineItems which I later need to add to issue a refund using the returnRefund mutation.
The problem is that it is not possible to know which returnLineItem is associated with which fulfillmentLineItem. If they are always in the same correct order I could look at the same node. But I am not sure that this is possible.
I tried a) to structure that query differently and b) tried many different queries to seperately lookup the fulfillmentLineItem for the corresponding returnLineItem but could not find a useful solution yet.
Please advice.
$post_data = [
'query' => '
query getReturn($id: ID!) {
return(id: $id) {
id
status
order {
id
lineItems(first: 10) {
edges {
node {
id
title
quantity
originalUnitPriceSet {
shopMoney {
amount
currencyCode
}
}
originalTotalSet {
shopMoney {
amount
currencyCode
}
}
}
}
}
}
returnLineItems(first: 10) {
edges {
node {
id
quantity
returnReason
returnReasonNote
}
}
}
}
}',
'variables' => [
'id' => $returnId
]
];
The resulting array helps you better see what I mean.
The bold ids cannot be matched to find the price for the returned product.
Other Queries that reveal this gap would be much appreciated.
Array
(
[data] => Array
(
[return] => Array
(
[id] => gid://shopify/Return/12673145676
[status] => OPEN
[order] => Array
(
[id] => gid://shopify/Order/6452884633804
[lineItems] => Array
(
[edges] => Array
(
[0] => Array
(
[node] => Array
(
[id] => **gid://shopify/LineItem/16284931096908**
[title] => ProductTitle1
[quantity] => 1
[originalUnitPriceSet] => Array
(
[shopMoney] => Array
(
[amount] => 169.99
[currencyCode] => EUR
)
)
[originalTotalSet] => Array
(
[shopMoney] => Array
(
[amount] => 169.99
[currencyCode] => EUR
)
)
[variant] => Array
(
[id] => **gid://shopify/ProductVariant/48991501582668**
[sku] => F3333_5AF333333_631_10_40
)
)
)
[1] => Array
(
[node] => Array
(
[id] => gid://shopify/LineItem/16284931129676
[title] => ProductTitle2
[quantity] => 1
[originalUnitPriceSet] => Array
(
[shopMoney] => Array
(
[amount] => 269.99
[currencyCode] => EUR
)
)
[originalTotalSet] => Array
(
[shopMoney] => Array
(
[amount] => 169.99
[currencyCode] => EUR
)
)
[variant] => Array
(
[id] => **gid://shopify/ProductVariant/48991501549900**
[sku] => F2222_5AF22222_631_10_40
)
)
)
)
)
)
[returnLineItems] => Array
(
[edges] => Array
(
[0] => Array
(
[node] => Array
(
[id] => gid://shopify/ReturnLineItem/21699559756
[quantity] => 1
[returnReason] => OTHER
[returnReasonNote] => F2222_5AF22222_631_10_40
)
)
)
)
)
)
Ok it can be done via:
$post_data = [
'query' => '
query getReturnLineItems($returnId: ID!) {
return(id: $returnId) {
returnLineItems(first: 25) {
nodes {
... on ReturnLineItem {
id
refundableQuantity
refundedQuantity
returnReason
returnReasonNote
customerNote
quantity
fulfillmentLineItem {
lineItem {
id
name
sku
}
}
}
}
}
}
}',
'variables' => [
'returnId' => 'gid://shopify/Return/12633145676',
],
];
2 Likes
Also consider the Relationship between fulfillmentLineItem and refundLineItem which is equally hard to come by via documentation.
1 Like
Another important point here is that the variant id is null when that variant changed since the order. So you might want to match in a different way.