
Originally Posted by
nicksab
Thank you very much. It seems to be working like a charm so far. This should even be part of the readme file or something.
I do have 2 last questions on this mods.
First, I am using this an older version of this plugin on another website with ZC 1.5.1. I did the change on post #7 of this threads so ODD will move forward to the next day after a certain time.
Is there a way of doing the same thing with the newer version of ODD? I have it set to 0 now so it allows same day delivery all day. However, I need it to move forward to the next day once it pass like 1 PM.
Second, the inverted date is still a little bit confusing. I tried to change Y-m-d to m-d-Y but it just breaks the whole thing.
Sorry for the long post. I am in no way a programmer obviously and I could use some more help
Thank you
The application as generally provided has been put together to use javascript. The current javascript code being used does not differentiate options by hours; however, there are some options available. For one, to revert back to what was used when this plugin was first developed would modify the below code found in includes/templates/YOUR_TEMPLATE/templates/tpl_checkout_shipping_default.php:
Code:
<!-- Bof Order Delivery Date -->
<?php if (isset($display_delivery_date) ? $display_delivery_date : true) { ?>
<fieldset class="shipping" id="order_delivery_date">
<legend><?php echo sprintf(TABLE_HEADING_DELIVERY_DATE, (defined('MIN_DISPLAY_DELIVERY_DATE') && MIN_DISPLAY_DELIVERY_DATE > 0 && (method_exists($zcObserverOrderDeliveryDateObserver, 'display_delivery_date') ? $zcObserverOrderDeliveryDateObserver->display_delivery_date($order) : true)) ? TABLE_HEADING_DELIVERY_DATE_IS_REQUIRED : TABLE_HEADING_DELIVERY_DATE_IS_OPTIONAL); ?></legend>
<label for="order_delivery_date">Date:</label>
<input id="date" name="order_delivery_date" type="text" value="<?php echo $order_delivery_date; ?>">
</fieldset>
<?php } ?>
<!-- Eof Order Delivery Date -->
and to replace the input line with:
Code:
<select name="order_delivery_date">
<?php
$current_time = (date("h:ia"));
$current_hour = (date("H")); // 24 hour time as two digits
$begin_cutoff_hour = '10'; // set on a 24 hour time clock
$end_cutoff_hour = '19'; // set on a 24 basis - "19" would be 7pm
$time_zone_adjust = '0'; // use this to adjust your hour value forward or backwards
$display_current_time = false; // Chage to "true" to check your system time for adjustments to $time_zone_adjust. Result will be echo'd to browser below ship date dropdown menu
$current_adjusted_hour = ($current_hour + $time_zone_adjust);
if($current_adjusted_hour <= $begin_cutoff_hour) {
$date_offset = '0';
}
else {
$date_offset = '1';
}
for ($i=$date_offset, $n=50; $i < $n; $i++) {
$now[$i] = strtotime ("+$i day", time());
if ( strftime ("%w",$now[$i])<>0
AND strftime ("%m-%d",$now[$i])<>"12-25"
AND strftime ("%m-%d",$now[$i])<>"12-26"
AND strftime ("%m-%d",$now[$i])<>"01-01"
){
echo '<option value="'.strftime ("%Y-%m-%d",$now[$i]).'">'.strftime ("%A %d %B %Y",$now[$i]).'</option>';
}
}
?>
</select>
Modifying the content of the for loop as necessary to support your business and date(s).
The date/time will still be stored in the database expected format of year-month-day; however, the selection option will be presented as desired/formatted.
As to using the provided javascript calendar to display the format differently, basically I envision that additional javascript would be necessary to do something like hide the provided input box providing an additional box that is formatted to display the result(s) desired and updated when the base data is modified. The reason for this operation is that if the visiting customer either does not have javascript/jquery/etc..., has disabled it, or there is a network problem, then the existing field would still be displayed and support data entry, though it would be expected to be in the year-month-day format.
Alternatively, the includes/modules/pages/checkout_shipping/jscript_calendar_head.php file could be modified following the instruction of the file and possibly the logic of above to disable today's date based on the page load time being above a certain value. This could be done by setting/adjusting the DIRECTION parameter following this instruction that is contained in the file:
DIRECTION - A positive or negative integer that determines the calendar's direction: n (a positive number) the calendar is future-only beginning at n days after today; -n (a negative number) the calendar is past-only ending at n days before today; 0 (zero) the calendar has no future or past restrictions (default). Note if you would like the calendar to be directional starting from today–as opposed to (1) tomorrow or (-1) yesterday–use a positive or negative fraction, such as direction: .5 (future-only, starting today).
This could be applied by the following in that file changing the default:
Code:
?>
<script type="text/javascript">
window.addEvent('domready', function() { myCal = new Calendar({ date: 'Y-m-d' }, { blocked: ['24-25,31 12 *', '0 * * 0'], direction: 3, draggable: false }); });
</script>
<?php /*
to:
Code:
$current_time = (date("h:ia"));
$current_hour = (date("H")); // 24 hour time as two digits
$begin_cutoff_hour = '10'; // set on a 24 hour time clock representing the hour portion of time where still can use the "earliest" available date.
$time_zone_adjust = '0'; // use this to adjust your hour value forward or backwards
$display_current_time = false; // Change to "true" to check your system time for adjustments to $time_zone_adjust. Result will be echo'd to browser below ship date dropdown menu (if applicable echo code has been added there see post #7 of the forum thread).
$current_adjusted_hour = ($current_hour + $time_zone_adjust);
$direction_add = 1;
if($current_adjusted_hour <= $begin_cutoff_hour) {
$direction_add = 0;
}
?>
<script type="text/javascript">
window.addEvent('domready', function() { myCal = new Calendar({ date: 'Y-m-d' }, { blocked: ['24-25,31 12 *', '0 * * 0'], direction: <?php echo 3 + $direction_add; ?>, draggable: false }); });
</script>
<?php /*
The echo 3 + $direction_add will either add a day or not to the existing 3 days from today.
As for instructions, well, I had set out to incorporate direction similar to above; however, besides at the time getting to a point of just moving on (still need to report issues encountered at the plugin's thread) also realized that the other plugin is still changing in various ways so didn't want to make the instructions so detailed that they have to change daily plus not being involved in the day-to-day development don't necessarily know the next direction it will take.
Bookmarks