FROM CACHE - en_header

Estimate delivery date

Anna101
New Member
4 0 0

Hi I'm using this code to display estimate delivery date

<p>Order today, and you'll receive your package 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(5);
  if (fromDate.is().saturday() || fromDate.is().sunday()) { 
    fromDate = fromDate.next().monday();
  }
  var toDate = Date.today().addDays(10);
  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> 

but I would like only business days to be counted in the calculation and not the weekend as is the case now

Can anyone help me?

Thanks

Reply 1 (1)
deenetz
New Member
6 0 0

@Anna101 wrote:

Hi I'm using this code to display estimate delivery date

<p>Order today, and you'll receive your package 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(5);
  if (fromDate.is().saturday() || fromDate.is().sunday()) { 
    fromDate = fromDate.next().monday();
  }
  var toDate = Date.today().addDays(10);
  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> 

but I would like only business days to be counted in the calculation and not the weekend as is the case now

Can anyone help me?

Thanks


Hey there! Recently released a Shopify app called Simpli - Delivery Estimation & I think it’ll be a perfect fit for your brand as it eliminates any sort of shipping anxiety your customers may have at your product page in turn increasing conversions.

Check it out: https://apps.shopify.com/delivery-estimation