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:
The function would be:Code:function update(&$callingClass, $notifier) {
Modify the function updateNotifyHeaderStartCheckoutShipping as below in red: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; }
Then modify the updateNotifyOrderCartFinished function as indicated 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 } }
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:
And change per the below: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 -->
Then, lastly, to define ORDER_DELIVERY_DATE_LOCATION to be one of the three values of: 'national', 'international', or 'both'.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 -->
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:
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.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'
Again, this has not been tested and was presented as a thought of what may be necessary...



Reply With Quote
