Display an estimated delivery date?

Highlighted
Tourist
10 0 4

I'd like to be able to display an estimated delivery date on each product page. It would be calculated by taking today's date and adding a specified number of business days and then displaying the result. Is there already an app for this? If not, it seems easy enough to code except that I'm not sure how to exclude non-business days when making the calculation. Any advice, thoughts, or resources?

Thanks,

Julie

0 Likes
Highlighted
Shopify Staff
Shopify Staff
5704 1 326

Hi Julie,

I'm not sure how to exclude non-business days when making the calculation.

I'd use JavaScript: http://javascript.about.com/library/blbusdayadd.htm

To add to your product.liquid template.

0 Likes
Highlighted
Tourist
10 0 4

Awesome. I knew there had to be someone who had already done this before me. You're the best, Caroline.

0 Likes
Highlighted
New Member
7 0 0

Hi - did you get this working?

0 Likes
Highlighted
Tourist
10 0 4

I ended up using something else. 

0 Likes
Highlighted
Tourist
17 0 1

Hi Julie - what else did you use?

Many Thanks

 

Neil

0 Likes
Highlighted
Tourist
10 0 4

I used this little bit of javascript:

<script type="text/javascript">(function(){var e=["2013-11-28","2013-12-25","2014-01-01","2014-01-20","2014-02-17","2014-05-26","2014-07-04","2014-09-01","2014-10-13","2014-11-11","2014-11-27","2014-12-25"];var t=function(t){function r(e){e|=0;return(e<10?"0":"")+e}var a=t.getFullYear()+"-"+r(t.getMonth()+1)+"-"+r(t.getDate());if(e.indexOf(a)!=-1)return 1;else return 0};function r(t,r){var a=t.getDay();var n=new Date(t.getTime());var i=new Date(t.getTime());i.setDate(t.getDate()+r+(a===6?2:+!a)+Math.floor((r-1+(a%6||1))/5)*2);for(var u in e){var v=e[u];var g=v.split("-");var D=new Date(g[0],g[1]-1,g[2]);var o=0;if(D.getTime()>=n.getTime()&&D.getTime()<=i.getTime()&&D.getDay()!=0&&D.getDay()!=7){i=new Date(i.getTime()+864e5);o++}if(o>1){i=new Date(i.getTime()+864e5)}}return i}function a(e){var t=new Array("January","February","March","April","May","June","July","August","September","October","November","December");var r=e.getDate();var a=e.getMonth();var n=e.getFullYear();return""+t[a]+" "+r+", "+n}jQuery(document).ready(function(e){var t=new Date;var n=r(t,12);var i=r(t,6);e("#todayDate").text(a(t));e("#normalArrivalDate").text(a(n));e("#fastestArrivalDate").text(a(i))})})();</script>

The key bits you'd need to change would be n=r(t,12);var i=r(t,6); for me, 12 is the number of business days for standard and 6 is the number of business days for rush delivery

Highlighted
Tourist
17 0 1

Thanks Julie

Will need to adapt a little as we aim to deliver next day if ordered prior to 4pm but that is a cracking starting place.

Thanks again

NMD

 

0 Likes
Tourist
4 0 3

Hi Julie,

I'm trying to display estimated delivery dates and your code seems to be exactly what I need. But I'm such a newbie that I don't know how to include it in my theme. Could you please tell me how/where to use that code?

Thank you so much!!!

0 Likes