Results 1 to 10 of 10
  1. #1
    Join Date
    Mar 2009
    Location
    Italy
    Posts
    155
    Plugin Contributions
    0

    Default Cash on Delivery error with php 5.4...

    Recently i upgraded php to 5.4.45, after that i got this error:

    HTML Code:
    [18-Nov-2015 20:58:30 Europe/Rome] Request URI: /index.php?main_page=checkout, IP address: 79.17.2.28
    #1  cod->cod() called at [/var/www/vhosts/laviadellincenso.it/httpdocs/includes/classes/payment.php:75]
    #2  payment->payment() called at [/var/www/vhosts/laviadellincenso.it/httpdocs/includes/modules/pages/checkout/header_php.php:204]
    #3  require(/var/www/vhosts/laviadellincenso.it/httpdocs/includes/modules/pages/checkout/header_php.php) called at [/var/www/vhosts/laviadellincenso.it/httpdocs/index.php:36]
    
    [18-Nov-2015 20:58:30 Europe/Rome] PHP Warning:  Illegal string offset 'id' in /var/www/vhosts/laviadellincenso.it/httpdocs/includes/modules/payment/cod.php on line 31
    [18-Nov-2015 20:58:30 Europe/Rome] Request URI: /index.php?main_page=checkout, IP address: 79.17.2.28
    #1  cod->cod() called at [/var/www/vhosts/laviadellincenso.it/httpdocs/includes/classes/payment.php:75]
    #2  payment->payment() called at [/var/www/vhosts/laviadellincenso.it/httpdocs/includes/modules/pages/checkout/header_php.php:204]
    #3  require(/var/www/vhosts/laviadellincenso.it/httpdocs/includes/modules/pages/checkout/header_php.php) called at [/var/www/vhosts/laviadellincenso.it/httpdocs/index.php:36]
    
    [18-Nov-2015 20:58:30 Europe/Rome] PHP Warning:  Illegal string offset 'id' in /var/www/vhosts/laviadellincenso.it/httpdocs/includes/modules/payment/cod.php on line 34
    [18-Nov-2015 20:58:30 Europe/Rome] Request URI: /index.php?main_page=checkout, IP address: 79.17.2.28
    #1  cop->update_status() called at [/var/www/vhosts/laviadellincenso.it/httpdocs/includes/modules/payment/cop.php:34]
    #2  cop->cop() called at [/var/www/vhosts/laviadellincenso.it/httpdocs/includes/classes/payment.php:75]
    #3  payment->payment() called at [/var/www/vhosts/laviadellincenso.it/httpdocs/includes/modules/pages/checkout/header_php.php:204]
    #4  require(/var/www/vhosts/laviadellincenso.it/httpdocs/includes/modules/pages/checkout/header_php.php) called at [/var/www/vhosts/laviadellincenso.it/httpdocs/index.php:36]
    
    [18-Nov-2015 20:58:30 Europe/Rome] PHP Warning:  Illegal string offset 'id' in /var/www/vhosts/laviadellincenso.it/httpdocs/includes/modules/payment/cop.php on line 41
    and here the lines called in cod.php (31 to 37):

    PHP Code:
    if (!IS_ADMIN_FLAG && strstr ($_SESSION['shipping']['id'], 'flat')) {
            
    $this->enabled false;
          }
          if (!
    IS_ADMIN_FLAG && strstr ($_SESSION['shipping']['id'], 'storepickup')) {
            
    $this->enabled false;
          }
        } 
    These lines set the module off if a specific shipping method is selected.

    I've searched all the forums and found different posts and some fixes but none works out for me.

    The line 41 of cop.php is the following:

    PHP Code:
    if (is_array($_SESSION) && $_SESSION['shipping']['id'] != 'storepickup_storepickup') { 
    Any help will be appreciate :-)

  2. #2
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,379
    Plugin Contributions
    9

    Default Re: Cash on Delivery error with php 5.4...

    Noted two things:

    1. as far as I know there is no such file named cop.php in the standard ZC 1.5.4 fileset

    2. your /includes/modules/payment/cod.php does not look right to me

    That file should look like this (unmodified):

    PHP Code:
    <?php 
    /** 
     * COD Payment Module 
     * 
     * @package paymentMethod 
     * @copyright Copyright 2003-2010 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 GIT: $Id: Author: DrByte  Tue Jan 22 03:36:04 2013 -0500 Modified in v1.5.2 $
     */ 
      
    class cod 
        var 
    $code$title$description$enabled
     
    // class constructor 
        
    function cod() { 
          global 
    $order
     
          
    $this->code 'cod'
          
    $this->title MODULE_PAYMENT_COD_TEXT_TITLE
          
    $this->description MODULE_PAYMENT_COD_TEXT_DESCRIPTION
          
    $this->sort_order MODULE_PAYMENT_COD_SORT_ORDER
          
    $this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true false); 
     
          if ((int)
    MODULE_PAYMENT_COD_ORDER_STATUS_ID 0) { 
            
    $this->order_status MODULE_PAYMENT_COD_ORDER_STATUS_ID
          } 
     
          if (
    is_object($order)) $this->update_status(); 
        } 
     
    // class methods 
        
    function update_status() { 
          global 
    $order$db
     
          if (
    $this->enabled && (int)MODULE_PAYMENT_COD_ZONE && isset($order->billing['country']['id'])) { 
            
    $check_flag false
            
    $check $db->Execute("select zone_id from " TABLE_ZONES_TO_GEO_ZONES " where geo_zone_id = '" MODULE_PAYMENT_COD_ZONE "' and zone_country_id = '" $order->delivery['country']['id'] . "' order by zone_id"); 
            while (!
    $check->EOF) { 
              if (
    $check->fields['zone_id'] < 1) { 
                
    $check_flag true
                break; 
              } elseif (
    $check->fields['zone_id'] == $order->delivery['zone_id']) { 
                
    $check_flag true
                break; 
              } 
              
    $check->MoveNext(); 
            } 
     
            if (
    $check_flag == false) { 
              
    $this->enabled false
            } 
          } 
     
    // disable the module if the order only contains virtual products 
          
    if ($this->enabled == true) { 
            if (
    $order->content_type != 'physical') { 
              
    $this->enabled false
            } 
          } 
        } 
     
        function 
    javascript_validation() { 
          return 
    false
        } 
     
        function 
    selection() { 
          return array(
    'id' => $this->code
                       
    'module' => $this->title); 
        } 
     
        function 
    pre_confirmation_check() { 
          return 
    false
        } 
     
        function 
    confirmation() { 
          return 
    false
        } 
     
        function 
    process_button() { 
          return 
    false
        } 
     
        function 
    before_process() { 
          return 
    false
        } 
     
        function 
    after_process() { 
          return 
    false
        } 
     
        function 
    get_error() { 
          return 
    false
        } 
     
        function 
    check() { 
          global 
    $db
          if (!isset(
    $this->_check)) { 
            
    $check_query $db->Execute("select configuration_value from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_PAYMENT_COD_STATUS'"); 
            
    $this->_check $check_query->RecordCount(); 
          } 
          return 
    $this->_check
        } 
     
        function 
    install() { 
          global 
    $db$messageStack
          if (
    defined('MODULE_PAYMENT_COD_STATUS')) { 
            
    $messageStack->add_session('COD module already installed.''error'); 
            
    zen_redirect(zen_href_link(FILENAME_MODULES'set=payment&module=cod''NONSSL')); 
            return 
    'failed'
          } 
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Cash On Delivery Module', 'MODULE_PAYMENT_COD_STATUS', 'True', 'Do you want to accept Cash On Delivery payments?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())"); 
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_COD_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())"); 
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_COD_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); 
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Set Order Status', 'MODULE_PAYMENT_COD_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())"); 
       } 
     
        function 
    remove() { 
          global 
    $db
          
    $db->Execute("delete from " TABLE_CONFIGURATION " where configuration_key in ('" implode("', '"$this->keys()) . "')"); 
        } 
     
        function 
    keys() { 
          return array(
    'MODULE_PAYMENT_COD_STATUS''MODULE_PAYMENT_COD_ZONE''MODULE_PAYMENT_COD_ORDER_STATUS_ID''MODULE_PAYMENT_COD_SORT_ORDER'); 
        } 
      }
    Suggest you replace your file with the code above.

  3. #3
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Cash on Delivery error with php 5.4...

    Cop is the cash on pick up module. Charges are it is not updated in a while, and not ready for the latest php and zen cart versions.

  4. #4
    Join Date
    Mar 2009
    Location
    Italy
    Posts
    155
    Plugin Contributions
    0

    Default Re: Cash on Delivery error with php 5.4...

    Quote Originally Posted by frank18 View Post

    Suggest you replace your file with the code above.
    Hi Frank and thanks for the suggestion. I checked and my cod.php is identical to the one you posted except for two condition lines that disable the module if a certain shipping is selected, here the file:
    PHP Code:
    <?php
    /**
     * COD Payment Module
     *
     * @package paymentMethod
     * @copyright Copyright 2003-2010 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 GIT: $Id: Author: DrByte  Tue Jan 22 03:36:04 2013 -0500 Modified in v1.5.2 $
     */
      
    class cod {
        var 
    $code$title$description$enabled;

    // class constructor
        
    function cod() {
          global 
    $order;

          
    $this->code 'cod';
          
    $this->title MODULE_PAYMENT_COD_TEXT_TITLE;
          
    $this->description MODULE_PAYMENT_COD_TEXT_DESCRIPTION;
          
    $this->sort_order MODULE_PAYMENT_COD_SORT_ORDER;
          
    $this->enabled = ((MODULE_PAYMENT_COD_STATUS == 'True') ? true false);

          if ((int)
    MODULE_PAYMENT_COD_ORDER_STATUS_ID 0) {
            
    $this->order_status MODULE_PAYMENT_COD_ORDER_STATUS_ID;
          }

          if (
    is_object($order)) $this->update_status();
          
    // bof: turn off payment module if shoppickup is enabled or picknpay
    //echo 'Payment Module sees: ' . $_SESSION['shipping']['id'] . '<br>';
          
    if (!IS_ADMIN_FLAG && strstr ($_SESSION['shipping']['id'], 'flat')) {
            
    $this->enabled false;
          }
          if (!
    IS_ADMIN_FLAG && strstr ($_SESSION['shipping']['id'], 'storepickup')) {
            
    $this->enabled false;
          }
        }

    // class methods
        
    function update_status() {
          global 
    $order$db;

          if ( (
    $this->enabled == true) && ((int)MODULE_PAYMENT_COD_ZONE 0) && isset($order->delivery['country']['id']) ) {//steve added last clause for php 5.4.7
            
    $check_flag false;
            
    $check $db->Execute("select zone_id from " TABLE_ZONES_TO_GEO_ZONES " where geo_zone_id = '" MODULE_PAYMENT_COD_ZONE "' and zone_country_id = '" $order->delivery['country']['id'] . "' order by zone_id");
            while (!
    $check->EOF) {
              if (
    $check->fields['zone_id'] < 1) {
                
    $check_flag true;
                break;
              } elseif (
    $check->fields['zone_id'] == $order->delivery['zone_id']) {
                
    $check_flag true;
                break;
              }
              
    $check->MoveNext();
            }

            if (
    $check_flag == false) {
              
    $this->enabled false;
            }
          }

    // disable the module if the order only contains virtual products
          
    if ($this->enabled == true) {
            if (
    $order->content_type != 'physical') {
              
    $this->enabled false;
            }
          }
        }

        function 
    javascript_validation() {
          return 
    false;
        }

        function 
    selection() {
          return array(
    'id' => $this->code,
                       
    'module' => $this->title);
        }

        function 
    pre_confirmation_check() {
          return 
    false;
        }

        function 
    confirmation() {
          return 
    false;
        }

        function 
    process_button() {
          return 
    false;
        }

        function 
    before_process() {
          return 
    false;
        }

        function 
    after_process() {
          return 
    false;
        }

        function 
    get_error() {
          return 
    false;
        }

        function 
    check() {
          global 
    $db;
          if (!isset(
    $this->_check)) {
            
    $check_query $db->Execute("select configuration_value from " TABLE_CONFIGURATION " where configuration_key = 'MODULE_PAYMENT_COD_STATUS'");
            
    $this->_check $check_query->RecordCount();
          }
          return 
    $this->_check;
        }

        function 
    install() {
          global 
    $db$messageStack;
          if (
    defined('MODULE_PAYMENT_COD_STATUS')) {
            
    $messageStack->add_session('Modulo Contrassegno gi&agrave; installato.''error');
            
    zen_redirect(zen_href_link(FILENAME_MODULES'set=payment&module=cod''NONSSL'));
            return 
    'failed';
          }
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Abilita il Modulo Contrassegno', 'MODULE_PAYMENT_COD_STATUS', 'True', 'Accettare pagamenti con Contrassegno?', '6', '1', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Zona di Pagamento', 'MODULE_PAYMENT_COD_ZONE', '0', 'Se viene selezionata una Zona, attiva questo metodo di pagamento soltanto per questa Zona.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Ordine di Visualizzazione', 'MODULE_PAYMENT_COD_SORT_ORDER', '0', 'Ordine di Visualizzazione. Il pi&ugrave; basso viene visualizzato per primo.', '6', '0', now())");
          
    $db->Execute("insert into " TABLE_CONFIGURATION " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) values ('Imposta Stato Ordine', 'MODULE_PAYMENT_COD_ORDER_STATUS_ID', '0', 'Imposta lo Stato degli Ordini eseguiti con questo modulo di pagamento a questo valore.', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");
       }

        function 
    remove() {
          global 
    $db;
          
    $db->Execute("delete from " TABLE_CONFIGURATION " where configuration_key in ('" implode("', '"$this->keys()) . "')");
        }

        function 
    keys() {
          return array(
    'MODULE_PAYMENT_COD_STATUS''MODULE_PAYMENT_COD_ZONE''MODULE_PAYMENT_COD_ORDER_STATUS_ID''MODULE_PAYMENT_COD_SORT_ORDER');
        }
      }
    The line 31 and 34 are the conditions and unfortunately the one that seems to generate the error, the illegal string offset regard this little part:

    PHP Code:
     if (!IS_ADMIN_FLAG && strstr ($_SESSION['shipping']['id'], 'flat')) {
            
    $this->enabled false;
          }
          if (!
    IS_ADMIN_FLAG && strstr ($_SESSION['shipping']['id'], 'storepickup')) {
            
    $this->enabled false;
          }
        } 

  5. #5
    Join Date
    Mar 2009
    Location
    Italy
    Posts
    155
    Plugin Contributions
    0

    Default Re: Cash on Delivery error with php 5.4...

    Quote Originally Posted by Design75 View Post
    Cop is the cash on pick up module. Charges are it is not updated in a while, and not ready for the latest php and zen cart versions.
    Hi Design75,

    You hit the spot, unfortunately I haven't found another module up to date that would do the same than Cash on Pickup... if You have any suggestion i'll be glad to follow the suggestion :-)

  6. #6
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Cash on Delivery error with php 5.4...

    I'll try to take a look at the mod tonight.

  7. #7
    Join Date
    Mar 2009
    Location
    Italy
    Posts
    155
    Plugin Contributions
    0

    Default Re: Cash on Delivery error with php 5.4...

    Quote Originally Posted by Design75 View Post
    I'll try to take a look at the mod tonight.
    Thanks mate, You are the best ;-)

  8. #8
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Cash on Delivery error with php 5.4...

    I installed the COP mod on a ZC 1.5.4 test environment, and are unable to reproduce your php warning. Partly because this mod will never work on 1.5.4 because of this line in includes/modules/payment/cop.php (line 41)
    PHP Code:
    if ($_SESSION['shipping']['id'] != 'storepickup_storepickup') { 
    In zen Cart 1.5.4 it is storepickup_storepickup0, storepickup_storepickup1 and so on.
    I am working on an update wich probably will be to update line 41 to
    PHP Code:
        if (stristr($_SESSION['shipping']['id'], 'storepickup') == FALSE) { 
    The fact that you are getting the php warning makes me suspect you did not upgrade to 1.5.4, or only did a partial update.

  9. #9
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Cash on Delivery error with php 5.4...

    I just submitted an updated version to the downloads section. Until available you can use this link

  10. #10
    Join Date
    Mar 2009
    Location
    Italy
    Posts
    155
    Plugin Contributions
    0

    Default Re: Cash on Delivery error with php 5.4...

    Quote Originally Posted by Design75 View Post
    I just submitted an updated version to the downloads section. Until available you can use this link
    Hi,

    great news :-), as regards my specific problem, to be onest i'm working with a full 1.54 install, and I really don't know what to say about it... for sure You are right about the storepickup_storepickup0, storepickup_storepickup1... but it work although my line 41 of cop.php is
    PHP Code:
    if (is_array($_SESSION) && $_SESSION['shipping']['id'] != 'storepickup_storepickup') { 
    .

    The error i posted in #1 is the one i get, and i wasn't getting it until I updated the server php to 5.4.45 (before it was 5.2, using PLesk now it's possible to switch php version of Domains with just 1 click, choosing between different versions availabe). I do not know if it's just a case or not...

    I'll be sure to try the COP.PHP update You posted


 

 

Similar Threads

  1. Replies: 10
    Last Post: 10 Jan 2013, 08:13 PM
  2. v139d cash on delivery error
    By vindyas in forum General Questions
    Replies: 1
    Last Post: 8 Apr 2012, 06:38 AM
  3. Help with COD - Cash on delivery
    By Alquimio in forum General Questions
    Replies: 2
    Last Post: 11 Nov 2009, 03:56 PM
  4. shipping per weight with cash on delivery extra charge
    By Llama de Anor in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 4 Mar 2008, 07:06 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