Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22
  1. #11
    Join Date
    Jan 2007
    Location
    Illinois, USA
    Posts
    312
    Plugin Contributions
    0

    Default Re: Error log generated when adding items to cart

    Quote Originally Posted by DrByte View Post
    Interesting.

    I've never used that mod. Good to know it has "issues".

    It did it on another site too... of the 5 active sites, using the same version of ZC and the same combination of add-ons, 2 of the 5 had the same altered file. The other 3 were un-altered. It may be the order of sequence that triggered the alteration.
    NTO: building a better network thru collaboration
    www.needtoorder.com | www.coffeewitheinstein.com

  2. #12
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,492
    Plugin Contributions
    88

    Default Re: Error log generated when adding items to cart

    Quote Originally Posted by Carbonless View Post
    It did it on another site too... of the 5 active sites, using the same version of ZC and the same combination of add-ons, 2 of the 5 had the same altered file. The other 3 were un-altered. It may be the order of sequence that triggered the alteration.
    Quote Originally Posted by Carbonless View Post
    I have found that in the my template file: /includes/templates/MYTEMPLATE/templates/tpl_shopping_cart_default.php that when I CLONED the template, it changed line 94 from:
    Code:
    <a href="<?php echo $product['linkProductsName']; ?>"><?php echo $product['productsImage']; ?><?php echo $product['productsName'] . '' . $product['flagStockCheck'] . ''; ?></a>
    to this:

    Code:
    <a href="<?php echo $product['../../MYTEMPLATE/templates/linkProductsName']; ?>"><?php echo $product['productsImage']; ?><?php echo $product['productsName'] . '' . $product['flagStockCheck'] . ''; ?></a>
    I changed it back to the default for the ZCA Bootstrap 4 default and it fixed the linking problem.
    The "Clone a Template" plugin makes no changes to the template-related files, it simply makes a copy/clone of the original template into a newly-named one. I've got no idea where those unwanted changes are being injected.

  3. #13
    Join Date
    Jan 2007
    Location
    Illinois, USA
    Posts
    312
    Plugin Contributions
    0

    Default Re: Error log generated when adding items to cart

    Quote Originally Posted by lat9 View Post
    The "Clone a Template" plugin makes no changes to the template-related files, it simply makes a copy/clone of the original template into a newly-named one. I've got no idea where those unwanted changes are being injected.


    My apologies, an assumption on my part. I love the mod. Not sure of the source of injection, but identifying the fix for LINK IN CART was identified. Thanks Lat9.
    NTO: building a better network thru collaboration
    www.needtoorder.com | www.coffeewitheinstein.com

  4. #14
    Join Date
    Jan 2007
    Location
    Illinois, USA
    Posts
    312
    Plugin Contributions
    0

    Default Re: Error log generated when adding items to cart

    This has been addressed and a fix has been posted here
    NTO: building a better network thru collaboration
    www.needtoorder.com | www.coffeewitheinstein.com

  5. #15
    Join Date
    Jan 2007
    Location
    Illinois, USA
    Posts
    312
    Plugin Contributions
    0

    Default Re: Error log generated when adding items to cart

    After making this fix - I made a status update, and I was greeted with the following error log:

    Code:
    [09-Jan-2021 13:17:51 America/Chicago] Request URI:  /XXXXX/index.php?cmd=orders&cID=1&page=1&oID=37035&action=update_order,  IP address: xxxxx
    #1  zen_update_orders_history() called at [/XXXXX/orders.php:179]
    #2  require(/XXXXX/orders.php) called at [/XXXXX/index.php:11]
    --> PHP Warning: Invalid argument supplied for foreach() in /includes/functions/functions_osh_update.php on line 117.
    The update did post, and all "loks" well from the admin orders.
    NTO: building a better network thru collaboration
    www.needtoorder.com | www.coffeewitheinstein.com

  6. #16
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: Error log generated when adding items to cart

    Quote Originally Posted by Carbonless View Post
    After making this fix - I made a status update, and I was greeted with the following error log:

    Code:
    [09-Jan-2021 13:17:51 America/Chicago] Request URI:  /XXXXX/index.php?cmd=orders&cID=1&page=1&oID=37035&action=update_order,  IP address: xxxxx
    #1  zen_update_orders_history() called at [/XXXXX/orders.php:179]
    #2  require(/XXXXX/orders.php) called at [/XXXXX/index.php:11]
    --> PHP Warning: Invalid argument supplied for foreach() in /includes/functions/functions_osh_update.php on line 117.
    The update did post, and all "loks" well from the admin orders.
    There's no foreach in Zen Cart's 1.5.7 version of the catalog file: includes/functions/functions_osh_update.php... How has this file been modified and by what? I went back to look at ZC 1.5.6 even and it doesn't have a foreach function in it either..
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #17
    Join Date
    Jan 2007
    Location
    Illinois, USA
    Posts
    312
    Plugin Contributions
    0

    Default Re: Error log generated when adding items to cart

    Quote Originally Posted by mc12345678 View Post
    There's no foreach in Zen Cart's 1.5.7 version of the catalog file: includes/functions/functions_osh_update.php... How has this file been modified and by what? I went back to look at ZC 1.5.6 even and it doesn't have a foreach function in it either..

    Great question! This was a fresh install with the following mods added:
    php vers 7.3
    with Shopping cart Reminder
    Edit Orders
    TY Package tracker
    Email Export
    Clone Template
    ZCA Boot 4
    and Order Comment Boiler plate
    NTO: building a better network thru collaboration
    www.needtoorder.com | www.coffeewitheinstein.com

  8. #18
    Join Date
    Jan 2007
    Location
    Illinois, USA
    Posts
    312
    Plugin Contributions
    0

    Default Re: Error log generated when adding items to cart

    Quote Originally Posted by mc12345678 View Post
    There's no foreach in Zen Cart's 1.5.7 version of the catalog file: includes/functions/functions_osh_update.php... How has this file been modified and by what? I went back to look at ZC 1.5.6 even and it doesn't have a foreach function in it either..

    It appears that the TY Tracking mod may be responsible. Here is the complete code surrounding the call fo in the file includes/functions/functions_osh_update.php

    Code:
                // Begin Ty Package Tracker
                
                 if (is_array($track_id)) {
                foreach($track_id as $id => $track) {
                    $osh_sql['track_id' . $id] = zen_db_input($track);
                }
               }
                $notify_comments = '';
                if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) {
                    if (zen_not_null($comments)) {
                        $notify_comments = EMAIL_TEXT_COMMENTS_UPDATE . $comments . "\n\n";
                    }
                    else if (zen_not_null($track_id)) {
                        $notify_comments = EMAIL_TEXT_COMMENTS_TRACKING_UPDATE . "\n\n";
                        $comment = EMAIL_TEXT_COMMENTS_TRACKING_UPDATE;
                    }
                    foreach($track_id as $id => $track) {
                        if(zen_not_null($track) && constant('CARRIER_STATUS_' . $id) == 'True') {
                            $notify_comments .= "Your " . constant('CARRIER_NAME_' . $id) . " Tracking ID is " . $track . " \n<br /><a href=" . constant('CARRIER_LINK_' . $id) . $track . ">Click here</a> to track your package. \n<br />If the above link does not work, copy the following URL address and paste it into your Web browser. \n<br />" . constant('CARRIER_LINK_' . $id) . $track . "\n\n<br /><br />It may take up to 24 hours for the tracking information to appear on the website." . "\n<br />";
                        }
                    }
                    $notify_comments = "\n".$notify_comments."\n";
                    unset($id); unset($track);
                }
                // End Ty Package Tracker
    NTO: building a better network thru collaboration
    www.needtoorder.com | www.coffeewitheinstein.com

  9. #19
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Error log generated when adding items to cart

    Quote Originally Posted by Carbonless View Post
    After making this fix - I made a status update, and I was greeted with the following error log:

    Code:
    [09-Jan-2021 13:17:51 America/Chicago] Request URI:  /XXXXX/index.php?cmd=orders&cID=1&page=1&oID=37035&action=update_order,  IP address: xxxxx
    #1  zen_update_orders_history() called at [/XXXXX/orders.php:179]
    #2  require(/XXXXX/orders.php) called at [/XXXXX/index.php:11]
    --> PHP Warning: Invalid argument supplied for foreach() in /includes/functions/functions_osh_update.php on line 117.
    The update did post, and all "loks" well from the admin orders.
    Quote Originally Posted by Carbonless View Post
    It appears that the TY Tracking mod may be responsible. Here is the complete code surrounding the call fo in the file includes/functions/functions_osh_update.php

    Code:
                // Begin Ty Package Tracker
                
                 if (is_array($track_id)) {
                foreach($track_id as $id => $track) {
                    $osh_sql['track_id' . $id] = zen_db_input($track);
                }
               }
                $notify_comments = '';
                if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) {
                    if (zen_not_null($comments)) {
                        $notify_comments = EMAIL_TEXT_COMMENTS_UPDATE . $comments . "\n\n";
                    }
                    else if (zen_not_null($track_id)) {
                        $notify_comments = EMAIL_TEXT_COMMENTS_TRACKING_UPDATE . "\n\n";
                        $comment = EMAIL_TEXT_COMMENTS_TRACKING_UPDATE;
                    }
                    foreach($track_id as $id => $track) {
                        if(zen_not_null($track) && constant('CARRIER_STATUS_' . $id) == 'True') {
                            $notify_comments .= "Your " . constant('CARRIER_NAME_' . $id) . " Tracking ID is " . $track . " \n<br /><a href=" . constant('CARRIER_LINK_' . $id) . $track . ">Click here</a> to track your package. \n<br />If the above link does not work, copy the following URL address and paste it into your Web browser. \n<br />" . constant('CARRIER_LINK_' . $id) . $track . "\n\n<br /><br />It may take up to 24 hours for the tracking information to appear on the website." . "\n<br />";
                        }
                    }
                    $notify_comments = "\n".$notify_comments."\n";
                    unset($id); unset($track);
                }
                // End Ty Package Tracker
    I'm not sure why it says that error is happening on line 117, but since you say you're using v1.5.7, you could try this variant of function_osh_update.php:
    Code:
    <?php
    /**
     * functions_osh_update
     *
     * @copyright Copyright 2003-2020 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: DrByte 2020 Apr 12 Modified in v1.5.7 $
     */
    if (!defined('IS_ADMIN_FLAG')) {
        exit('Invalid Access');
    }
    
    
    // -----
    // A common-use (both storefront and admin) that updates an order's status-history.
    //
    // Inputs:
    // - $order_id ................ The order for which the status record is to be created
    // - $message ................. The comments associated with the history record, if non-blank.
    // - $updated_by .............. If non-null, the specified value will be used for the like-named field.  Otherwise,
    //                              the value will be calculated based on some defaults.
    // - $orders_new_status ....... The orders_status value for the update.  If set to -1, no change in the status value was detected.
    // - $notify_customer ......... Identifies whether the history record is sent via email and visible to the customer via the "account_history_info" page:
    //                               0 ... No emails sent, customer can view on "account_history_info"
    //                               1 ... Email sent, customer can view on "account_history_info"
    //                              -1 ... No emails sent, comments and status-change hidden from customer view
    //                              -2 ... Email sent only to configured admins; status-change hidden from customer view
    // - $email_include_message ... Identifies whether (true) or not (false) to include the status message ($osh_additional_comments) in any email sent.
    // - $email_subject ........... If specified, overrides the default email subject line.
    // - $send_extra_mails_to ..... If specified, overrides the "standard" database settings SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS and
    //                              SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO.
    //
    // Returns:
    // - $osh_id ............ A value > 0 if the record has been written (the orders_status_history_id number)
    //                        -2 if no order record was found for the specified $orders_id
    //                        -1 if no status change was detected (i.e. no record written).
    //
    function zen_update_orders_history($orders_id, $message = '', $updated_by = null, $orders_new_status = -1, $notify_customer = -1, $email_include_message = true, $email_subject = '', $send_extra_emails_to = '') 
    {
        global $osh_sql, $osh_additional_comments;
        
        // -----
        // Initialize return value to indicate no change and sanitize various inputs.
        //
        $osh_id = -1;
        $orders_id = (int)$orders_id;
        $message = (string)$message;
        $email_subject = (string)$email_subject;
        $send_extra_emails_to = (string)$send_extra_emails_to;
        
        $osh_info = $GLOBALS['db']->ExecuteNoCache(
            "SELECT customers_name, customers_email_address, orders_status, date_purchased 
               FROM " . TABLE_ORDERS . " 
              WHERE orders_id = $orders_id
              LIMIT 1" 
        );
        if ($osh_info->EOF) {
            $osh_id = -2; 
        } else {
            // -----
            // Determine the message to be included in any email(s) sent.  If an observer supplies an additional
            // message, that text is appended to the message supplied on the function's call.
            //
            $message = stripslashes($message);
            $email_message = '';
            if ($email_include_message === true) {
                $email_message = $message;
                if (empty($osh_additional_comments)) {
                    $osh_additional_comments = '';
                }
                $GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_PRE_EMAIL', array('message' => $message), $osh_additional_comments);
                if (!empty($osh_additional_comments)) {
                    if (!empty($email_message)) {
                        $email_message .= "\n\n";
                    }
                    $email_message .= (string)$osh_additional_comments;
                }
                if (!empty($email_message)) {
                    $email_message = OSH_EMAIL_TEXT_COMMENTS_UPDATE . $email_message . "\n\n";
                }
            }
            
            $orders_current_status = $osh_info->fields['orders_status'];
            $orders_new_status = (int)$orders_new_status;
            if (($orders_new_status != -1 && $orders_current_status != $orders_new_status) || !empty($email_message)) {
                if ($orders_new_status == -1) {
                    $orders_new_status = $orders_current_status;
                }
                $GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_STATUS_VALUES', array('orders_id' => $orders_id, 'new' => $orders_new_status, 'old' => $orders_current_status));
            
                $GLOBALS['db']->Execute( 
                    "UPDATE " . TABLE_ORDERS . " 
                        SET orders_status = $orders_new_status,
                            last_modified = now() 
                      WHERE orders_id = $orders_id
                      LIMIT 1" 
                );
            
                $notify_customer = ($notify_customer == 1 || $notify_customer == -1 || $notify_customer == -2) ? $notify_customer : 0;
                // Begin Ty Package Tracker
                $track_id = array();
                $track_id = zen_db_prepare_input($_POST['track_id']);
                $tracking_comments = '';
                if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) {
                    if (zen_not_null($comments)) {
                        $tracking_comments = EMAIL_TEXT_COMMENTS_UPDATE . $comments . "\n\n";
                    }
                    else if (zen_not_null($track_id)) {
                        $tracking_comments = EMAIL_TEXT_COMMENTS_TRACKING_UPDATE . "\n\n";
                        $comment = EMAIL_TEXT_COMMENTS_TRACKING_UPDATE;
                    }
                    if (is_array($track_id)) foreach($track_id as $id => $track) {
                        if(zen_not_null($track) && constant('CARRIER_STATUS_' . $id) == 'True') {
                            $tracking_comments .= "Your " . constant('CARRIER_NAME_' . $id) . " Tracking ID is " . $track . " \n<br /><a href=" . constant('CARRIER_LINK_' . $id) . $track . ">Click here</a> to track your package. \n<br />If the above link does not work, copy the following URL address and paste it into your Web browser. \n<br />" . constant('CARRIER_LINK_' . $id) . $track . "\n\n<br /><br />It may take up to 24 hours for the tracking information to appear on the website." . "\n<br />";
                        }
                    }
                    $tracking_comments = "\n".$tracking_comments."\n";
                    unset($id); unset($track);
                }
                // End Ty Package Tracker          
                if ($notify_customer == 1 || $notify_customer == -2) {
                    $new_orders_status_name = zen_get_orders_status_name($orders_new_status);
                    if ($new_orders_status_name == '') {
                        $new_orders_status_name = 'N/A';
                    }
    
    
                    if ($orders_new_status != $orders_current_status) {
                        $status_text = OSH_EMAIL_TEXT_STATUS_UPDATED;
                        $status_value_text = sprintf(OSH_EMAIL_TEXT_STATUS_CHANGE, zen_get_orders_status_name($orders_current_status), $new_orders_status_name);
                    } else {
                        $status_text = OSH_EMAIL_TEXT_STATUS_NO_CHANGE;
                        $status_value_text = sprintf(OSH_EMAIL_TEXT_STATUS_LABEL, $new_orders_status_name);
                    }
                    
                    //send emails
                    $email_text =
                        EMAIL_SALUTATION . ' ' . $osh_info->fields['customers_name'] . ', ' . "\n\n" .
                        STORE_NAME . ' ' . OSH_EMAIL_TEXT_ORDER_NUMBER . ' ' . $orders_id . "\n\n" .
                        OSH_EMAIL_TEXT_INVOICE_URL . ' ' . zen_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, "order_id=$orders_id", 'SSL') . "\n\n" .
                        OSH_EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($osh_info->fields['date_purchased']) . "\n\n" .
                        strip_tags($email_message.$tracking_comments) .
                        $status_text . $status_value_text .
                        OSH_EMAIL_TEXT_STATUS_PLEASE_REPLY;
               
                    // Add in store specific order message
                    $email_order_message = defined('EMAIL_ORDER_UPDATE_MESSAGE') ? constant('EMAIL_ORDER_UPDATE_MESSAGE') : '';
                    $GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_SET_ORDER_UPDATE_MESSAGE', $orders_id, $email_order_message); 
                    if (!empty($email_order_message)) {
                     $email_text .= "\n\n" . $email_order_message . "\n\n";
                    }
                    $html_msg['EMAIL_ORDER_UPDATE_MESSAGE'] = $email_order_message;
    
    
                    $html_msg['EMAIL_SALUTATION'] = EMAIL_SALUTATION;
                    $html_msg['EMAIL_CUSTOMERS_NAME']    = $osh_info->fields['customers_name'];
                    $html_msg['EMAIL_TEXT_ORDER_NUMBER'] = OSH_EMAIL_TEXT_ORDER_NUMBER . ' ' . $orders_id;
                    $html_msg['EMAIL_TEXT_INVOICE_URL']  = '<a href="' . zen_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, "order_id=$orders_id", 'SSL') .'">' . str_replace(':', '', OSH_EMAIL_TEXT_INVOICE_URL) . '</a>';
                    $html_msg['EMAIL_TEXT_DATE_ORDERED'] = OSH_EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($osh_info->fields['date_purchased']);
                    // Begin Ty Package Tracker
                    $html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br($email_message.$tracking_comments);
                    // End Ty Package Tracker
                    $html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace("\n", '', $status_text);
                    $html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace("\n", '', $status_value_text);
                    $html_msg['EMAIL_TEXT_NEW_STATUS'] = $new_orders_status_name;
                    $html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace("\n", '', OSH_EMAIL_TEXT_STATUS_PLEASE_REPLY);
                    $html_msg['EMAIL_PAYPAL_TRANSID'] = '';
                    
                    if (empty($email_subject)) {
                        $email_subject = OSH_EMAIL_TEXT_SUBJECT . ' #' . $orders_id;
                    }
    
    
                    if ($notify_customer == 1) { 
                        zen_mail($osh_info->fields['customers_name'], $osh_info->fields['customers_email_address'], $email_subject, $email_text, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status');
                    } 
    
    
                    // PayPal Trans ID, if any
                    $result = $GLOBALS['db']->Execute(
                        "SELECT txn_id, parent_txn_id 
                           FROM " . TABLE_PAYPAL . " 
                          WHERE order_id = $orders_id
                       ORDER BY last_modified DESC, date_added DESC, parent_txn_id DESC, paypal_ipn_id DESC"
                    );
                    if (!$result->EOF) {
                        $email_text .= "\n\n" . ' PayPal Trans ID: ' . $result->fields['txn_id'];
                        $html_msg['EMAIL_PAYPAL_TRANSID'] = $result->fields['txn_id'];
                    }
    
    
                    //send extra emails
                    if (empty($send_extra_emails_to) && SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS == '1') {
                        $send_extra_emails_to = (string)SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO;
                    }
                    if (!empty($send_extra_emails_to)) {
                        zen_mail('', $send_extra_emails_to, SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_SUBJECT . ' ' . $email_subject, $email_text, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status_extra');
                    }
                }
        
                if (empty($updated_by)) {
                    if (IS_ADMIN_FLAG === true && isset($_SESSION['admin_id'])) {
                        $updated_by = zen_updated_by_admin();
                    } elseif (IS_ADMIN_FLAG === false && isset($_SESSION['customers_id'])) {
                        $updated_by = '';
                    } else {
                        $updated_by = 'N/A';
                    }
                }
        
                $osh_sql = array(
                    'orders_id' => $orders_id,
                    'orders_status_id' => $orders_new_status,
                    'date_added' => 'now()',
                    'customer_notified' => $notify_customer,
                    'comments' => $message,
                    'updated_by' => $updated_by
                );
                // Begin Ty Package Tracker       
                if (is_array($track_id)) foreach($track_id as $id => $track) {
                    $osh_sql['track_id' . $id] = zen_db_input($track);
                }
                // End Ty Package Tracker
                $GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_BEFORE_INSERT', array(), $osh_sql);
        
                zen_db_perform (TABLE_ORDERS_STATUS_HISTORY, $osh_sql);
                $osh_id = $GLOBALS['db']->Insert_ID();
            }    
        }
        return $osh_id;
    }
    Last edited by DrByte; 12 Jan 2021 at 02:35 AM. Reason: fix copy/paste issue
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  10. #20
    Join Date
    Jan 2007
    Location
    Illinois, USA
    Posts
    312
    Plugin Contributions
    0

    Default Re: Error log generated when adding items to cart

    Quote Originally Posted by DrByte View Post
    I'm not sure why it says that error is happening on line 117, but since you say you're using v1.5.7, you could try this variant of function_osh_update.php:
    Code:
    <?php/**
     * functions_osh_update
     *
     * @copyright Copyright 2003-2020 Zen Cart Development Team
     * @copyright Portions Copyright 2003 osCommerce
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: DrByte 2020 Apr 12 Modified in v1.5.7 $
     */
    if (!defined('IS_ADMIN_FLAG')) {
        exit('Invalid Access');
    }
    
    
    // -----
    // A common-use (both storefront and admin) that updates an order's status-history.
    //
    // Inputs:
    // - $order_id ................ The order for which the status record is to be created
    // - $message ................. The comments associated with the history record, if non-blank.
    // - $updated_by .............. If non-null, the specified value will be used for the like-named field.  Otherwise,
    //                              the value will be calculated based on some defaults.
    // - $orders_new_status ....... The orders_status value for the update.  If set to -1, no change in the status value was detected.
    // - $notify_customer ......... Identifies whether the history record is sent via email and visible to the customer via the "account_history_info" page:
    //                               0 ... No emails sent, customer can view on "account_history_info"
    //                               1 ... Email sent, customer can view on "account_history_info"
    //                              -1 ... No emails sent, comments and status-change hidden from customer view
    //                              -2 ... Email sent only to configured admins; status-change hidden from customer view
    // - $email_include_message ... Identifies whether (true) or not (false) to include the status message ($osh_additional_comments) in any email sent.
    // - $email_subject ........... If specified, overrides the default email subject line.
    // - $send_extra_mails_to ..... If specified, overrides the "standard" database settings SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS and
    //                              SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO.
    //
    // Returns:
    // - $osh_id ............ A value > 0 if the record has been written (the orders_status_history_id number)
    //                        -2 if no order record was found for the specified $orders_id
    //                        -1 if no status change was detected (i.e. no record written).
    //
    function zen_update_orders_history($orders_id, $message = '', $updated_by = null, $orders_new_status = -1, $notify_customer = -1, $email_include_message = true, $email_subject = '', $send_extra_emails_to = '') 
    {
        global $osh_sql, $osh_additional_comments;
        
        // -----
        // Initialize return value to indicate no change and sanitize various inputs.
        //
        $osh_id = -1;
        $orders_id = (int)$orders_id;
        $message = (string)$message;
        $email_subject = (string)$email_subject;
        $send_extra_emails_to = (string)$send_extra_emails_to;
        
        $osh_info = $GLOBALS['db']->ExecuteNoCache(
            "SELECT customers_name, customers_email_address, orders_status, date_purchased 
               FROM " . TABLE_ORDERS . " 
              WHERE orders_id = $orders_id
              LIMIT 1" 
        );
        if ($osh_info->EOF) {
            $osh_id = -2; 
        } else {
            // -----
            // Determine the message to be included in any email(s) sent.  If an observer supplies an additional
            // message, that text is appended to the message supplied on the function's call.
            //
            $message = stripslashes($message);
            $email_message = '';
            if ($email_include_message === true) {
                $email_message = $message;
                if (empty($osh_additional_comments)) {
                    $osh_additional_comments = '';
                }
                $GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_PRE_EMAIL', array('message' => $message), $osh_additional_comments);
                if (!empty($osh_additional_comments)) {
                    if (!empty($email_message)) {
                        $email_message .= "\n\n";
                    }
                    $email_message .= (string)$osh_additional_comments;
                }
                if (!empty($email_message)) {
                    $email_message = OSH_EMAIL_TEXT_COMMENTS_UPDATE . $email_message . "\n\n";
                }
            }
            
            $orders_current_status = $osh_info->fields['orders_status'];
            $orders_new_status = (int)$orders_new_status;
            if (($orders_new_status != -1 && $orders_current_status != $orders_new_status) || !empty($email_message)) {
                if ($orders_new_status == -1) {
                    $orders_new_status = $orders_current_status;
                }
                $GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_STATUS_VALUES', array('orders_id' => $orders_id, 'new' => $orders_new_status, 'old' => $orders_current_status));
            
                $GLOBALS['db']->Execute( 
                    "UPDATE " . TABLE_ORDERS . " 
                        SET orders_status = $orders_new_status,
                            last_modified = now() 
                      WHERE orders_id = $orders_id
                      LIMIT 1" 
                );
            
                $notify_customer = ($notify_customer == 1 || $notify_customer == -1 || $notify_customer == -2) ? $notify_customer : 0;
                // Begin Ty Package Tracker
                $track_id = array();
                $track_id = zen_db_prepare_input($_POST['track_id']);
                $tracking_comments = '';
                if (isset($_POST['notify_comments']) && ($_POST['notify_comments'] == 'on')) {
                    if (zen_not_null($comments)) {
                        $tracking_comments = EMAIL_TEXT_COMMENTS_UPDATE . $comments . "\n\n";
                    }
                    else if (zen_not_null($track_id)) {
                        $tracking_comments = EMAIL_TEXT_COMMENTS_TRACKING_UPDATE . "\n\n";
                        $comment = EMAIL_TEXT_COMMENTS_TRACKING_UPDATE;
                    }
                    if (is_array($track_id)) foreach($track_id as $id => $track) {
                        if(zen_not_null($track) && constant('CARRIER_STATUS_' . $id) == 'True') {
                            $tracking_comments .= "Your " . constant('CARRIER_NAME_' . $id) . " Tracking ID is " . $track . " \n<br /><a href=" . constant('CARRIER_LINK_' . $id) . $track . ">Click here</a> to track your package. \n<br />If the above link does not work, copy the following URL address and paste it into your Web browser. \n<br />" . constant('CARRIER_LINK_' . $id) . $track . "\n\n<br /><br />It may take up to 24 hours for the tracking information to appear on the website." . "\n<br />";
                        }
                    }
                    $tracking_comments = "\n".$tracking_comments."\n";
                    unset($id); unset($track);
                }
                // End Ty Package Tracker          
                if ($notify_customer == 1 || $notify_customer == -2) {
                    $new_orders_status_name = zen_get_orders_status_name($orders_new_status);
                    if ($new_orders_status_name == '') {
                        $new_orders_status_name = 'N/A';
                    }
    
    
                    if ($orders_new_status != $orders_current_status) {
                        $status_text = OSH_EMAIL_TEXT_STATUS_UPDATED;
                        $status_value_text = sprintf(OSH_EMAIL_TEXT_STATUS_CHANGE, zen_get_orders_status_name($orders_current_status), $new_orders_status_name);
                    } else {
                        $status_text = OSH_EMAIL_TEXT_STATUS_NO_CHANGE;
                        $status_value_text = sprintf(OSH_EMAIL_TEXT_STATUS_LABEL, $new_orders_status_name);
                    }
                    
                    //send emails
                    $email_text =
                        EMAIL_SALUTATION . ' ' . $osh_info->fields['customers_name'] . ', ' . "\n\n" .
                        STORE_NAME . ' ' . OSH_EMAIL_TEXT_ORDER_NUMBER . ' ' . $orders_id . "\n\n" .
                        OSH_EMAIL_TEXT_INVOICE_URL . ' ' . zen_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, "order_id=$orders_id", 'SSL') . "\n\n" .
                        OSH_EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($osh_info->fields['date_purchased']) . "\n\n" .
                        strip_tags($email_message.$tracking_comments) .
                        $status_text . $status_value_text .
                        OSH_EMAIL_TEXT_STATUS_PLEASE_REPLY;
               
                    // Add in store specific order message
                    $email_order_message = defined('EMAIL_ORDER_UPDATE_MESSAGE') ? constant('EMAIL_ORDER_UPDATE_MESSAGE') : '';
                    $GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_SET_ORDER_UPDATE_MESSAGE', $orders_id, $email_order_message); 
                    if (!empty($email_order_message)) {
                     $email_text .= "\n\n" . $email_order_message . "\n\n";
                    }
                    $html_msg['EMAIL_ORDER_UPDATE_MESSAGE'] = $email_order_message;
    
    
                    $html_msg['EMAIL_SALUTATION'] = EMAIL_SALUTATION;
                    $html_msg['EMAIL_CUSTOMERS_NAME']    = $osh_info->fields['customers_name'];
                    $html_msg['EMAIL_TEXT_ORDER_NUMBER'] = OSH_EMAIL_TEXT_ORDER_NUMBER . ' ' . $orders_id;
                    $html_msg['EMAIL_TEXT_INVOICE_URL']  = '<a href="' . zen_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, "order_id=$orders_id", 'SSL') .'">' . str_replace(':', '', OSH_EMAIL_TEXT_INVOICE_URL) . '</a>';
                    $html_msg['EMAIL_TEXT_DATE_ORDERED'] = OSH_EMAIL_TEXT_DATE_ORDERED . ' ' . zen_date_long($osh_info->fields['date_purchased']);
                    // Begin Ty Package Tracker
                    $html_msg['EMAIL_TEXT_STATUS_COMMENTS'] = nl2br($email_message.$tracking_comments);
                    // End Ty Package Tracker
                    $html_msg['EMAIL_TEXT_STATUS_UPDATED'] = str_replace("\n", '', $status_text);
                    $html_msg['EMAIL_TEXT_STATUS_LABEL'] = str_replace("\n", '', $status_value_text);
                    $html_msg['EMAIL_TEXT_NEW_STATUS'] = $new_orders_status_name;
                    $html_msg['EMAIL_TEXT_STATUS_PLEASE_REPLY'] = str_replace("\n", '', OSH_EMAIL_TEXT_STATUS_PLEASE_REPLY);
                    $html_msg['EMAIL_PAYPAL_TRANSID'] = '';
                    
                    if (empty($email_subject)) {
                        $email_subject = OSH_EMAIL_TEXT_SUBJECT . ' #' . $orders_id;
                    }
    
    
                    if ($notify_customer == 1) { 
                        zen_mail($osh_info->fields['customers_name'], $osh_info->fields['customers_email_address'], $email_subject, $email_text, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status');
                    } 
    
    
                    // PayPal Trans ID, if any
                    $result = $GLOBALS['db']->Execute(
                        "SELECT txn_id, parent_txn_id 
                           FROM " . TABLE_PAYPAL . " 
                          WHERE order_id = $orders_id
                       ORDER BY last_modified DESC, date_added DESC, parent_txn_id DESC, paypal_ipn_id DESC"
                    );
                    if (!$result->EOF) {
                        $email_text .= "\n\n" . ' PayPal Trans ID: ' . $result->fields['txn_id'];
                        $html_msg['EMAIL_PAYPAL_TRANSID'] = $result->fields['txn_id'];
                    }
    
    
                    //send extra emails
                    if (empty($send_extra_emails_to) && SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_STATUS == '1') {
                        $send_extra_emails_to = (string)SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO;
                    }
                    if (!empty($send_extra_emails_to)) {
                        zen_mail('', $send_extra_emails_to, SEND_EXTRA_ORDERS_STATUS_ADMIN_EMAILS_TO_SUBJECT . ' ' . $email_subject, $email_text, STORE_NAME, EMAIL_FROM, $html_msg, 'order_status_extra');
                    }
                }
        
                if (empty($updated_by)) {
                    if (IS_ADMIN_FLAG === true && isset($_SESSION['admin_id'])) {
                        $updated_by = zen_updated_by_admin();
                    } elseif (IS_ADMIN_FLAG === false && isset($_SESSION['customers_id'])) {
                        $updated_by = '';
                    } else {
                        $updated_by = 'N/A';
                    }
                }
        
                $osh_sql = array(
                    'orders_id' => $orders_id,
                    'orders_status_id' => $orders_new_status,
                    'date_added' => 'now()',
                    'customer_notified' => $notify_customer,
                    'comments' => $message,
                    'updated_by' => $updated_by
                );
                // Begin Ty Package Tracker       
                if (is_array($track_id)) foreach($track_id as $id => $track) {
                    $osh_sql['track_id' . $id] = zen_db_input($track);
                }
                // End Ty Package Tracker
                $GLOBALS['zco_notifier']->notify('ZEN_UPDATE_ORDERS_HISTORY_BEFORE_INSERT', array(), $osh_sql);
        
                zen_db_perform (TABLE_ORDERS_STATUS_HISTORY, $osh_sql);
                $osh_id = $GLOBALS['db']->Insert_ID();
            }    
        }
        return $osh_id;
    }
    Tried replacing the contents of the file with the code you provided... the result was a blank page when trying to view the admin.

    Here is the error log created:
    Code:
    [11-Jan-2021 18:50:55 America/Chicago] PHP Parse error:  syntax error,  unexpected 'if' (T_IF) in /includes/functions/functions_osh_update.php  on line 9
    
    [11-Jan-2021 18:50:55 America/Chicago] Request URI: /XXxxx/, IP address: xxxxx
    --> PHP Parse error: syntax error, unexpected 'if' (T_IF) in /includes/functions/functions_osh_update.php on line 9.
    NTO: building a better network thru collaboration
    www.needtoorder.com | www.coffeewitheinstein.com

 

 
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 14 Feb 2011, 04:47 PM
  2. blank page when adding items to cart
    By kitcorsa in forum General Questions
    Replies: 7
    Last Post: 3 Jun 2009, 01:33 PM
  3. Blank pages when adding items to cart?
    By uberwench in forum General Questions
    Replies: 2
    Last Post: 13 Sep 2008, 03:08 PM
  4. Error with shopping_cart.php when adding items.
    By mohinder in forum General Questions
    Replies: 3
    Last Post: 25 Jul 2008, 09:22 PM
  5. Error when adding 13 items
    By teebo in forum General Questions
    Replies: 1
    Last Post: 23 Jun 2008, 06:56 PM

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