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

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

bigdzo
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 3 (3)

DaveMcV
Shopify Staff
104 31 29

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.

 

Cheers

Dave
 

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

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

 

Best,

Nikola

Lorenzo_dr
Shopify Partner
2 0 0

Hello Dave,

do you have any update?
I'd like to run a cron job that has to delete a tag from customers if they're not part of a segment anymore and I'm finding it difficult not being able to nest iterations.

Thank You