Re: Order Delivery Date Support Thread
Quote:
Originally Posted by
plantman
Sorry, I thought of that just now. They are the plain text emails. A lot of our customers are schools and html emails don't go through some of the systems well.
Your includes/classes/orders.php file should have a notifier at or around line 1018:
Code:
$this->notify('NOTIFY_ORDER_EMAIL_BEFORE_PRODUCTS', array(), $email_order, $html_msg);
Also the new code located in includes/classes/observers/auto.order_delivery_date_observer.php within the function updateNotifyOrderEmailBeforeProducts should have a line:
Code:
$email_order .= EMAIL_TEXT_DELIVERY_DATE . ' ' . zen_db_output($callingClass->info['order_delivery_date']) . "\n\n";
that appends the delivery date to just after the customer provided comments block...
That the data is available in the admin does indicate that at least it was stored with the order and confirms that it is locatable in the database and therefore should be present to be used in the above code.
Ohhhh... That all is fine and dandy, but the identification of using the above function is missing from the observer class:
Add the following at line 33 (moving existing line 33 down one) of includes/classes/observers/auto.order_delivery_date_observer.php:
Code:
$attachNotifier[] = 'NOTIFY_ORDER_EMAIL_BEFORE_PRODUCTS';
Change shown and incorporated in master branch: https://github.com/mc12345678/order-delivery-date/commit/53e749993e8c6a02780a28ed7dc04477826735df#diff-dbecab78edebe73f70eecd555e1b74cd
Re: Order Delivery Date Support Thread
All of that appears to be there but but that doesn't seem to be doing the job.
Re: Order Delivery Date Support Thread
Quote:
Originally Posted by
plantman
All of that appears to be there but but that doesn't seem to be doing the job.
Until about 15 minutes ago, the $attachNotifier identified above was not present in the file system:
The line listed in red below has been newly added to the file download, needs to be added to your installation, and would be a reason that the email would not include the order delivery date information (in either html or plain text).
This is from/to be in: includes/classes/observers/auto.order_delivery_date_observer.php
Code:
function __construct() {
$attachNotifier = array();
$attachNotifier[] = 'NOTIFY_ORDER_AFTER_QUERY';
$attachNotifier[] = 'NOTIFY_ORDER_CART_FINISHED';
$attachNotifier[] = 'NOTIFY_ORDER_DURING_CREATE_ADDED_ORDER_HEADER';
$attachNotifier[] = 'NOTIFY_ORDER_EMAIL_BEFORE_PRODUCTS';
$attachNotifier[] = 'NOTIFY_HEADER_START_CHECKOUT_SHIPPING';
$attachNotifier[] = 'ORDER_QUERY_ADMIN_COMPLETE';
$this->attach($this, $attachNotifier);
}
If it was added while still logged in from the previous test, may need to log out and log back in/clear cache/sessions for the information to get "refreshed". Otherwise, you may have read the message before it was modified and only now have seen the modification that fixes the issue. :)
Re: Order Delivery Date Support Thread
The added code took care of it. You are awesome. Thanks
Re: Order Delivery Date Support Thread
Quote:
Originally Posted by
plantman
The added code took care of it. You are awesome. Thanks
Keep the feedback coming in whatever it is you test, try, or use... Everyone that has written something or added their touch can only really know what is and is not working by the feedback from the users. Mind you, it's most helpful to everyone if at least a little self research is done, but everyone makes mistakes. I could have deleted that entire "logic", but if nothing else you can see the process of elimination that I used... :) Had to go back to the basics again. :)
Thank you for confirming it fixed the issue. Now to write some more instruction on how to manage a transition from an older version to this one and maybe how it can be operated in ZC 1.5.3/1.5.4 (was just looking at the notifiers to see if it was possible without significant change to the ZC software).
I have also seen that there might be a remote possibility of capturing a time option as requested a few pages back which means likely will want to introduce an auto-installer to make the overall installation and support easier...
Re: Order Delivery Date Support Thread
Posted version 2.5.2 of the plugin to the ZC software moderators.
Quote:
What changed v2.5.2:
- Removed modifications from core files and used the notifier/observer system instead for ZC 1.5.5. Specifically the autoloader system.
- Replaced the mootools javascript with software that works with ZC 1.5.5.
- Removed changes from template files that did not get incorporated into ZC 1.5.5.
- Added text to identify that the delivery date is optional/required.
Once accepted it will be available for download from the ZC forum from here.
Re: Order Delivery Date Support Thread
Quote:
Originally Posted by
mc12345678
Posted version 2.5.2 of the plugin to the ZC software moderators.
Once accepted it will be available for download from the ZC forum
from here.
Version 2.5.2 has been reviewed and posted and is available from this zen-cart link:
Re: Order Delivery Date Support Thread
Hi there and first off, thank you so much for this wonderful mod. It is extremely useful for logistics operations.
One question: is there anyway I can code it such that the delivery date picker pops up only for local orders and not international orders?
Right now, if an international customer ignores the date picker and doesn't make a selection, the customer isn't allowed to proceed to the next page.
Any insight will be greatly appreciated!
Re: Order Delivery Date Support Thread
Quote:
Originally Posted by
audrey
Hi there and first off, thank you so much for this wonderful mod. It is extremely useful for logistics operations.
One question: is there anyway I can code it such that the delivery date picker pops up only for local orders and not international orders?
Right now, if an international customer ignores the date picker and doesn't make a selection, the customer isn't allowed to proceed to the next page.
Any insight will be greatly appreciated!
At minimum there are two files that would require modification, the observer class and then the checkout_shipping template file. I assume that for "sanity's" sake that if the current page were loaded with a send-to address that is international, that you would *not* want to display the delivery date field, though perhaps that would be a separate control to be addressed. The "condition" would update based on page reload/change when selecting an alternate ship-to address.
Some things that need to be considered: Where the definition/control is to be placed to identify perhaps usage for 'national', 'international', or 'both' (shipping typically or possibly has such a control which can be adapted to this), the consideration of free shipping items (does the delivery date and/or identification of a delivery date factor into such a situation)
The below is completely untested and written from a perspective of "seems like it would work"...
Per the below, modify: includes/classes/observers/auto.order_delivery_date_observer.php
Add a new function just before:
Code:
function update(&$callingClass, $notifier) {
The function would be:
Code:
/**
* Function to support display of the delivery date based on known internally collected order information.
**/
function display_delivery_date($order = NULL) {
// if this function is called, but there is no ORDER_DELIVERY_DATE_LOCATION defined, then allow the delivery date to be displayed.
if (!defined('ORDER_DELIVERY_DATE_LOCATION')) return true;
// If the location to be sent to is not defined, then address information will not be available for the $order class to determine
// the destination, indicate to display the delivery date.
if (!isset($_SESSION['sendto']) return true;
if (!isset($order)) {
$order = $GLOBALS['order'];
}
if (!isset($order)) {
// This area may need additional assignments in order to generate the appropriate information to be handled below
// if $order has not previously been fully populated.
require(DIR_WS_CLASSES . 'order.php');
$order = new order;
}
$pass = false;
switch (ORDER_DELIVERY_DATE_LOCATION) {
case 'national':
if ($order->delivery['country_id'] == STORE_COUNTRY) {
$pass = true;
}
break;
case 'international':
if ($order->delivery['country_id'] != STORE_COUNTRY) {
$pass = true;
}
break;
case 'both':
$pass = true;
break;
}
return $pass;
}
Modify the function updateNotifyHeaderStartCheckoutShipping as below in red:
Code:
// ZC155: $zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_SHIPPING');
// NOTIFY_HEADER_START_CHECKOUT_SHIPPING
function updateNotifyHeaderStartCheckoutShipping(&$callingClass, $notifier) {
global $order_delivery_date, $messageStack;
// BEGIN Order Delivery Date
if (isset($_SESSION['order_delivery_date'])) {
$order_delivery_date = (isset($_SESSION['order_delivery_date'])) ? $_SESSION['order_delivery_date'] : null;
}
if ( isset($_POST['action']) && ($_POST['action'] == 'process') ) {
if (zen_not_null($_POST['order_delivery_date'])) {
$_SESSION['order_delivery_date'] = zen_db_prepare_input($_POST['order_delivery_date']);
} else if (defined('MIN_DISPLAY_DELIVERY_DATE') && MIN_DISPLAY_DELIVERY_DATE > 0 && $this->display_delivery_date())
{
$messageStack->add_session('checkout_shipping', ERROR_PLEASE_CHOOSE_DELIVERY_DATE, 'error');
unset($_SESSION['order_delivery_date']);
unset($order_delivery_date);
zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
} else {
// If nothing was posted, and the date is not required, then
// be sure to clear the date from the session so that the
// nothing will carry forward.
unset($_SESSION['order_delivery_date']);
}
$order_delivery_date = isset($_SESSION['order_delivery_date']) ? $_SESSION['order_delivery_date'] : null; // modified for strict processing mc12345678 2018-01-24
}
}
Then modify the updateNotifyOrderCartFinished function as indicated below in red:
Code:
// ZC 1.5.5: $this->notify('NOTIFY_ORDER_CART_FINISHED');
// This point was chosen to have just one delivery date for the entire order.
// To support a different delivery date by product, would want to either cycle through all of the product in this
// function or use the notifier 'NOTIFY_ORDER_CART_ADD_PRODUCT_LIST' to work with each product as it comes along.
function updateNotifyOrderCartFinished(&$callingClass, $notifier) {
global $display_delivery_date;
$callingClass->info['order_delivery_date'] = (isset($_SESSION['order_delivery_date'])) ? $_SESSION['order_delivery_date'] : null;
// set the global variable to display the delivery date (or not) based on the destination of the delivery.
$display_delivery_date = $this->display_delivery_date($callingClass);
}
Then in the template files:
includes/templates/YOUR_TEMPLATE/templates/tpl_checkout_shipping_default.php
and/or
includes/templates/YOUR_TEMPLATE_RESPONSIVE/templates/tpl_checkout_shipping_default.php
Find:
Code:
<!-- Bof Order Delivery Date -->
<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) ? 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>
<!-- Eof Order Delivery Date -->
And change per the below:
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) ? 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 -->
Then, lastly, to define ORDER_DELIVERY_DATE_LOCATION to be one of the three values of: 'national', 'international', or 'both'.
Ideally/ultimately this may be in an admin setting; however, let's put it in a file for the moment.
add a new file: includes/extra_datafiles/order_delivery_date_location.php
that contains:
Code:
<?php
/**
* This file contains the definition for when to display the order delivery date field based on the shipping destination.
**/
define('ORDER_DELIVERY_DATE_LOCATION', 'both'); // values are 'national', 'international', or 'both'
If the above changes are entered in that sequence (and potentially tested at each "chunk" of addition), then operation should not be disturbed along the way.
Again, this has not been tested and was presented as a thought of what may be necessary...
Re: Order Delivery Date Support Thread
I posted this a couple of years ago - time is added in quite easily, but take note my instructions are for an older version of the module ....
Will note though that while I thought time selection was a great idea at the time, we have now abandoned it as we found it too hard to meet customer demands.
Zencart Order Delivery Date – Time Addition
Following documents changes I made to my 1.5.1 installation to add Order Delivery Time to your Zencart.
It assumes you have Order Delivery Date mod already installed.
Datebase changes
orders.order_delivery_date was added as type 'date'. This needs to be changed to 'datetime'.
admin/includes/classes
order.php
no change
admin/includes/languages/English
orders.php
Change -
define('TABLE_HEADING_DELIVERY_DATE', 'Desired Delivery Date');
define('ENTRY_DELIVERY_DATE', 'Desired Delivery Date:');
define('EMAIL_TEXT_DELIVERY_DATE', 'Desired Delivery Date:');
To -
define('TABLE_HEADING_DELIVERY_DATE', 'Desired Delivery Date');
define('ENTRY_DELIVERY_DATE', 'Desired Delivery Date:');
define('EMAIL_TEXT_DELIVERY_DATE', 'Desired Delivery Date:');
define('TABLE_HEADING_DELIVERY_TIME', 'Desired Delivery Time');
define('ENTRY_DELIVERY_TIME', 'Desired Delivery Time:');
define('EMAIL_TEXT_DELIVERY_TIME', 'Desired Delivery Time:');
invoice.php
Change -
define('ENTRY_DELIVERY_DATE', 'Desired Delivery Date:');
To -
define('ENTRY_DELIVERY_DATE', 'Desired Delivery Date:');
define('ENTRY_DELIVERY_TIME', 'Desired Delivery Time:');
packingslip.php
Change –
define('ENTRY_DELIVERY_DATE', 'Desired Delivery Date:');
To –
define('ENTRY_DELIVERY_DATE', 'Desired Delivery Date:');
define('ENTRY_DELIVERY_TIME', 'Desired Delivery Time:');
admin/
invoice.php
Change –
<tr>
<td class="main"><strong><?php echo ENTRY_DELIVERY_DATE; ?></strong></td>
<td class="main"><?php echo zen_date_long($order->info['order_delivery_date']); ?></td>
</tr>
To -
<tr>
<td class="main"><strong><?php echo ENTRY_DELIVERY_DATE; ?></strong></td>
<td class="main"><?php echo zen_date_long($order->info['order_delivery_date']); ?></td>
</tr>
<tr>
<td class="main"><strong><?php echo ENTRY_DELIVERY_TIME; ?></strong></td>
<td class="main"><?php echo substr(zen_datetime_short($order->info['order_delivery_date']) ,11); ?></td>
</tr>
orders.php
Change –
<td class="main"><strong><?php echo ENTRY_DELIVERY_DATE; ?></strong></td>
<td class="main"><?php echo zen_date_long($order->info['order_delivery_date']); ?></td>
</tr>
To –
<td class="main"><strong><?php echo ENTRY_DELIVERY_DATE; ?></strong></td>
<td class="main"><?php echo zen_date_long($order->info['order_delivery_date']); ?></td>
</tr>
<tr>
<td class="main"><strong><?php echo ENTRY_DELIVERY_TIME; ?></strong></td>
<td class="main"><?php echo substr(zen_datetime_short($order->info['order_delivery_date']) ,11); ?></td>
</tr>
packingslip.php
Change –
<tr>
<td class="main"><strong><?php echo ENTRY_DELIVERY_DATE; ?></strong></td>
<td class="main"><?php echo zen_date_long($order->info['order_delivery_date']); ?></td>
</tr>
To –
<tr>
<td class="main"><strong><?php echo ENTRY_DELIVERY_DATE; ?></strong></td>
<td class="main"><?php echo zen_date_long($order->info['order_delivery_date']); ?></td>
</tr>
<tr>
<td class="main"><strong><?php echo ENTRY_DELIVERY_TIME; ?></strong></td>
<td class="main"><?php echo substr(zen_datetime_short($order->info['order_delivery_date']) ,11); ?></td>
</tr>
email
no change
(this could be improved - but the time does appear next to delivery date.)
includes/classes
order.php
no change
includes/languages/english/TEMPLATE/
checkout_confirmation.php
Change –
// Begin Order Delivery Date
define('TABLE_HEADING_DELIVERY_DATE', 'Desired Delivery Date');
// End Order Delivery Date
To –
// Begin Order Delivery Date
define('TABLE_HEADING_DELIVERY_DATE', 'Desired Delivery Date');
define('TABLE_HEADING_DELIVERY_TIME', 'Desired Delivery Time by');
// End Order Delivery Date
checkout_process.php
Change –
// BEGIN Order Delivery Date
define('EMAIL_TEXT_DELIVERY_DATE', 'Desired Delivery Date:');
// END Order Delivery Date
To –
// BEGIN Order Delivery Date
define('EMAIL_TEXT_DELIVERY_DATE', 'Desired Delivery Date:');
define('EMAIL_TEXT_DELIVERY_TIME', 'Desired Delivery Time:');
// END Order Delivery Date
checkout_shipping.php
Change –
// BEGIN Order Delivery Date
define('TABLE_HEADING_DELIVERY_DATE', 'Desired Delivery Date is Required!');
define('ERROR_PLEASE_CHOOSE_DELIVERY_DATE', 'Please choose a delivery date');
// END Order Delivery
To –
// BEGIN Order Delivery Date
define('TABLE_HEADING_DELIVERY_DATE', 'Desired Delivery Date is Required!');
define('TABLE_HEADING_DELIVERY_TIME', 'Desired Delivery Time is Required!');
define('ERROR_PLEASE_CHOOSE_DELIVERY_DATE', 'Please choose a delivery date');
define('ERROR_PLEASE_CHOOSE_DELIVERY_TIME', 'Please choose a delivery time');
// END Order Delivery
includes/modules/pages/checkout_shipping
header_php.php
Change -
//BEGIN Order Delivery Date
if (zen_not_null($_POST['order_delivery_date'])) {
$_SESSION['order_delivery_date'] = zen_db_prepare_input($_POST['order_delivery_date']);
} elseif (MIN_DISPLAY_DELIVERY_DATE > 0)
{
$messageStack->add_session('checkout_shipping', ERROR_PLEASE_CHOOSE_DELIVERY_DATE, 'error');
To -
//BEGIN Order Delivery Date
if ($_POST['order_delivery_time'] == 'notselected') {
$messageStack->add_session('checkout_shipping', ERROR_PLEASE_CHOOSE_DELIVERY_TIME, 'error');
zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
}
if (zen_not_null($_POST['order_delivery_date'])) {
$_SESSION['order_delivery_date'] = zen_db_prepare_input($_POST['order_delivery_date'] . " " . $_POST['order_delivery_time']);
} elseif (MIN_DISPLAY_DELIVERY_DATE > 0)
{
$messageStack->add_session('checkout_shipping', ERROR_PLEASE_CHOOSE_DELIVERY_DATE, 'error');
jscript_a-mootools.js
no change
jscript_b-calendar.js
no change
jscript_calendar_head.php
no change
includes/templates/TEMPLATE/css
checkout_shipping
no change
includes/templates/TEMPLATE/images
no change
includes/templates/TEMPLATE/templates
tpl_checkout_confirmation_default.php
Change -
<?php // BEGIN Order Delivery Date ?>
<br />
<h3><?php echo TABLE_HEADING_DELIVERY_DATE; ?></h3>
<h4><?php echo zen_date_long($order->info['order_delivery_date']); ?></h4><br />
</div>
<?php // END Order Delivery Date ?>
To -
<?php // BEGIN Order Delivery Date ?>
<br />
<h3><?php echo TABLE_HEADING_DELIVERY_DATE; ?></h3>
<h4><?php echo zen_date_long($order->info['order_delivery_date']); ?></h4><br />
<h3><?php echo TABLE_HEADING_DELIVERY_TIME; ?></h3>
<h4><?php echo substr(zen_datetime_short($order->info['order_delivery_date']),11); ?></h4><br />
</div>
<?php // END Order Delivery Date ?>
tpl_checkout_shipping_default.php
please note I force my customers to choose a 2 hour time window - you can amend the option value statements below to best suit your needs. Do note that I do record the upper limit of the time window in the order.
Its up to you what business logic you wish to apply.
Change -
<!-- Bof Order Delivery Date -->
<fieldset class="shipping" id="order_delivery_date">
<legend><?php echo TABLE_HEADING_DELIVERY_DATE; ?></legend>
<label for="order_delivery_date">Date:</label>
<input readonly="readonly" id="date" name="order_delivery_date" type="text">
</fieldset>
<!-- Eof Order Delivery Date -->
To -
<!-- Bof Order Delivery Date -->
<fieldset class="shipping" id="order_delivery_date">
<legend><?php echo TABLE_HEADING_DELIVERY_DATE; ?></legend>
<label for="order_delivery_date">Date:</label>
<input readonly="readonly" id="date" name="order_delivery_date" type="text">
</fieldset>
<fieldset class="shipping" id="order_delivery_time">
<legend><?php echo TABLE_HEADING_DELIVERY_TIME; ?></legend>
<label for="order_delivery_time">Time:</label>
<select name="order_delivery_time" id="delivery_time">
<option value="notselected" selected="selected">Please select ...</option>
<option value="11:00">09:00-11:00</option>
<option value="12:00">10:00-12:00</option>
<option value="13:00">11:00-13:00</option>
<option value="14:00">12:00-14:00</option>
<option value="15:00">13:00-15:00</option>
<option value="16:00">14:00-16:00</option>
<option value="17:00">15:00-17:00</option>
<option value="18:00">16:00-18:00</option>
</select>
</fieldset>
<!-- Eof Order Delivery Date -->