Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
We use the trigger order created to notify us if no shipment has been made within 36 hours.
It goes something like this:
Order created >> wait 36 hours >> check for shipping >> send Slack message if no shipping.
But now we have the problem that our warehouse is not always working on weekends. Therefore we would like to have it something like this:
Order created >> Check for weekday (if order is created between Sunday and Thursday) >> Wait for 36 hours. But if the order was created between Friday and Saturday, wait e.g. 48 hours.
But I have not found out how to create a check based on weekdays,
Is it possible somehow?
Solved! Go to the solution
This is an accepted solution.
Hi @Timo_Krause
one way you could approach is would be to print the day of the week this order was created on using a variable that prints the day of week in a tag or metafield, and later check again for that same value to determine if it's a weekday or a weekend order:
{{ order.createdAt | date: "%a" }}
You can use a wait step for a few seconds to make sure the condition is applied on the updated item.
This way you can have different paths to manage your shipping processes.
To learn more visit the Shopify Help Center or the Community Blog.
Currently there is no way to check the current day of the week in Flow.
To learn more visit the Shopify Help Center or the Community Blog.
This is an accepted solution.
Hi @Timo_Krause
one way you could approach is would be to print the day of the week this order was created on using a variable that prints the day of week in a tag or metafield, and later check again for that same value to determine if it's a weekday or a weekend order:
{{ order.createdAt | date: "%a" }}
You can use a wait step for a few seconds to make sure the condition is applied on the updated item.
This way you can have different paths to manage your shipping processes.
To learn more visit the Shopify Help Center or the Community Blog.
At the moment of writing as in Flow can be inserted custom Javascript code this is possible indeed with a javscript code.
The following:
export default function main(input) {
const order = input.order;
// Parse the createdAt date
const createdDate = new Date(order.createdAt);
const dayOfWeek = createdDate.getUTCDay(); // Sunday = 0, Saturday = 6
// Check if createdAt is a weekend day (Saturday or Sunday)
const isWeekendOrder = dayOfWeek === 0 || dayOfWeek === 6;
return {
isWeekendOrder, // Boolean: true if created on a weekend
orderId: order.id, // Order ID
};
}
If I understand correctly, after the `Run code` step we need to set up a condition that will establish different waiting times depending on the calculation result? This might be inconvenient as it would require duplicating the steps "check for shipping >> send Slack message if no shipping".
No, I mean, first the code into the run code(missing the input shape and output shape object in purpose, I would give in pm), is checking if the order is made on a weekend /weekday, it can be easy adapted as dayOfWeek === 6 is Staturday.
There is no duplication in term of that if a condition is true, then proceed in a defined path, otherwise in another.
This is exactly what is been asked.
I see that there is no duplication in the code itself. I meant that duplication exists in the steps following the “Run code” phase. The subsequent steps differ only in the waiting time. The “check for shipping” and “send Slack message if no shipping” steps are identical, regardless of whether the order is placed on a weekend or a weekday.
The duplication of these steps can also be eliminated by moving them into a separate workflow and invoking it from both branches of the condition.
Hey Community! As we jump into 2025, we want to give a big shout-out to all of you wh...
By JasonH Jan 7, 2025Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024