Help with 'Transfer to Pickup location'

I’m currently stuck trying to set up a new Flow and haven’t been able to find an answer anywhere. I’ve included some context below.

To support local pickup—even at locations that don’t regularly stock the product—I enabled “transfers” at all locations.

  • Everything is working as expected—when a customer selects a pickup location at checkout that doesn’t have the item in stock, Shopify displays a “Transfer to pickup location” button in the Order Admin UI.
  • Now I’m trying to handle that transfer step programmatically through Flow.
  • Here’s what my Flow does:
  1. Checks if any fulfillment orders have deliveryMethodType set to pick_up.
  2. Get location data by looking up the location where the name matches the order’s shipping line title (used later in the flow).
  3. Loops through each fulfillment order.
    Check if the fulfillment orders assigned location name is not equal to the orders shipping line title. If the assigned location name doesn’t match the orders shipping line title, I know the fulfillment order needs to move.
  4. Send Admin API request step with ‘inventoryActivate’ mutation
    Before moving the fulfillment order, I need to activate inventory at the destination location, since the transfer fails if the item isn’t already stocked.
  5. Send admin API Request with ‘inventoryAdjustQuantities’ mutation
    Now that the inventory items are stocked at the destination location, I can set the inventory quantities.
  6. Fulfillment Order Move
    Since I handle the process of stocking the items at the destination location, then the fulfillment order move action works as expected.

This is the inventoryActivate mutation:

[
{% for lineItems_item in fulfillmentOrdersForeachitem.lineItems %}
{
“inventoryItemId”: {{ lineItems_item.inventoryItemId | json }},
“inventoryItemUpdates”: [
{
“locationId”: {% for getLocationData_item in getLocationData %}{{ getLocationData_item.id | json }}{% endfor %},
“activate”: true
}
]
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]

This is the inventoryAdjustQuantities mutation:

{
“input”: {
“reason”: “movement_created”,
“name”: “available”,
“changes”: [
{% for lineItem in fulfillmentOrdersForeachitem.lineItems %}
{
“delta”: -{% for lineItems_item in fulfillmentOrdersForeachitem.lineItems %}{{ lineItems_item.totalQuantity }}{% endfor %},
“inventoryItemId”: “{{ lineItem.inventoryItemId | strip_newlines | strip }}”,
“locationId”: “{{ fulfillmentOrdersForeachitem.assignedLocation.location.id | strip_newlines | strip }}”
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
}
}

When I run the Flow, I’m getting this:

Exception: [ { “inventoryItemId”: “gid://shopify/InventoryItem/44079696740418”, “inventoryItemUpdates”: [{ “locationId”: “gid://shopify/Location/68473028674”, “activate”: true }] }, { “inventoryItemId”: “gid://shopify/InventoryItem/44079662235714”, “inventoryItemUpdates”: [{ “locationId”: “gid://shopify/Location/68473028674”, “activate”: true }] } ]

Mutation had errors: “Variable $inventoryItemId of type ID! was provided invalid value”, “Variable $locationId of type ID! was provided invalid value”

At this point, I’m not sure if the issue is the way I’m formatting the mutation, or if inventoryActivate and inventoryAdjustQuantities doesn’t support activating multiple inventory items in a single call.

Any ideas or suggestions would be hugely appreciated. Help with ‘Transfer to Pickup location’

1 Like

Here, you are looping over locations and outputting them all, but the mutation takes just one.

"locationId": {% for getLocationData_item in getLocationData %}{{ getLocationData_item.id | json }}{% endfor %},

So I’d expect this to output something like:

gid;//shopify/Location/123gid:://shopify/Location/59594

Generally, I’d recommend that you test liquid like this in Log Output so that you can see the exact JSON produced by your code.

@paul_n
Thanks for your reply.

Although you make a fair point about the code, I can guarantee the get location data query is only returning one location. And you can see that from the data it populated here:

Exception: [ { “inventoryItemId”: “gid://shopify/InventoryItem/44079696740418”, “inventoryItemUpdates”: [{ “locationId”: “gid://shopify/Location/68473028674”, “activate”: true }] }, { “inventoryItemId”: “gid://shopify/InventoryItem/44079662235714”, “inventoryItemUpdates”: [{ “locationId”: “gid://shopify/Location/68473028674”, “activate”: true }] } ]

Mutation had errors: “Variable $inventoryItemId of type ID! was provided invalid value”, “Variable $locationId of type ID! was provided invalid value”

The issue stands, inventoryActivate and inventoryAdjustQuantities doesn’t support activating multiple inventory items in a single call.

If I simply change to the send http request action, and run this query:
{
“query”: “mutation ActivateInventoryItem {\n item1: inventoryActivate(\n inventoryItemId: "gid://shopify/InventoryItem/44079662235714",\n locationId: "gid://shopify/Location/68473028674",\n available: 1\n ) {\n inventoryLevel {\n id\n quantities(names: ["available"]) {\n name\n quantity\n }\n }\n }\n item2: inventoryActivate(\n inventoryItemId: "gid://shopify/InventoryItem/44079696740418",\n locationId: "gid://shopify/Location/68473028674",\n available: 1\n ) {\n inventoryLevel {\n id\n quantities(names: ["available"]) {\n name\n quantity\n }\n }\n }\n}”
}

It works just fine.

Whereas, if I inputted this into the Send Admin API Request (inventoryActivate mutation):
[
{
“inventoryItemId”: “gid://shopify/InventoryItem/44079662235714”,
“locationId”: “gid://shopify/Location/68473028674”,
“available”: 1,
“inventoryLevel”: {
“id”: null,
“quantities”: {
“names”: [“available”],
“name”: null,
“quantity”: null
}
}
},
{
“inventoryItemId”: “gid://shopify/InventoryItem/44079696740418”,
“locationId”: “gid://shopify/Location/68473028674”,
“available”: 1,
“inventoryLevel”: {
“id”: null,
“quantities”: {
“names”: [“available”],
“name”: null,
“quantity”: null
}
}
}
]

Then it errors.

Is this a known-limitation using the send admin api request in Shopify Flow?

1 Like

It’s hard to read you code here…use the “…” menu and then the </> icon.

You cannot update multiple inventories at the same time using either option. Here’s a doc page https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/inventoryActivate

Not sure where you though you could just send it a list in the mutation. Instead you would need to call the action for each inventoryItem you want to update (or do 2 mutations via Send HTTP request/etc).