Code Guides > How to make a delivery date estimator that avoids weekends for a Shopify product page

How to make a delivery date estimator that avoids weekends for a Shopify product page

Hey,

I've seen a lot of people looking for this online without a solution. I built this and am testing it out on The William Painter Sunglasses website. Here is a screenshot of how it looks.

This uses javascript to show the estimated delivery date of your products with javascript by calculating todays date, adding two days, or more depending on what the current day of the week is. This is built to avoid weekend days so people don't get estimates that are on weekends as delivery doesn't normally happen then. This is a very rudimentary solution as it does not connect with any shipping provider, but works well to increase conversion by showing this information.

First, add this to your product form where you want the information to show. This has a liquid backup of two days from now, in case the javascript does not fire.

Second, add this to your theme.js javascript file to trigger the date and time remaining. I added some logic that will add an extra day if it is past noon, as that is a common cutoff date.

Let me know if this works for you and share improvements on the code. I am still optimizing it for load time, but wanted to share what I have working so far.