Weekly flow that would add customer tags/metafield based on how much customer spent past year

Shopify Partner
3 0 1

Hi everyone,


I've had some trouble setting this up. I was able to create an order-triggered flow that queries for the orders in the past year based on customer-id and sums them up but couldn't do it for scheduled-at-triggered flow.


I've added "Get customer data" as a step and then tried using the "for each" loop to get order data for the past year and then sum the amounts but was not able to make it work (it's actually succeeding and summing up something but none of the test customers have anything changed). I attached the screenshot of the flow (it's a short video since .png was not supported). Also, the code in the "Get order data" step is:

{% for getCustomerData_item in getCustomerData %}
{% for orders_item in getCustomerData_item.orders %}
getCustomerData_item.id:{{orders_item.customer.legacyResourceId}} AND created_at:>='{{ "now" | date_minus:"1 year" }}'
{% endfor %}
{% endfor %}


All the best to all!

Replies 2 (2)

Shopify Staff
82 26 24

Hi Bigdzo,


Flow currently only allows one iterator step to run within a For Each loop, which makes this challenging at the moment. We have some work coming shortly which should help with use cases like summing up a customer's orders within the last year. Stay tuned for that in the next couple of weeks.




DaveMcV | Flow Development 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.
Shopify Partner
3 0 1

Thank you for your reply, Dave! I'm looking forward to what the next few weeks will bring!