How to work with future delivery dates in metafields?

sherifabdulla
Tourist
3 0 1

Hi everyone,

 

I have a store that has a variant metafield called "delivery_date". We set the date to be in the future for when the variant is expected to be delivered.

I would like to create an action with a slack notification in the end:

When an order is placed -> if delivery_date > today -> send message.

 

However, because all metafield values are strings I cannot create this condition. Is there a way around this?

 

One alternative is to create a second daily flow:

Every day, get data for delivery_date, if <=today, then delete data; that way the flow above can work if the condition is set to "has value". But I don't know how to make this second flow work either

 

Any advice would be helpful! Thank you!

Replies 3 (3)

paul_n
Shopify Staff
1005 133 240

You can use Run code to get around this, because you can cast that string to a date.

 

Here's an example showing how to work with dates for a slightly different use case :https://github.com/Shopify/flow-code-examples/blob/main/run-code-examples/schedule-check-scheduled-t... 

Paul_N | Flow Product 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.
sherifabdulla
Tourist
3 0 1

Thanks Paul! I'm not very familiar with code; are you able to run me through the logic of how it works, please?

paul_n
Shopify Staff
1005 133 240

Here's more details about the Run code step: https://help.shopify.com/en/manual/shopify-flow/reference/actions/run-code

Paul_N | Flow Product 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.