Customer spending 365 days

Hey,

We have B2B and D2C customers in our shop. but B2B customers can reach different discount levels depending on their spending of the last 365 days.

Currently, we need to check their spending over the last 365 days periodically (manually) and then may adjust their tags.

Would it be possible to use S.Flow to automate this?

Order created-> Check if the customer has the tag “xxx” (B2B customer tag)-> if yes → Check turnover of customer over the last 365 days → if over 2500.- add tag “XYZ” (discount level tag) to customer-> if over 5000.- add tag “ABC” (discount level tag 2) to customer…

The main thing I’m struggling with is the “last 365 days” part.

Thx for your help
Cheers
Dominic

1 Like

Yeah shouldn’t be a problem. Use get order data with created_at > 365 days ago. Then sum the values up.

1 Like

Thank you.

I now used:
“created_at:<=‘{{ scheduledAt }}’ AND created_at:>‘{{ scheduledAt | date_minus: “365 day” }}’”
for it (adapted to the standard “created in the last day” one, but it tells me “scheduledAt” is invalid
Any pointers?

If you change “scheduledAt” to “now” then it should work as that will execute when it’s scheduled to run.

1 Like

It almost seems to work, thank you very much.
The only thing is, I seem not to be able to get the correct sum. When it runs it always gives me a sum I know is not correct for that account.

Any tips?
Cheers

Do you have a link to your workflow that I could use to help debug the issue?

Thank you so much
how would I link the workflow?
Cheers