Forums / Managing Customers and Orders / Order Delivery Date Support Thread

Order Delivery Date Support Thread

Views: 163,130

Results 421 to 440 of 545
2 Nov 2017, 5:32 PM
#421
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Order Delivery Date Support Thread

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:

$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: ```
$email_order .= EMAIL_TEXT_DELIVERY_DATE . ' ' . zen_db_output($callingClass->info['order_delivery_date']) . "\n\n";


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:
$attachNotifier[] = 'NOTIFY_ORDER_EMAIL_BEFORE_PRODUCTS';

Change shown and incorporated in master branch: [https://github.com/mc12345678/order-delivery-date/commit/53e749993e8c6a02780a28ed7dc04477826735df#diff-dbecab78edebe73f70eecd555e1b74cd
](https://github.com/mc12345678/order-delivery-date/commit/53e749993e8c6a02780a28ed7dc04477826735df#diff-dbecab78edebe73f70eecd555e1b74cd)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

2 Nov 2017, 5:45 PM
#422
plantman avatar

plantman

New Zenner

Join Date:
Sep 2017
Location:
Rockwood, TN
Posts:
10
Plugin Contributions:
0

Re: Order Delivery Date Support Thread

All of that appears to be there but but that doesn't seem to be doing the job.

2 Nov 2017, 5:51 PM
#423
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Order Delivery Date Support Thread

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

  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. :)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

2 Nov 2017, 5:53 PM
#424
plantman avatar

plantman

New Zenner

Join Date:
Sep 2017
Location:
Rockwood, TN
Posts:
10
Plugin Contributions:
0

Re: Order Delivery Date Support Thread

The added code took care of it. You are awesome. Thanks

2 Nov 2017, 5:59 PM
#425
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Order Delivery Date Support Thread

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...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

13 Nov 2017, 5:41 AM
#426
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Order Delivery Date Support Thread

Posted version 2.5.2 of the plugin to the ZC software moderators.

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.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

22 Nov 2017, 4:19 PM
#427
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Order Delivery Date Support Thread

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:

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

24 Jan 2018, 10:35 AM
#428
audrey avatar

audrey

New Zenner

Join Date:
Dec 2008
Posts:
15
Plugin Contributions:
0

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!

24 Jan 2018, 2:16 PM
#429
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Order Delivery Date Support Thread

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:

  function update(&$callingClass, $notifier) {

The function would be:

  /**
  * 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:

  // 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:

  // 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:

<!-- 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:

<!-- 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:

<?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...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

24 Jan 2018, 11:32 PM
#430
royaldave avatar

royaldave

Zen Follower

Join Date:
Aug 2013
Location:
Perth, WA, AU
Posts:
285
Plugin Contributions:
1

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 -->
28 Jan 2018, 5:42 AM
#431
audrey avatar

audrey

New Zenner

Join Date:
Dec 2008
Posts:
15
Plugin Contributions:
0

Re: Order Delivery Date Support Thread

Thank you for replying!

I tried the code but failed at the first chunk at: function update(&$callingClass, $notifier) {
Immediately after, the my index page showed up blank.

I wonder if I am doing something wrong? Pardon me, I'm not only at an intermediate level. Appreciate any thoughts.

This is how it looks like after I added in the code before the above line.

    // Need a test for presence of field/plugin? Prefer something already in memory rather than asking the DB.
    $order = $db->Execute("SELECT order_delivery_date 
                           from " . TABLE_ORDERS . "
                           where orders_id = " . (int)$order_id);

    $callingClass->info = array_merge($callingClass->info, array('order_delivery_date' => $order->fields['order_delivery_date']));
  }

  /**
  * 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;
  }

  function update(&$callingClass, $notifier) {

mc12345678:

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:

function update(&$callingClass, $notifier) {

> 
> The function would be:
> ```
  /**
  * 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:

// 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:
> ```
  // 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:

<!-- 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: > ``` <!-- 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: > ``` <?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...
28 Jan 2018, 6:57 AM
#432
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Order Delivery Date Support Thread

Looking at it again, in first "chunk"
this:

    if (!isset($_SESSION['sendto']) return true;

is missing a closing paranthesis:

    if (!isset($_SESSION['sendto'])) return true;

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

28 Jan 2018, 1:55 PM
#433
audrey avatar

audrey

New Zenner

Join Date:
Dec 2008
Posts:
15
Plugin Contributions:
0

Re: Order Delivery Date Support Thread

Thanks again! I added the parenthesis and tested the site at every "chunk" edit. The site is working with no issues now. However, the delivery date picker is still showing up even though I've selected an overseas address.

Is there some part of the code for the observer file that I'm not editing right? So far I've just cut and pasted wholesale.

mc12345678:

Looking at it again, in first "chunk"
this:

if (!isset($_SESSION['sendto']) return true;
> is missing a closing paranthesis:
> ```
    if (!isset($_SESSION['sendto'])) return true;
29 Jan 2018, 12:27 AM
#434
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Order Delivery Date Support Thread

Audrey,

Okay, had a chance to look this over and try to use it. As said it was untested. There were parts that worked, and parts that did not... For example, if the location were set to national and an international address were chosen, then the customer would not be able to check out and would be stuck in a loop. That has been corrected in the following commit that incorporates this entire concept.

Note, it defaults to accept the date from both national and international, then if one of those is chosen, the date box is defaulted to display always. To change either/both of these settings such that the date box only displays for orders that really need them, modify the settings in the includes/extra_datafiles/order_delivery_date_location.php file.

https://github.com/mc12345678/order-delivery-date/tree/locality

The specific commit where the changes are shown is: https://github.com/mc12345678/order-delivery-date/commit/a228fb7209170127a4b046d14a35349c8124621b

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

29 Jan 2018, 3:41 PM
#435
audrey avatar

audrey

New Zenner

Join Date:
Dec 2008
Posts:
15
Plugin Contributions:
0

Re: Order Delivery Date Support Thread

Ok, I think that flew right over my head. But thank you MC12345678 for taking the time to walk me through this. I'll try my best to follow. Really appreciate your time!

29 Jan 2018, 4:15 PM
#436
audrey avatar

audrey

New Zenner

Join Date:
Dec 2008
Posts:
15
Plugin Contributions:
0

Re: Order Delivery Date Support Thread

Ok wow, I can't believe how easy your instructions were. I followed it to a T and the mod is working beautifully now. Thank you so much :)

For those looking to have the Delivery Date Picker show up only for local orders and not international orders, and if you have been following the thread, all I had to do was:

(1) edit the file -----> includes/extra_datafiles/order_delivery_date_location.php
with this define set to "national" instead of "both". like this:

<?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', 'national'); // values are 'national', 'international', or 'both'

(2) THEN, make the changes to the file -----> includes/classes/observers/auto.order_delivery_date_observer.php
with the new edits in this link ------> https://github.com/mc12345678/order-delivery-date/commit/a228fb7209170127a4b046d14a35349c8124621b

Psyched that this worked out. Thank you again MC12345678!

29 Jan 2018, 4:41 PM
#437
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Order Delivery Date Support Thread

Glad that worked out for you. It was an interesting issue to try to address, required some reworking of the code to be able to detect the delivery address.

Note: a separate setting to consider and to achieve the goal of item 1 above (or to always display the field) is that within the same file there is an additional define that should be considered. As provided it defaults to false, but if set to true then it would always display the field:

define('ORDER_DELIVERY_DATE_DISPLAY_ALWAYS', 'false');

Now though I just realized an additional "arrangement" of options. The text indicating that the delivery date for a national delivery is required but is optional for an international delivery. The code (checkout process) already operates in this manner, but the displayed text does not.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

29 Jan 2018, 4:52 PM
#438
audrey avatar

audrey

New Zenner

Join Date:
Dec 2008
Posts:
15
Plugin Contributions:
0

Re: Order Delivery Date Support Thread

Do you mean the text that is actually displayed on the website? I had no issue with that at all following the above.

In fact, I went a step further and applied the code you gave (below) for the template files to :

includes/templates/YOUR_TEMPLATE/templates/tpl_checkout_shipping_confirmation.php

just so it doesn't pop up there as well and confuse the customer, being that they did not get the chance to select a date in the checkout payment step.

<!-- 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 -->

As for this below, I omitted it and the mod still achieves the intended outcome. It's a safeguard I suppose and handy to have if you want to always have it on/off. How interesting!

define('ORDER_DELIVERY_DATE_DISPLAY_ALWAYS', 'false'); 
29 Jan 2018, 10:28 PM
#439
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Order Delivery Date Support Thread

Thank you for pointing out that part as well, will update the code accordingly.

You wouldn't have seen the issue I described based on your desired usage. The text display issue to which I was referring would be seen in the following "complex" condition:
Location to require entry set to something other than both.
Display of the field set to always (true).
The order_delivery_date identified as required (configuration->minimums area with a non-zero value)
And the purchaser having entered a shipto address that is opposite of the location setting.

When the checkout_shipping page is displayed, the text "above" the date field would be displayed as required, but the user could click through without entering anything because the existing internal checkout logic doesn't require the date to be entered for that condition.

The text should actually display as the date being optional at that point.

So instead of this logic:

defined('MIN_DISPLAY_DELIVERY_DATE') &&  MIN_DISPLAY_DELIVERY_DATE > 0) ?  TABLE_HEADING_DELIVERY_DATE_IS_REQUIRED :  TABLE_HEADING_DELIVERY_DATE_IS_OPTIONAL

It would be:

defined('MIN_DISPLAY_DELIVERY_DATE') &&  MIN_DISPLAY_DELIVERY_DATE > 0 [b]&& (method_exists($zcObserverOrderDeliveryDateObserver, 'display_delivery_date') ? $zcObserverOrderDeliveryDateObserver->display_delivery_date($order) : true)[/b]) ?  TABLE_HEADING_DELIVERY_DATE_IS_REQUIRED :  TABLE_HEADING_DELIVERY_DATE_IS_OPTIONAL

The addition, bolded above, will toggle the required to optional text in the condition described above.

Ideally, perhaps an additional function would be added to the code to identify that the date is required as compared to optional considering that logic is basically used in more than one place (internal to the observer and then in the template files).

On some other things, I see that the branch I set aside for this functionality did not end up with all of the code and that your previous post addressed that by reference to the other commit where the additional code ended up. I'm working to correct that issue and to have all of the added functionality to support this in one commit instead of spread out. I didn't see the template file that was specifically referenced, but am thinking that it was intended to be the checkout_confirmation not the checkout_shipping_confirmation page. Need to look a little further, but makes me wonder if anything further downstram needs to be modified such as the email, the admin orders, etc... I thought though that there was enough present to allow end user/installer to modify the output relatively consistently.

Btw, since I started writing this, I have updated the locality branch to incorporate the required/optional swap and properly pulled in the display_delivery_date function that accidentally was captured in a later commit instead of where it should have been.

Unfortunately, with the complexity that this module is beginning to have, it is almost as if a separate configuration area may be necessary to support the additional features which may not be a bad thing considering it would then make it easier to modify the operation of the script when/where it is used. Especially if the previously posted method of incorporating a time option is used (instead of using a script based method of incorporating a time picker.)

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

30 Jan 2018, 7:04 PM
#440
jkenwell avatar

jkenwell

New Zenner

Join Date:
Dec 2016
Location:
Edmonton
Posts:
25
Plugin Contributions:
0

Re: Order Delivery Date Support Thread

Does anyone here know if a module is available that uses (adjustable) time slots instead of calendar days? (It doesn't have to be free, and it would sure remove a lot of headaches I currently have trying to cobble something together through the checkout).

What I need is a module that lets me assign "so many orders for this slot" (or "so many order-$$$ for this slot" or a combination of both), and that lets me variate the size of the slot (e.g. from 2 hours to 3 or 4 hours), and delivery slots auto-closing after a pre-determined cut-off (e.g. at 10 am the delivery slot for 2pm-4pm disappears or is disabled). Ideally there would be a selectable date, with the available slots appearing after the delivery date has been chosen.

Thanks in advance.