Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2007
    Posts
    412
    Plugin Contributions
    0

    Default Call to undefined function zen_datetime_short() after installing Print Invoice Popup

    After installing the Print Invoice Popup mod:

    http://www.zen-cart.com/downloads.php?do=file&id=1089

    Im getting the following error in my logs folder:

    [19-Jul-2014 06:55:28 America/Chicago] PHP Fatal error: Call to undefined function zen_datetime_short() in /home/mywebsite/www/includes/modules/print_invoice.php on line 421

    I know that module is made for zencart version 1.3.0 but it seems to work fine with 1.5.1 except that Im getting the above error in my logs folder.

    Anybody knows how to correct this error?

    Line 421 in print_invoice.php looks like this:
    <td class="smallText" align="left" valign="top">' . zen_datetime_short($orders_history->fields['date_added']) . '</td>' . "\n";

    I guess the problem is the "zen_datetime_short" definition, but what is the correct definition??
    Last edited by DML73; 20 Jul 2014 at 05:48 AM.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Call to undefined function zen_datetime_short() after installing Print Invoice Po

    Since in original ZC code that function is defined in /admin/includes/functions/general.php, it can only be used on the admin side.
    So, perhaps the plugin has a functions file where it also defines it on the storefront side by putting a file with just that function somewhere under the /includes/functions/extra_functions folder? ... in which case it seems as though you've not actually uploaded all the files that probably came with the plugin?
    .

    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.

  3. #3
    Join Date
    Oct 2007
    Posts
    412
    Plugin Contributions
    0

    Default Re: Call to undefined function zen_datetime_short() after installing Print Invoice Po

    Thanks. I just re-checked that I did upload all files.
    When I search for "zen_datetime_short" in admin->Tools->Developers Tool Kit then I can see that this string only exists in the following files:

    /includes/classes/super_order.php
    /includes/modules/payment/paypal/paypal_admin_notification.php
    /includes/modules/print_invoice.php

    I also see no functions file in the plugin folders. So apparently there is no file defining this function.

    Is there a way I can add such a file defining this function relatively easy? What would the code be? (unfortunately Im not a programmer )

  4. #4
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Call to undefined function zen_datetime_short() after installing Print Invoice Po

    You apparently didn't search in admin files. I found this in my v1.5.1 files:

    /my_admin/includes/functions/general.php
    Line #169 : function zen_datetime_short($raw_datetime) {

    If you look at that file, you should be able to copy that function into a new file (you can name it like datetime_functions.php or whatever) and save the file in your main /includes/functions/extra_functions/ folder.

  5. #5
    Join Date
    Oct 2007
    Posts
    412
    Plugin Contributions
    0

    Default Re: Call to undefined function zen_datetime_short() after installing Print Invoice Po

    Great thanks, its working! I put:

    Code:
    function zen_datetime_short($raw_datetime) {
        if ( ($raw_datetime == '0001-01-01 00:00:00') || ($raw_datetime == '') ) return false;
    
        $year = (int)substr($raw_datetime, 0, 4);
        $month = (int)substr($raw_datetime, 5, 2);
        $day = (int)substr($raw_datetime, 8, 2);
        $hour = (int)substr($raw_datetime, 11, 2);
        $minute = (int)substr($raw_datetime, 14, 2);
        $second = (int)substr($raw_datetime, 17, 2);
    
        return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
      }
    into a new file called datetime_functions.php and put it in /includes/functions/extra_functions as you suggested. Now I no longer get the error in my logs folder.

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,873
    Plugin Contributions
    96

    Default Re: Call to undefined function zen_datetime_short() after installing Print Invoice Po

    Just in case that function "comes over to the store-side" in a future release of Zen Cart, you might want to make a slight update:
    Code:
    if (!function_exists('zen_datetime_short')) {
      function zen_datetime_short($raw_datetime) {
        if ( ($raw_datetime == '0001-01-01 00:00:00') || ($raw_datetime == '') ) return false;
    
        $year = (int)substr($raw_datetime, 0, 4);
        $month = (int)substr($raw_datetime, 5, 2);
        $day = (int)substr($raw_datetime, 8, 2);
        $hour = (int)substr($raw_datetime, 11, 2);
        $minute = (int)substr($raw_datetime, 14, 2);
        $second = (int)substr($raw_datetime, 17, 2);
    
        return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
      }
    }

  7. #7
    Join Date
    Oct 2007
    Posts
    412
    Plugin Contributions
    0

    Default Re: Call to undefined function zen_datetime_short() after installing Print Invoice Po

    Thanks, I made the update.

 

 

Similar Threads

  1. Client Invoice - problems customizing the popup-print-invoice addon
    By LloydR in forum All Other Contributions/Addons
    Replies: 7
    Last Post: 12 Jan 2011, 10:41 AM
  2. Call to undefined function
    By Forum5 in forum General Questions
    Replies: 10
    Last Post: 14 Sep 2010, 02:43 PM
  3. Call to undefined function: cfg_select_option() after upgrading
    By SyringaHobbyCraft in forum Upgrading from 1.3.x to 1.3.9
    Replies: 5
    Last Post: 5 Aug 2009, 02:04 AM
  4. Call to undefined function: curl_init()
    By lewispearce in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 23 Jan 2007, 09:32 PM

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