Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Migrating server: Error Custom Shipping file & module


jmianez

Recommended Posts

Migrating an OSC Store, I get a problem with a shipping custom module (lenoir.php).

 

The old-store is working OK - w/o problems from few years ago: MySQL 4.1.12-standard and PHP 4.3.3.

 

New server: MySQL 5.0.32-Debian and PHP/5.2.0-8+etch13

 

In Admin > Modules > Shipping, I get the error as below:

 

Fatal error: Cannot access empty property in /var/www/vhosts/domain.com/httpdocs/includes/modules/shipping/lenoir.php on line 34

 

The page http://domain.com/admin/modules.php?select...mp;set=shipping is not displayed properly. The same message error is displayed when a customer tries to close the purchase.

 

I'm revised the code once, twice, ... but error persist.

 

<?php 
/* 
 $Id: table.php,v 1.27 2003/02/05 22:41:52 hpdl Exp $ 

 osCommerce, Open Source E-Commerce Solutions 
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url] 

 Copyright © 2003 osCommerce 

 Released under the GNU General Public License 
*/ 

 class lenoir { 
   var $code, $title, $description, $icon, $enabled, $selected_zone; 

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

     $this->code = 'lenoir'; 
     $this->title = MODULE_SHIPPING_LENOIR_TABLE_TEXT_TITLE; 
     $this->description = MODULE_SHIPPING_LENOIR_TABLE_TEXT_DESCRIPTION; 
     $this->sort_order = MODULE_SHIPPING_LENOIR_TABLE_SORT_ORDER; 
     $this->icon = ''; 
     $this->tax_class = MODULE_SHIPPING_LENOIR_TABLE_TAX_CLASS; 
     $this->enabled = ((MODULE_SHIPPING_LENOIR_TABLE_STATUS == 'True') ? true : false); 

     if ($this->enabled){ 
       for ($i=1; $i<5; $i+=1) { 
                                       $check_flag = $this->module_enabled($i); 


                                       if ($check_flag == True) { 
                                                       $this->$selected_zone = $i; 
                                                       break; 
                                       } 
                               } 

       if ($check_flag == false) { 
               $this->$selected_zone = 4; 
         //$this->enabled = false; 

       } 
     } 
   } 

