I’m looking at restocking items for an open return, and I’m not sure about the process here.
I’m looking at docs for Build for return management and according to Creating returns guide , after receiving a return order, you are supposed to restock it.
I’m looking for this part, but I don’t see any mutation to restock an item from a return after a return has been created. In my case, the returns would be created from Shopify’s backend. If I was creating the return myself, I could use returnLineItems field on returnCreate - GraphQL Admin to specify the restock items.
The main challenge I’m facing is that while Shopify’s API has clear mutations for closing returns, I haven’t been able to find a direct way to programmatically restock items. I need to figure out the best way to handle this restocking step before closing the return.
Is there something i’m missing here?
What I think the issue is, is the lack of an upsert mutation on an open return.
Also, for context I’m trying to do this within flow - restock and close an open return after 7 days it was created. Plan is to send admin API request from Flow, if I can just figure out the right mutation.
Looking for the API equivalent of the “Restock” button on the bottom. This is for Returns with status ‘OPEN’.
Hi Taksh
Is returnApproveRequest
mutation what you’re looking for? This mutation approves a customer’s return request and sets the Return.status
field to OPEN
. Once the return is approved, the items can be restocked. eg:
mutation ApproveReturn {
returnApproveRequest(input: {
id: "gid://shopify/Return/945000958", # Replace with the return ID
notifyCustomer: true # Optional: Notify the customer about the approval
}) {
return {
id
status
}
userErrors {
code
field
message
}
}
}
No, when a return is created from Shopify admin, the status is set to OPEN
already.
However I was able to figure out the right endpoint for this. Had to reverse-engineer the admin a bit.
It was reverseFulfillmentOrderDispose
reverseFulfillmentOrderDispose - GraphQL Admin.
The terminally was slightly confusing here, as ‘Dispose’ would mean discarding the inventory, or not restocking it. However reverseFulfillmentOrderDispose
mutation does seem to be the one for restocking items.
@Liam-Shopify I’m marking the solution, but would appreciate it you could look at the terminology, or add some detailing in the step 10 of the app building guide. Build for return management.
Some clarity would be helpful.
Hi Taksh,
Glad to hear reverseFulfillmentOrderDispose
works for you! Will connect with the team that owns this to make the documentation clearer and to include this step.
Hi!, @Taksh_Shah and @Liam-Shopify,
I am in a similar case from an ERP, I manage to set the order in “Return in progress”, but I would need to do the same to simulate the restock button of shopi, I think you talk about something similar and you have been able to do it, could you show me an example of how you create the GraphQl for this?
Thanks in advance.
Greetings.
Hey @ERP_Integracion
Here’s a sample of my code,
const inputQuery = `{
reverseFulfillmentOrderLineItemId: "${restockableItems[0].id}",
quantity: ${restockableItems[0].totalQuantity},
dispositionType: RESTOCKED,
locationId: "${input.return.order.fulfillments[0].location.id}"
}`;
const mutation = `mutation {
reverseFulfillmentOrderDispose(
dispositionInputs: [
${inputQuery}
]
) {
reverseFulfillmentOrderLineItems {
id
dispositions {
quantity
dispositionType
}
}
userErrors {
field
message
}
}
}`;
This wouldn’t work as-is in flow, but should give you a starting point. If you are trying to do it specifically within flow, you’ll need to create input data in a run code step, and then use that in the “Send admin API request” action.
1 Like
@Taksh_Shah
Thanks for your answer!,
The problem now, I am encountering is that I can’t figure out how to find the reverseFulfillmentOrderLineItemId.
Do you know how I could do it?
You can refer to reverseFulfillmentOrders
on the return
object.
return > reverseFulfillmentOrders > items > id
reverseFulfillmentOrder - GraphQL Admin!
@Taksh_Shah
Yes, I have been checking it but I can’t figure it out, the return has returned this:
{
“data”: {
“returnCreate”: {
“return”: {
“id”: “gid://shopify/Return/12693537111”
},
“userErrors”:
}
},
“extensions”: {
“cost”: {
“requestedQueryCost”: 10,
“actualQueryCost”: 10,
“throttleStatus”: {
“maximumAvailable”: 20000.0,
“currentlyAvailable”: 19990,
“restoreRate”: 1000.0
}
}
}
}
The example it shows is this:
{
reverseFulfillmentOrder(id) {
# ReverseFulfillmentOrder fields
}
}
But the id indicates that it is: The ID of the reverse fulfillment order to return.
I don’t know how I can make the query, so that it returns the reverseFulfillmentOrderLineItemId.
You need to edit your returnCreate
query to return more fields.
Here’s what mine looks like for your reference
query {
shop {
name
}
return {
order {
fulfillments {
location {
id
}
}
}
reverseFulfillmentOrders {
lineItems {
id
totalQuantity
dispositions {
location {
id
}
id
quantity
type
}
}
}
returnLineItems {
refundedQuantity
id
fulfillmentLineItem {
id
lineItem {
id
variant {
id
}
}
}
returnReason
quantity
}
}
}
that query is in postman?
I create the return like this:
strong text
Modify this portion of your query,
to be like
return {
id
order {
fulfillments {
location {
id
}
}
}
reverseFulfillmentOrders {
lineItems {
id
totalQuantity
dispositions {
location {
id
}
id
quantity
type
}
}
}
returnLineItems {
refundedQuantity
id
fulfillmentLineItem {
id
lineItem {
id
variant {
id
}
}
}
returnReason
quantity
}
}
this should give you all the data you need to work with.