UPDATE::: you had underscores at the end of the metafield coding. Once removed, it works great. Thanks!
Topic summary
A user implemented an estimated delivery date feature on Shopify product pages using metafields and custom CSS. The code calculates a future delivery date by adding a specified number of days to the current date.
Initial Problem:
- Needed to add date ranges (e.g., “Jan 15 to Jan 20”) instead of single dates
- Wanted location-based delivery estimates for different countries (USA vs Canada)
Solution Provided:
- Create a second metafield called “Range Date For Delivery” to specify the start of the date range
- Modified code displays both range start and end dates using two metafields
- The original poster confirmed the solution works after removing trailing underscores from the metafield references
Location Detection:
- Suggested using Shopify’s Location API to detect customer location and adjust delivery estimates accordingly
- This feature remains unimplemented but was recommended as the next step
Status: The date range functionality is now working. Location-based detection would require additional API integration.
1 Like