How can I auto-fulfill a specific product with an HTTP request?

How can I auto-fulfill a specific product with an HTTP request?

jake_mitchell
Shopify Partner
120 2 55

Hi, 

We have one product on our store that requires no fulfilment at all. Let's just say its ID is '123456'. We're a charity and this product is a donation that customers can make in the basket/cart. 

What I'm trying to do is get to a solution where whenever an order is made that contains that line_item it is immediately set to 'fulfilled'. 

Ideally I'd do this without paying for a new app so I was wondering if it would be possible with Flow and a send HTTP request action. 

 

I've had a look at the mutations available on the GraphQL API (https://shopify.dev/docs/api/admin-graphql/2023-01/mutations/fulfillmentCreateV2) but couldn't quite see anything that would work. 

 

So I'm putting it out there here. Has anyone done anything similar or would know how to get it working? 

thanks

Replies 4 (4)

paul_n
Shopify Staff
1172 143 276

Yeah it's possible. This is a working query mutation that I use in Send HTTP Request to Mark all fulfillment orders as fulfilled:

{ "query": "mutation fulfillmentCreateV2($fulfillment: FulfillmentV2Input!) {  fulfillmentCreateV2(fulfillment: $fulfillment) { fulfillment { id } userErrors { field message }  } }", "variables": { "fulfillment": {  "lineItemsByFulfillmentOrder": [{% for fo in order.fulfillmentOrders %}{ "fulfillmentOrderId": "{{fo.id}}"}{% unless forloop.last %}, {% endunless %}{% endfor %}]}}}

 Note that you'll need an API key to use this. The action looks like this:

05-01-2eval-hs549

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
jake_mitchell
Shopify Partner
120 2 55

Thanks @paul_n . Always good to see you pop up with a solution. A real Shopify Forums hero. 

I'll give this a go. I may be reading the code wrong but is this going to fulfil only the targeted line item or the entire order. 

Our item that requires no fulfilment can be on an order with other items that do so we wouldn't want to automatically fulfil the whole thing. 

thanks,

Digico
Shopify Partner
47 1 5

Hi Jake, did you found solutions for your charity?

 

François, Digico Paris

tyler_k
Shopify Staff
5 2 1

We now have a  "Mark fulfillment order as fulfilled" action to fulfill an entire fulfillment order,  you would have to  ensure that it is the only product in the fulfillment order. If this product is setup as digital product it will automatically be its own fulfillment order and you could us a template we have. Look up "Fulfill a digital item in an order" in the templates section.

tyler_k_0-1709744291574.png 

tyler_k_1-1709744319494.png