How can I use Flow to automatically fulfil one product?

Solved

How can I use Flow to automatically fulfil one product?

no_robotocha
Shopify Partner
55 2 12

My shop has the option to personalise items, using "Personalisation" as a separate product. I'd like to automatically set this to Fulfilled when the order is placed. I'm trying to use the Flow app to achieve this, but I can't seem to find a way to set the specific product to fulfilled. 

 

So far I have the following set up:

Screenshot 2023-09-04 at 11.26.17.png

 

Can anyone suggest how to complete this workflow?

 

Thanks,

--
No, Robotocha!
Accepted Solution (1)

paul_n
Shopify Staff
1336 151 307

This is an accepted solution.

There isn't a "Mark as fulfilled" option yet, but you can accomplish that by using the Send HTTP Request to call the API. I would recommend using the REST API as it's easier to work with in Flow. https://shopify.dev/docs/api/admin-rest/2023-07/resources/fulfillment#post-fulfillments

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.

View solution in original post

Replies 18 (18)

paul_n
Shopify Staff
1336 151 307

This is an accepted solution.

There isn't a "Mark as fulfilled" option yet, but you can accomplish that by using the Send HTTP Request to call the API. I would recommend using the REST API as it's easier to work with in Flow. https://shopify.dev/docs/api/admin-rest/2023-07/resources/fulfillment#post-fulfillments

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.
no_robotocha
Shopify Partner
55 2 12

Thanks Paul, that's helpful.

 

I haven't yet used the Shopify REST API - in flows or otherwise - does my set up look correct?


Screenshot 2023-09-05 at 14.59.31.pngScreenshot 2023-09-05 at 14.59.43.png
And to get access tokens, would I set up an app as per these instructions?: https://help.shopify.com/en/manual/shopify-flow/reference/actions/send-http-request#call-the-shopify...

 

Thanks

--
No, Robotocha!
paul_n
Shopify Staff
1336 151 307

Yeah, looks pretty good. I would remove white space by using hyphens in your tags, just in case, like:

{{- variable -}}
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.
vicnovo
Shopify Partner
3 0 0

Hey Paul,

I have similar task, but a little bit confuse about the settings, could you help me, please to figure out what is the right settings should it be here?

vicnovo_0-1694795215263.png

What is the URL should be?

I guess instead of {access_token} should be something? Where I can get it?

 

Also, for the making a fulfillment of a single product with a specific name if it exists in an order. Is it the correct code?

vicnovo_1-1694795495691.png

and flow settings:

vicnovo_2-1694795618507.png

 

paul_n
Shopify Staff
1336 151 307

You should try this request first through an API tool like Postman. It will make troubleshooting much faster. In order to get an API key, you need to create a custom app with the right scopes and get the key: https://help.shopify.com/en/manual/apps/app-types/custom-apps#enable-custom-app-development

 

For the URL consult the docs I posted earlier. 

 

For the code, please post it as text and not an image. 

 

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.
vicnovo
Shopify Partner
3 0 0

Hey man, did it work for you?

Have the same task, but a bit lost in the nuances (

no_robotocha
Shopify Partner
55 2 12

Hi Vicnovo, we've not tried it quite yet - adding some conditions, but will post back here when we do (likely next week).

--
No, Robotocha!
Fertel1
Shopify Partner
3 0 0

Hi @no_robotocha  just wondering how you went with this? 

 

We tried to recreate the flow but it is giving us a 400 response error, we have tried troubleshooting with no success. Screenshot_113023_114714_AM.jpg2848-31062-13804-45783-17955.png

no_robotocha
Shopify Partner
55 2 12

Hi @Fertel1 - I actually ended up using the Mechanic app to get this task done - it's proved to be more versatile for us and has solved a few challenges.

 

Looking at your request, it seems the body received is not formatted correctly and has a lot of \s etc. - so I'd look to correct that initially.

--
No, Robotocha!
Fertel1
Shopify Partner
3 0 0

Hi @no_robotocha, thank you for your reply and for your advise. 

Will check it out. 

paul_n
Shopify Staff
1336 151 307

A 400 error is a badly formed request. As a first step, like the other comments you should remove white space around your actual request (notice how it starts with \n\n\n\n\n). Do that by including hyphens in your tags like:

{%- endfor -%}

 

Also, both of your id's are missing the quotes around them. Try something like

"{{ personalizationId }}"
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.
Jonas10
Shopify Partner
10 0 5

I was getting similar errors and this is how I fixed it:

http.png

 

Notice the headers and the filter on the fOrder ID.

Fertel1
Shopify Partner
3 0 0

Hi Jonas10, thank you for getting back to me. I'll give it a go. 

tyler_k
Shopify Staff
5 2 1

You can now do this using "Mark fulfillment order as fulfilled" action. This action only allows you to fulfill the entire fulfillment order, it is not able to partially fulfill by selecting line specific line items. You will have to ensure the that "Personalisation" product is the only item in the fulfillment order

no_robotocha
Shopify Partner
55 2 12

Thanks @tyler_k - as my post explains, this is an addition to other products which do require fulfilment, so this would not be a solution to this problem as it would never be the only item in the fulfilment order so we'll stick with the Mechanic app solution for now.

--
No, Robotocha!

timd
Shopify Partner
124 6 79

I've achieved this with an HTTPRequest using GraphQL.

Just note that the IDs for both the order and line item need to be gIDs rather than liquid IDs, so {{ order.id }} wont work in flow for either RestAPI or GraphQL requests.

{
	"query": "mutation fulfillmentCreateV2($fulfillment: FulfillmentV2Input!) {
		fulfillmentCreateV2(fulfillment: $fulfillment) {
			fulfillment {
				id
				status
			}
			userErrors {
				field
				message
			}
		}
	}",
	"variables": {
		{
			"fulfillment": {
				"lineItemsByFulfillmentOrder": {
					"fulfillmentOrderId": "{{ ID OF ORDER FULFILLMENT}}",
					"fulfillmentOrderLineItems": {
						"id": "{{ LINE ITEM FULFILLMENT ID OF ITEM TO BE FULFILLED }}",
						"quantity": 1
					}
				}
			}
		},
		"message": "Autofulfilled by Flow"
	}
}

 

zaidkhan
Shopify Partner
14 0 1

@TimD1 Can you please post the flow template along with the Http endpoint?

paul_n
Shopify Staff
1336 151 307

I'll note that you can now use Send Admin API request to simplify this, where you only need the variables part.

 

 

 

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.