Editing a date calculator script

New Member
2 0 0

I have this script from another forum that I am adding onto my Order Summary page so that customers have an estimated shipment date. It works for the day they order, however if they go back to check at a later date the timeframe is calculated from Date.today.

I am trying to edit the script so that it uses order.created_at instead but I am coming up short and I can't figure it out!

Can anyone help?

Thanks.

 

 

<br>

<br>

<p>Your estimated shipment date for any Design Your Own products is between <span id="fromDate"></span> and <span id="toDate"></span>.</p>

{{ '//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js' | script_tag }}

<script>

  var fromDate = Date.today().addDays(35);

  if (fromDate.is().saturday() || fromDate.is().sunday()) { 

    fromDate = fromDate.next().monday();

  }

  var toDate = Date.today().addDays(42);

  if (toDate.is().saturday() || toDate.is().sunday()) { 

    toDate = toDate.next().monday(); 

  }

  document.getElementById('fromDate').innerHTML = fromDate.toString('dddd MMMM dS');

  document.getElementById('toDate').innerHTML = toDate.toString('dddd MMMM dS');

</script>

0 Likes
Shopify Expert
9778 86 1525

Hey Tiny Tiger,

What's the code you are using with created_at?
Seeing that might give some insight into what the issue is.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
New Member
2 0 0

That is the part I am having trouble with - I am new to coding ;)

I want to substitute today's date with the order created date so it will show the appropriate shipment date for each order.

Can I do that?

0 Likes
Highlighted
Shopify Staff
Shopify Staff
81 0 11

I'll move this to Shopify Design

0 Likes