Hi,
I’m using the new Sense Theme and I’m trying to show the text “Free Shipping until (current date/today’s date)” using metafields, but I can’t find a way to do that. I already tried to use the metafield date and I’ve been searching for a solution, but with no sucess.
Does anyone know how can I add that Current Date Metafield text?
Hi André,
Could you please share more details on this task? What date would you like to display in that “Free Shipping” message? The “today” date (and make sure that it would be updated automatically), a static date from a metafield etc.
You can display the current date with a Liquid snippet like this:
Free Shipping until {{'now' | date: "%Y-%m-%d" }}
Also, you may want to visit the following resources to learn more about the dates in Liquid:
-
general information;
-
Liquid reference.
And the metafield-based date can be displayed like this:
Free Shipping until {{ product.metafields.my_fields.date.value }}
1 Like
It worked! It’s exactly what I wanted to do. I used your first code example.
Thank you very much!
1 Like
I am using the date metafield. By default it displayed date as YYYY-MM-DD. I added this code: "| date: “%m-%d-%Y” and it now display as: MM-DD-YYYY.