Using Shopify Flow to update product status based on metafield date

Hi Shopify experts,

I could use some help with using Flow to update products based on metafield values.
I’m a bit stuck and any advice would be greatly appreciated!

Looking to leverage the knowledge of this community.
Thank you in advance for your time and guidance.

Here is a draft community post in English describing your issue and question regarding using Shopify Flow to change product status based on metafield date:

Title: Using Shopify Flow to update product status based on metafield date

Objective: I would like to use Shopify Flow to automatically change the status of products to “draft” when a deadline date saved in the product metafields is reached.

What I have tried:

  1. Created a scheduled daily trigger in Flow

  2. Used the “Update product status” action in Flow

  3. Added a condition to check if the metafield date matches the current date:

    Shop Metafields namespace Equal to 
    and metafields_item.key Equal to  
    and metafields_item.value Equal to {{ "now" | date: "%Y-%m-%d" }}
    

When running this flow, I get an error on the action part and it does not execute properly.

Question: Is there a way to compare the current date and metafield date directly in Liquid, without using the Flow metafield extensions?

I tried to rewrite your issue concisely in fluent English. Please use this as a starting point for your community forum post. Let me know if you would like me to clarify or expand any part of the post.

I appreciate you taking the time to read my post.
Looking forward to hearing your thoughts and suggestions on this issue.
Let me know if you need any clarification or additional details from my end.

Thanks again!
Have a nice day.

Question: Is there a way to compare the current date and metafield date directly in Liquid, without using the Flow metafield extensions?

Yes, you can do that in liquid. You need to get the metafield value into a variable and then compare it with that now variable. You cannot use liquid in a condition like the image you posted above…it needs to be written in an action.

Thank you for your response.
I will read the documentation again as I am still not sure which action and what liquid code to write.
Just knowing that the solution is in Action is a big step forward.

Thank you very much.

The “Run code” action released today makes this pretty straight-forward if you know any JavaScript

Thank you for the useful information! I will try JacaScript, as it seems to be quite flexible and can be specified in code.

Hi,
could you solve this? i am looking for the same flow. thanks

Hi @DGinv ,

You should be able to accomplish this in the Run code action using JavaScript date/time functionality. You’ll be able to access dates from metafields as strings which you can then turn into Date objects to work with in code. You’d be able to use other date fields on trigger variables to get the current date (like createdAt or updatedAt variables).

Hope that helps!