Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Problem with ot_shipping.php after PHP5.3 upgrade.


Leak-Proof

Recommended Posts

I can't seem to find a fix for this warning. Any help would be appreciated.

 

I am getting the warning below on my 2.3 sites. My host upgraded to PHP5.3, so I have been going through the sites and making the code compliant by replacing deprecated functions etc. I believe I completely finished the front end of the shop fully and am now finishing the admin area for deprecated functions.

 

It has seems that the function is receiving an array and it is looking for a string.

 

 

Warning
: strpos() expects parameter 1 to be string, array given in
/home/leakp/public_html/catalog/includes/modules/order_total/ot_shipping.php
on line
48

 

Warning
: substr() expects parameter 1 to be string, array given in
/home/leakp/public_html/catalog/includes/modules/order_total/ot_shipping.php
on line
48

Sub-Total: CAD $496.65 UPS Standard: CAD $70.42 ON HST: CAD $73.72 Total: CAD $640.79

It has been suggested to me that the function is receiving this array:

 

$shipping = array('id' => $shipping,'title' => (($free_shipping == true) ? $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),'cost' => $quote[0]['methods'][0]['cost']);

...when it is looking for a string.

 

and ($GLOBALS['shipping']['id'] is the array that is being received but the substr and strops functions are looking for strings, not arrays. You may have to cast the array to a string before putting it into the substr and strops functions.

 

I originally install many mods on these shops years ago, but have been out of it for too long to remember everything I learned then. I am also looking for a coder to assist in several small projects on these shops as well. I am located in Ontario, Canada.

 

my full code for that page (ot_shipping.php)is

*******************************************

 [/size]
[size="2"] [font="Times New Roman"][size="3"][color="#000000"] [/color][/size][/font][/size]
[size="2"][color=#17365D][size=3][font="Calibri"]<?php[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]/*[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]  $Id: ot_shipping.php,v 1.15 2003/02/07 22:01:57 dgw_ Exp $[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]  osCommerce, Open Source E-Commerce Solutions[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [url="http://www.oscommerce.com/"][font="Calibri"][color="#0000ff"]http://www.oscommerce.com[/color][/font][/url][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]  Copyright (c) 2003 osCommerce[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]  Released under the GNU General Public License[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]*/[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]  class ot_shipping {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	var $title, $output;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	function ot_shipping() {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  $this->code = 'ot_shipping';[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  $this->title = MODULE_ORDER_TOTAL_SHIPPING_TITLE;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  $this->description = MODULE_ORDER_TOTAL_SHIPPING_DESCRIPTION;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  $this->enabled = ((MODULE_ORDER_TOTAL_SHIPPING_STATUS == 'true') ? true : false);[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  $this->sort_order = MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  $this->output = array();[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	}[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	function process() {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  global $order, $currencies;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  case 'national':[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]			if ($order->delivery['country_id'] == STORE_COUNTRY) $pass = true; break;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  case 'international':[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]			if ($order->delivery['country_id'] != STORE_COUNTRY) $pass = true; break;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  case 'both':[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]			$pass = true; break;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  default:[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]			$pass = false; break;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		}[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		if ( ($pass == true) && ( ($order->info['total'] - $order->info['shipping_cost']) >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  $order->info['shipping_method'] = $this->title;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  $order->info['total'] -= $order->info['shipping_cost'];[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  $order->info['shipping_cost'] = 0;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		}[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  }[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	 $module = substr($GLOBALS['shipping']['id'], 0, strpos($GLOBALS['shipping']['id'], '_'));[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  if (tep_not_null($order->info['shipping_method'])) {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		if ($GLOBALS[$module]->tax_class > 0) {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  $shipping_tax = tep_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  $shipping_tax_description = tep_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  $order->info['tax'] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  $order->info['tax_groups']["$shipping_tax_description"] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  $order->info['total'] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		  if (DISPLAY_PRICE_WITH_TAX == 'true') $order->info['shipping_cost'] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		}[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		$this->output[] = array('title' => $order->info['shipping_method'] . ':',[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]								'text' => $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']),[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]								'value' => $order->info['shipping_cost']);[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  }[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	}[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	function check() {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  if (!isset($this->_check)) {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_SHIPPING_STATUS'");[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]		$this->_check = tep_db_num_rows($check_query);[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  }[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  return $this->_check;[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	}[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	function keys() {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  return array('MODULE_ORDER_TOTAL_SHIPPING_STATUS', 'MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER', 'MODULE_ORDER_TOTAL_SHIPPING_DESTINATION');[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	}[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	function install() {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  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 ('Display Shipping', 'MODULE_ORDER_TOTAL_SHIPPING_STATUS', 'true', 'Do you want to display the order shipping cost?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', now())");[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  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_ORDER_TOTAL_SHIPPING_SORT_ORDER', '2', 'Sort order of display.', '6', '2', now())");[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  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 ('Allow Free Shipping', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'false', 'Do you want to allow free shipping?', '6', '3', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('Free Shipping For Orders Over', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER', '50', 'Provide free shipping for orders over the set amount.', '6', '4', 'currencies->format', now())");[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  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 ('Provide Free Shipping For Orders Made', 'MODULE_ORDER_TOTAL_SHIPPING_DESTINATION', 'national', 'Provide free shipping for orders sent to the set destination.', '6', '5', 'tep_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	}[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3] [/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	function remove() {[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]	}[/font][/size][/color][/size]

[size="2"][color=#17365D][size=3][font="Calibri"]  }[/font][/size][/color][/size]
[size="2"][size="3"][color=#17365D]?>[/color][/size][/size]
[size="2"]

I like these mods, there fun! ...65 70 72 75 80 85 125+ contributions installed and counting...

 

Tools I'm using: OSC2.2 milestone2, Filezilla for FTP, PHP Designer 2007PE (nice), Araxis Merge 6.5 to compare files, XP(my box), Remote Server is shared Apache 1.3 Cpanel, CURL, and PHPmyAdmin through my hosts Cpanel to mess up the database.

Link to comment
Share on other sites

let me try that again...

 

<?php
/*
 $Id: ot_shipping.php,v 1.15 2003/02/07 22:01:57 dgw_ Exp $
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2003 osCommerce
 Released under the GNU General Public License
*/
 class ot_shipping {
   var $title, $output;
   function ot_shipping() {
  $this->code = 'ot_shipping';
  $this->title = MODULE_ORDER_TOTAL_SHIPPING_TITLE;
  $this->description = MODULE_ORDER_TOTAL_SHIPPING_DESCRIPTION;
  $this->enabled = ((MODULE_ORDER_TOTAL_SHIPPING_STATUS == 'true') ? true : false);
  $this->sort_order = MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER;
  $this->output = array();
   }
   function process() {
  global $order, $currencies;
  if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
    switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
	  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;
	  default:
	    $pass = false; break;
    }
    if ( ($pass == true) && ( ($order->info['total'] - $order->info['shipping_cost']) >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) ) {
	  $order->info['shipping_method'] = $this->title;
	  $order->info['total'] -= $order->info['shipping_cost'];
	  $order->info['shipping_cost'] = 0;
    }
  }
//	 $module = substr($GLOBALS['shipping']['id'], 0, strpos($GLOBALS['shipping']['id'], '_'));
    $module = substr($GLOBALS['shipping']('id'), 0, strpos($GLOBALS['shipping']['id'], '_'));
  if (tep_not_null($order->info['shipping_method'])) {
    if ($GLOBALS[$module]->tax_class > 0) {
	  $shipping_tax = tep_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
	  $shipping_tax_description = tep_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
	  $order->info['tax'] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);
	  $order->info['tax_groups']["$shipping_tax_description"] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);
	  $order->info['total'] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);
	  if (DISPLAY_PRICE_WITH_TAX == 'true') $order->info['shipping_cost'] += tep_calculate_tax($order->info['shipping_cost'], $shipping_tax);
    }
    $this->output[] = array('title' => $order->info['shipping_method'] . ':',
						    'text' => $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']),
						    'value' => $order->info['shipping_cost']);
  }
   }
   function check() {
  if (!isset($this->_check)) {
    $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_ORDER_TOTAL_SHIPPING_STATUS'");
    $this->_check = tep_db_num_rows($check_query);
  }
  return $this->_check;
   }
   function keys() {
  return array('MODULE_ORDER_TOTAL_SHIPPING_STATUS', 'MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER', 'MODULE_ORDER_TOTAL_SHIPPING_DESTINATION');
   }
   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 ('Display Shipping', 'MODULE_ORDER_TOTAL_SHIPPING_STATUS', 'true', 'Do you want to display the order shipping cost?', '6', '1','tep_cfg_select_option(array(\'true\', \'false\'), ', 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_ORDER_TOTAL_SHIPPING_SORT_ORDER', '2', 'Sort order of display.', '6', '2', now())");
  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 ('Allow Free Shipping', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING', 'false', 'Do you want to allow free shipping?', '6', '3', 'tep_cfg_select_option(array(\'true\', \'false\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, date_added) values ('Free Shipping For Orders Over', 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER', '50', 'Provide free shipping for orders over the set amount.', '6', '4', 'currencies->format', now())");
  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 ('Provide Free Shipping For Orders Made', 'MODULE_ORDER_TOTAL_SHIPPING_DESTINATION', 'national', 'Provide free shipping for orders sent to the set destination.', '6', '5', 'tep_cfg_select_option(array(\'national\', \'international\', \'both\'), ', now())");
   }
   function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
   }
 }
