For each

TheFor eachaction performs an action on every item in a list, when that action is connected to theDo this for each itemoption. This action functions on lists, such as line items in an order or in workflows that retrieve data by using one of the following actions:

After you add theFor eachaction, select either or both of the following options:

  • ClickThento add a single action or a condition. This action is taken after all the actions performed byDo this for each itemare complete.
  • ClickDo this for each itemto add an action to perform on every entry in the list returned by aGetaction.

For example, you create a workflow that runs once a week. The workflow uses theGet order dataaction to retrieve orders placed during that week and applies a tag to each one. After all the tags are applied, an email is sent indicating that tagging is complete.

Example of a workflow that retrieves a list of orders placed in the past week and adds a tag to each order, then sends an email.

Considerations for using the For each action

Review the following considerations before you use theFor each行动:

Only one condition or action can immediately followDo this for each item. You can add multiple additional conditions after this, but each option can only lead to a single condition or action.

For example, you create a workflow that uses theFor eachaction. You clickDo this for each itemand add a condition. In this condition, and in every condition following it, only one action or condition can be added to either theThenorOtherwiseoptions.

Example of a workflow that uses multiple conditions after Do this for each action.

字段

TheFor eachaction contains the following fields.

字段used in the For each action.
Field Description
List Required. The list of items to perform an action on. This can be a list returned by aGetaction or a list returned by a trigger, such as a list of line items returned by theOrder createdtrigger.

Triggers

TheFor eachaction can be used in any workflow.

Monitoring workflows

After a workflow has run, you canreview its performanceon the Shopify Flow活动page. The following is true for workflows that contain aFor each行动:

  • TheStatusandActionsections apply to all the actions taken by theFor eachaction.
  • TheRun detailssection, including the preview of the workflow, apply only to the last action that theFor eachaction has taken.

Example

Example of a workflow that retrieves a list of unfulfilled orders every day at 5:00 pm adds a tag to each retrieved order.

In this example workflow, a list of unfulfilled orders is retrieved every day at 5:00 pm. TheExpedite shippingtag is added to every order in the list.

Ready to start selling with Shopify?

Try it free