// class methods 
// verifica si se aplica la forma de envio  
               function module_enabled($dest_zone){ 
                       global $order; 

                       //echo "MODULE_SHIPPING_LENOIR_TABLE_ZONE_".$dest_zone; 
                       $zone = constant("MODULE_SHIPPING_LENOIR_TABLE_ZONE_".$dest_zone); 
                       //echo "select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . $zone . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id" . "<br>"; 

     if ( ($this->enabled == true) && ((int)$zone > 0) ) { 
       $check_flag = false; 
       $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . $zone . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id"); 
       while ($check = tep_db_fetch_array($check_query)) { 
         if ($check['zone_id'] < 1) { 
           $check_flag = true; 
           break; 
         } elseif ($check['zone_id'] == $order->delivery['zone_id']) { 
           $check_flag = true; 
           break; 
         } 
       }                
       return($check_flag); 
                       } 
               } 

   function quote($method = '') { 
     global $order, $cart, $shipping_weight, $shipping_num_boxes; 
     global $contrareembolso_enabled, $tarjeta_enabled, $dias_entrega; 

     if ($this->enabled) { 


       $aux = constant('MODULE_SHIPPING_LENOIR_TABLE_COST_COURIER_' . $this->$selected_zone); 
       $zones_courier = split("[:,]" , $aux); 
       $dias_courier = constant('MODULE_SHIPPING_LENOIR_TABLE_DIAS_COURIER_' . $this->$selected_zone); 
       $aux = constant('MODULE_SHIPPING_LENOIR_TABLE_COST_CERTIFICADO_' . $this->$selected_zone); 




       $zones_certificado = split("[:,]" , $aux); 
       $dias_certificado = constant('MODULE_SHIPPING_LENOIR_TABLE_DIAS_CERTIFICADO_' . $this->$selected_zone); 


       $order_total = $cart->show_total(); 

       //print_r($zones_courier); 
       //print_r($dias_courier); 

       // vemos el importe de courier 
       $size = sizeof($zones_courier); 
       for ($i=0; $i<$size; $i+=2) { 
         if ($order_total <= $zones_courier[$i]) { 
           $shipping = $zones_courier[$i+1]; 
           $shipping_method = 'Enviar A' . ' ' . $dest_country . ' : ' . $shipping_weight . ' kg(s)'; 
           break; 
         } 
       } 
       if ($shipping == -1) { 
         $shipping_cost = 0; 
         $shipping_method = 'No se han podido calcular los gastos de envio para courier'; 
       } else { 
         $shipping_cost = ($shipping * $shipping_num_boxes);// + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone); 
       } 

       // ahora vemos el importe de certificado 
       $size = sizeof($zones_certificado); 
       for ($i=0; $i<$size; $i+=2) { 
         if ($order_total <= $zones_certificado[$i]) { 
           $shipping_cert = $zones_certificado[$i+1]; 
           $shipping_method_cert = 'Enviar A' . ' ' . $dest_country . ' : ' . $shipping_weight . ' kg(s)'; 
           break; 
         } 
       } 

       if ($shipping_cert == -1) { 
         $shipping_cost_cert = 0; 
         $shipping_method_cert = 'No se han podido calcular los gastos de envio para certificado'; 
       } else { 
         $shipping_cost_cert = ($shipping * $shipping_num_boxes);// + constant('MODULE_SHIPPING_ZONES_HANDLING_' . $dest_zone); 
       } 

       if (strlen($method) == 0){ 
               $this->quotes = array('id' => $this->code, 
                           'module' => MODULE_SHIPPING_LENOIR_TABLE_TEXT_TITLE, 
                           'methods' => array(array('id' => "1", 
                                                    'title' => 'Urgente / Prioritario ('.$dias_courier.' días aprox.)', 
                                                    'cost' => $shipping),      //  + MODULE_SHIPPING_LENOIR_TABLE_HANDLING), 
                                              array('id' => "2", 
                                                    'title' => 'Normal / Econ&mico ('.$dias_certificado.' días aprox.)', 
                                                    'cost' => $shipping_cert), //+ MODULE_SHIPPING_LENOIR_TABLE_HANDLING), 
                                              ) 
                            ); 
       } // de if isset($method) 
       else{ // por aqui pasa una vez que se ha seleccionado la forma de pago 
               if (!tep_session_is_registered('contrareembolso_enabled'))tep_session_register('contrareembolso_enabled'); 
               if (!tep_session_is_registered('tarjeta_enabled')) tep_session_register('tarjeta_enabled'); 
               if (!tep_session_is_registered('dias_entrega')) tep_session_register('dias_entrega'); 

               if ($method == '1'){ //courier 

                       // courier & contrareembolso -> solo en zonas 1 y 2 
                       $contrareembolso_enabled = (($this->$selected_zone == 1) || ($this->$selected_zone == 2)); 
                       // courier & tarjeta -> en todas las zonas 
                       $tarjeta_enabled = true; 
                       $dias_entrega = $dias_courier; 



                       $this->quotes = array('id' => $this->code, 
                           'module' => MODULE_SHIPPING_LENOIR_TABLE_TEXT_TITLE, 
                           'methods' => array(array('id' => "1", 
                                                    'title' => 'Urgente / Prioritario '.$dias_courier.' días aprox.', 
                                                    'cost' => $shipping))); 

               } 
               elseif ($method == '2'){ //certificado 
                       // certificado & contrareembolso -> solo en zonas 1 y 2 
                       $contrareembolso_enabled = (($this->$selected_zone == 1) || ($this->$selected_zone == 2)); 
                       // certificado & tarjeta -> solo en zonas 3 y 4 
                       $tarjeta_enabled = (($this->$selected_zone == 3) || ($this->$selected_zone == 4)); 
                       $dias_entrega = $dias_certificado; 

                       $this->quotes = array('id' => $this->code, 
                           'module' => MODULE_SHIPPING_LENOIR_TABLE_TEXT_TITLE, 
                           'methods' => array(array('id' => "2", 
                                                    'title' => 'Normal / Económico '.$dias_certificado.' días aprox.', 
                                                    'cost' => $shipping_cert))); 
               } 


       } 
                       }                                         

     if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title); 

     if ($this->tax_class > 0) 
     { 
       $this->quotes['tax'] = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); 
     } 

     return $this->quotes; 
   } 

   function check() { 

     if (!isset($this->_check)) { 
       $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_LENOIR_TABLE_STATUS'"); 
       $this->_check = tep_db_num_rows($check_query); 
     } 
     return $this->_check; 
   } 

   function install() { 
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Enable Table Method', 'MODULE_SHIPPING_LENOIR_TABLE_STATUS', 'True', 'Do you want to offer table rate shipping?', '6', '0', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); 

     // zona 1 
     tep_db_query("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 1 ---------', 'MODULE_SHIPPING_LENOIR_TABLE_ZONE_1', '0', 'Seleccione zona 1', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())"); 
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tarifa Courier zona 1', 'MODULE_SHIPPING_LENOIR_TABLE_COST_COURIER_1', '25:8.50,50:5.50,10000:0.00', 'Ejemplo: 25:8.50,50:5.50,etc.. Más de 25 8.50, desde 25 a 50 5.50 de cargo, etc', '6', '0', now())"); 
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tiempo envio Courier zona 1', 'MODULE_SHIPPING_LENOIR_TABLE_DIAS_COURIER_1', '2', '', '6', '0', now())"); 
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tarifa Certificado zona 1', 'MODULE_SHIPPING_LENOIR_TABLE_COST_CERTIFICADO_1', '25:3.50,50:1.50,10000:0.00', '', '6', '0', now())");       
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tiempo envio Certificado zona 1', 'MODULE_SHIPPING_LENOIR_TABLE_DIAS_CERTIFICADO_1', '7', '', '6', '0', now())"); 

     // zona 2 
     tep_db_query("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 2 ---------', 'MODULE_SHIPPING_LENOIR_TABLE_ZONE_2', '0', 'Seleccione zona 2', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");             
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tarifa Courier zona 2', 'MODULE_SHIPPING_LENOIR_TABLE_COST_COURIER_2', '25:8.50,50:5.50,10000:0.00', 'Ejemplo: 25:8.50,50:5.50,etc.. Más de 25 8.50, desde 25 a 50 5.50 de cargo, etc', '6', '0', now())"); 
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tiempo envio Courier zona 2', 'MODULE_SHIPPING_LENOIR_TABLE_DIAS_COURIER_2', '', '', '6', '0', now())"); 
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tarifa Certificado zona 2', 'MODULE_SHIPPING_LENOIR_TABLE_COST_CERTIFICADO_2', '25:8.50,50:5.50,10000:0.00', '', '6', '0', now())");       
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tiempo envio Certificado zona 2', 'MODULE_SHIPPING_LENOIR_TABLE_DIAS_CERTIFICADO_2', '', '', '6', '0', now())"); 

     // zona 3 
     tep_db_query("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 3 ---------', 'MODULE_SHIPPING_LENOIR_TABLE_ZONE_3', '0', 'Seleccione zona 3', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");             
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tarifa Courier zona 3', 'MODULE_SHIPPING_LENOIR_TABLE_COST_COURIER_3', '25:8.50,50:5.50,10000:0.00', 'Ejemplo: 25:8.50,50:5.50,etc.. Más de 25 8.50, desde 25 a 50 5.50 de cargo, etc', '6', '0', now())"); 
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tiempo envio Courier zona 3', 'MODULE_SHIPPING_LENOIR_TABLE_DIAS_COURIER_3', '', '', '6', '0', now())"); 
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tarifa Certificado zona 3', 'MODULE_SHIPPING_LENOIR_TABLE_COST_CERTIFICADO_3', '25:8.50,50:5.50,10000:0.00', '', '6', '0', now())");       
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tiempo envio Certificado zona 3', 'MODULE_SHIPPING_LENOIR_TABLE_DIAS_CERTIFICADO_3', '', '', '6', '0', now())"); 

     // zona 4 
     tep_db_query("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 4 ---------', 'MODULE_SHIPPING_LENOIR_TABLE_ZONE_4', '0', 'Seleccione zona 4', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");             

                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tarifa Courier zona 4', 'MODULE_SHIPPING_LENOIR_TABLE_COST_COURIER_4', '25:8.50,50:5.50,10000:0.00', 'Ejemplo: 25:8.50,50:5.50,etc.. Más de 25 8.50, desde 25 a 50 5.50 de cargo, etc', '6', '0', now())"); 
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tiempo envio Courier zona 4', 'MODULE_SHIPPING_LENOIR_TABLE_DIAS_COURIER_4', '', '', '6', '0', now())"); 
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tarifa Certificado zona 4', 'MODULE_SHIPPING_LENOIR_TABLE_COST_CERTIFICADO_4', '25:8.50,50:5.50,10000:0.00', '', '6', '0', now())");       
                       tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Tiempo envio Certificado zona 4', 'MODULE_SHIPPING_LENOIR_TABLE_DIAS_CERTIFICADO_4', '', '', '6', '0', now())"); 

     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Tax Class', 'MODULE_SHIPPING_LENOIR_TABLE_TAX_CLASS', '0', 'Use the following tax class on the shipping fee.', '6', '0', 'tep_get_tax_class_title', 'tep_cfg_pull_down_tax_classes(', now())"); 
     tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_LENOIR_TABLE_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())"); 
   } 

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

   function keys() { 
     return array('MODULE_SHIPPING_LENOIR_TABLE_STATUS', 

                  'MODULE_SHIPPING_LENOIR_TABLE_ZONE_1', 
                  'MODULE_SHIPPING_LENOIR_TABLE_COST_COURIER_1', 
                  'MODULE_SHIPPING_LENOIR_TABLE_DIAS_COURIER_1', 
                  'MODULE_SHIPPING_LENOIR_TABLE_COST_CERTIFICADO_1', 
                  'MODULE_SHIPPING_LENOIR_TABLE_DIAS_CERTIFICADO_1', 

                  'MODULE_SHIPPING_LENOIR_TABLE_ZONE_2', 
                  'MODULE_SHIPPING_LENOIR_TABLE_COST_COURIER_2', 
                  'MODULE_SHIPPING_LENOIR_TABLE_DIAS_COURIER_2', 
                  'MODULE_SHIPPING_LENOIR_TABLE_COST_CERTIFICADO_2', 
                  'MODULE_SHIPPING_LENOIR_TABLE_DIAS_CERTIFICADO_2', 

                  'MODULE_SHIPPING_LENOIR_TABLE_ZONE_3', 
                  'MODULE_SHIPPING_LENOIR_TABLE_COST_COURIER_3', 
                  'MODULE_SHIPPING_LENOIR_TABLE_DIAS_COURIER_3', 
                  'MODULE_SHIPPING_LENOIR_TABLE_COST_CERTIFICADO_3', 
                  'MODULE_SHIPPING_LENOIR_TABLE_DIAS_CERTIFICADO_3', 

                  'MODULE_SHIPPING_LENOIR_TABLE_ZONE_4', 
                  'MODULE_SHIPPING_LENOIR_TABLE_COST_COURIER_4', 
                  'MODULE_SHIPPING_LENOIR_TABLE_DIAS_COURIER_4', 
                  'MODULE_SHIPPING_LENOIR_TABLE_COST_CERTIFICADO_4', 
                  'MODULE_SHIPPING_LENOIR_TABLE_DIAS_CERTIFICADO_4', 

                  'MODULE_SHIPPING_LENOIR_TABLE_TAX_CLASS',                                                                          
                  'MODULE_SHIPPING_LENOIR_TABLE_SORT_ORDER'); 
   } 
 } 

?> 

 

Thanks for your help.

 

Jose Manuel - jmanuel [at] lenoir.es

Edited by jmianez
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...