?>

I like these mods, there fun! ...65 70 72 75 80 85 125+ contributions installed and counting...

 

Tools I'm using: OSC2.2 milestone2, Filezilla for FTP, PHP Designer 2007PE (nice), Araxis Merge 6.5 to compare files, XP(my box), Remote Server is shared Apache 1.3 Cpanel, CURL, and PHPmyAdmin through my hosts Cpanel to mess up the database.

Link to comment
Share on other sites

@@Leak-Proof

 

I am getting the warning below on my 2.3 sites. My host upgraded to PHP5.3, so I have been going through the sites and making the code compliant by replacing deprecated functions etc. I believe I completely finished the front end of the shop fully and am now finishing the admin area for deprecated functions.

 

osCommerce v2.3.1 is PHP 5.3 compliant already.

 

 

 

Chris

Link to comment
Share on other sites

sorry, I'm upping my code to 2.3

I like these mods, there fun! ...65 70 72 75 80 85 125+ contributions installed and counting...

 

Tools I'm using: OSC2.2 milestone2, Filezilla for FTP, PHP Designer 2007PE (nice), Araxis Merge 6.5 to compare files, XP(my box), Remote Server is shared Apache 1.3 Cpanel, CURL, and PHPmyAdmin through my hosts Cpanel to mess up the database.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...