Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
I have assigned a name variable with a delivery date to a product but when it is displayed in the cart notification window and also at checkout, the default date format changes to YYYY-MM-DD. I need to change this to, for example, 'Wednesday, 8th May 2024'.
I can't seem to find any .liquid or .json files in my sections or templates in the code which has the date formatting for these. Is there a way to change the overall default for the whole website or even just for these isolated instances?
I am using Dawn theme.
Please see pictures below.
Thanks in advance!
Since the date format is predefined, you won't find code to simply edit - instead you need to overwrite it.
You will need to go to locales/en.json and define a new date format variable that the theme will use to overwrite the way dates are displayed. Once you've done that, you can use the new date format on your product page. I'd suggest googling some articles on "date format" and "shopify", and duplicating your theme before making any edits in case you need to roll-back an error.
Good luck and let me know if you have questions!
I have added the following into the locales/en.json file:
"date_formats": {
"custom_format": "%A, %e{{ date_variable | date: '_ordinal' }} %B %Y"
}
However, I am still unable to overwrite the cart notification and checkout date formats with this custom format as they are not hard coded in the liquid files. I think when the cart notification and checkouts are populated by the product, the 'delivery date' name variable that I have assigned to the product is auto populated using a default date format as the variable recognises that it's a date. I can't find this default anywhere in the code editor - really at a loss!
What I've done instead is just changed the date to a string so that Shopify doesn't reformat it but it would be nice to have a proper solution using date formatting.
We recently spoke with Zopi developers @Zopi about how dropshipping businesses can enha...
By JasonH Oct 23, 2024A big shout out to all of the merchants who participated in our AMA with 2H Media: Holi...
By Jacqui Oct 21, 2024We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024