Hi' All
I have an ordering formular where users can choose on have many days they want their order on. I use the below script to calculate and show the shipping date:
What i want the script to do as an extra thing is to add one day extra, to the days already added, if the user uses the ordering formular after 3 p.m. Can this be done...???
Example:
A user orders at 4 p.m. on the 24th of November and wants the order on 2 days. So instead of delivery date being the 26th of November it should be the 27th of November...
I have an ordering formular where users can choose on have many days they want their order on. I use the below script to calculate and show the shipping date:
Code:
<script type="text/javascript">
function setDelivery(val) {
var delivery = new Date(); // We start on current day
var theyear = delivery.getFullYear();
var themonth = delivery.getMonth()+1;
var i = 0; // i - Number of working days we have reached
while (i < parseInt(val)) // We continue until we have reached the desired number of working days
{
delivery.setDate(delivery.getDate() + 1); // Always jump one day ahead
if (delivery.getDay() != 0 && delivery.getDay() != 6) i++; // Provided that it is not a saturady or sunday we add a working day to i
}
// Now "delivery" should contain the desired date.
//you have the correct date...
document.getElementById("shopform").shipdate.value = delivery.getDate() + "-" + (delivery.getMonth() + 1) + "-" + delivery.getFullYear();
}
// end Helpers -->
</script>
Example:
A user orders at 4 p.m. on the 24th of November and wants the order on 2 days. So instead of delivery date being the 26th of November it should be the 27th of November...
Comment