Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
Good morning,
I have a requirement of displaying the number of orders by a customer in a specific timeframe e.g. last 3 months on the order invoice. It doesn't look like order printer has the customer.orders object to work with so I was looking for a workaround using Shopify Flow.
If I can get this number into the order note, I should be able to pull it into the invoice. I've tried the following code using the modify order note action:
{% for order in customer.orders %}
Date: {{ order.created_at }} <br>
{% endfor %}
However, when I save the flow and then click "Preview Workflow" I get an error saying "Your workflow can't be previewed. Fix any errors and try again."
Any assistance would be appreciated!
Hi @GenOnDev,
I'm pretty sure you cannot do that using Flow either. While liquid works in Flow, it only does so as long as you work with the available template variables, so your code won't run (which is causing your error message). I don't believe there is a way to list a customer's previous orders from an Order created trigger (you can only get the Customer order count, which is not helpful in your situation).
If there were such a way, you could probably do the second part of your query by pushing all past orders in an array with a timestamp for each, then assign a variable with the current date, minus your timeframe limit, and from there figure out how many items in your array are larger than your variable—which would be the number of orders within that timeframe.
You might be able to pull that kind of information using Zapier, or another 3rd-party connector. You could probably use a webhook when an order is created, then pull the customer ID, search the store for orders with that customer ID (since the customer.json doesn't supply that information by itself), and you could maybe sort of kinda get what you need(?). I'm really not sure Zapier's API connection allows for everything I mentioned, but it might be worth a shot.
If anything else comes to mind I'll drop you another reply here.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024