Hi there,
I’m building a returns app. Before a return is created, I can use returnCalculate just fine.
query
query CalculateReturn($input: CalculateReturnInput!) {
returnCalculate(input: $input) {
id
returnLineItems {
id
fulfillmentLineItem {
id
}
subtotalSet {
shopMoney {
amount
currencyCode
}
}
totalTaxSet {
shopMoney {
amount
currencyCode
}
}
}
exchangeLineItems {
id
variant {
id
}
subtotalSet {
shopMoney {
amount
currencyCode
}
}
totalTaxSet {
shopMoney {
amount
currencyCode
}
}
}
}
}
variables
{
"input": {
"orderId": "gid://shopify/Order/6128868491439",
"returnLineItems": [
{
"fulfillmentLineItemId": "gid://shopify/FulfillmentLineItem/12326289277103",
"quantity": 1
}
],
"exchangeLineItems": [],
"returnShippingFee": {
"amount": {
"amount": "3.99",
"currencyCode": "USD"
}
}
}
}
response
{
"data": {
"returnCalculate": {
"id": "gid://shopify/CalculatedReturn/2aa9167f-7793-4523-9316-6fc96d893d74",
"returnLineItems": [
{
"id": "gid://shopify/CalculatedReturnLineItem/d253b476-4789-4eec-87f7-3e950f89586f",
"fulfillmentLineItem": {
"id": "gid://shopify/FulfillmentLineItem/12326289277103"
},
"subtotalSet": {
"shopMoney": {
"amount": "-29.0",
"currencyCode": "USD"
}
},
"totalTaxSet": {
"shopMoney": {
"amount": "0.0",
"currencyCode": "USD"
}
}
}
],
"exchangeLineItems": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 5,
"actualQueryCost": 4,
"throttleStatus": {
"maximumAvailable": 2000,
"currentlyAvailable": 1996,
"restoreRate": 100
}
}
}
}
but as soon as the return is actually created, if I run that same exact query with the same exact variables, I get this response
{
"errors": [
{
"message": "Internal error. Looks like something went wrong on our end.\nRequest ID: e1fca960-ab37-4d12-8757-ab3b2ff4da33-1726677526 (include this in support requests).",
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"requestId": "e1fca960-ab37-4d12-8757-ab3b2ff4da33-1726677526"
}
}
]
}
So I use returnCalculate to present to the user how much of a refund they’ll get. They accept and the return is created. I feel like I should be able to use that same exact functionality to recalculate the refund and apply it after the reverse fulfillment is taken care of.
I suspect this should be possible because I can see a suggested refund amount in the Shopify admin (native orders panel) that has the same amount calculated from my returnCalculate
At the very least a better error message would be nice ![]()
I couldn’t figure out another mechanism to calculate without doing everything manually, which is a bit cumbersome with potentially proportionally applied discounts, etc, which is why returnCalculate is so handy. I could also potentially save the original result as a metafield or something but it’s possible that the refund could exchange while the reverse fulfillment is in transit (maybe the customer complains about a return shipping fee and we waive it).
After a return is created, I can still do returnCalculate on unreturned items in the order. I also tried using the ReverseFulfillmentOrderLineItem ID and got an “invalid id” error.
Any help is much appreciated. Thanks!
