Page 44 of 54 FirstFirst ... 344243444546 ... LastLast
Results 431 to 440 of 535
  1. #431
    Join Date
    Dec 2008
    Posts
    15
    Plugin Contributions
    0

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

    Code:
        // 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) {
    Quote Originally Posted by mc12345678 View Post
    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...

  2. #432
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default Re: Order Delivery Date Support Thread

    Looking at it again, in first "chunk"
    this:
    Code:
        if (!isset($_SESSION['sendto']) return true;
    is missing a closing paranthesis:
    Code:
        if (!isset($_SESSION['sendto'])) return true;
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #433
    Join Date
    Dec 2008
    Posts
    15
    Plugin Contributions
    0

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

    Quote Originally Posted by mc12345678 View Post
    Looking at it again, in first "chunk"
    this:
    Code:
        if (!isset($_SESSION['sendto']) return true;
    is missing a closing paranthesis:
    Code:
        if (!isset($_SESSION['sendto'])) return true;

  4. #434
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default 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-.../tree/locality

    The specific commit where the changes are shown is: https://github.com/mc12345678/order-...35349c8124621b
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #435
    Join Date
    Dec 2008
    Posts
    15
    Plugin Contributions
    0

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

  6. #436
    Join Date
    Dec 2008
    Posts
    15
    Plugin Contributions
    0

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

    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', '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-...35349c8124621b

    Psyched that this worked out. Thank you again MC12345678!
    Last edited by audrey; 29 Jan 2018 at 05:18 PM.

  7. #437
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default 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:
    Code:
    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...

  8. #438
    Join Date
    Dec 2008
    Posts
    15
    Plugin Contributions
    0

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

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

    Code:
    define('ORDER_DELIVERY_DATE_DISPLAY_ALWAYS', 'false');

  9. #439
    Join Date
    Jul 2012
    Posts
    16,732
    Plugin Contributions
    17

    Default 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:
    Code:
    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:
    Code:
    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
    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...

  10. #440
    Join Date
    Dec 2016
    Location
    Edmonton
    Posts
    25
    Plugin Contributions
    0

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

 

 
Page 44 of 54 FirstFirst ... 344243444546 ... LastLast

Similar Threads

  1. order delivery date addon - date not showing in checkout
    By jagall in forum Addon Shipping Modules
    Replies: 4
    Last Post: 19 Oct 2017, 09:09 PM
  2. JK Order Exporter - Support Thread
    By eVelt in forum All Other Contributions/Addons
    Replies: 4
    Last Post: 26 Sep 2015, 07:06 AM
  3. v151 Order Delivery date on Product Info Page
    By nicksab in forum General Questions
    Replies: 0
    Last Post: 30 Dec 2013, 03:23 AM
  4. Support Thread for JS Date Picker for options
    By eVelt in forum All Other Contributions/Addons
    Replies: 17
    Last Post: 5 Dec 2013, 05:44 AM
  5. Order Delivery Date Mod
    By fagriffin in forum Addon Shipping Modules
    Replies: 1
    Last Post: 11 Oct 2008, 04:50 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR