Oscommerce, Solve UPS Error – “Call to undefined function tep_cfg_select_multioption()”

Before three days we have got “Fatal error: Call to undefined function tep_cfg_select_multioption() in /admin/modules.php(221) : eval()’d code on line 1” error while trying to edit the United Parcel Service (UPS) module configuration from our site admin.

And we have got solution of that, so we are sharing that solution.

Here the first question is: why this error has occurred? And what is the solution of it?

Here the error is saying “Call to undefined function tep_cfg_select_multioption()”, it means PHP doesn’t know anything about “tep_cfg_select_multioption()” function.

And this was happened because we didn’t add “tep_cfg_select_multioption()” function in “/admin/includes/functions/general.php” file.

Now to solve this problem just follow the under given two steps.

Step-1:

Add the following code to /admin/includes/functions/general.php, at the end just before the final “?>”:

// Alias function for array of configuration values in the Administration Tool
function tep_cfg_select_multioption($select_array, $key_value, $key = '') {
for ($i=0; $i<sizeof($select_array); $i++) {
$name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
$string .= '<br><input type="checkbox" name="' . $name . '" value="' . $select_array[$i] . '"';
$key_values = explode( ", ", $key_value);
if ( in_array($select_array[$i], $key_values) ) $string .= 'CHECKED';
$string .= '> ' . $select_array[$i];
}
return $string;
}
//

Step-2:

In /admin/modules.php, around line 37 replace:

case 'save':
while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
}

With

case 'save':
while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {
if( is_array( $value ) ) $value = implode( ", ", $value);
tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $value . "' where configuration_key = '" . $key . "'");
}

That’s it.

Hope this will help you.

How to upgrade oscommerce-2.2rc2a to oscommerce-3.0a5 and oscommerce-2.3.1?

It is important to upgrade your oscommerce store to newer version.

So if your store is in oscommerce-2.2rc2a or oscommerce-3.0a5 then we providing an upgrade guide to upgrade your store to oscommerce-3.0a5 or oscommerce-2.3.1 respectively.

To get an upgrade guide follow the under given link.

Get upgrade guide….

I hope this will help you….!!

Solution for Oscommerce PayPal Express Checkout ERRORCODE: 10736

Question:How to solve Oscommerce PayPal Express Checkout ERRORCODE: 10736?
ERROR:
TIMESTAMP: 2010-01-13T08:34:06Z
ACK: FAILURE
SHORTMESSAGE: SHIPPING ADDRESS INVALID CITY STATE POSTAL CODE
LONGMESSAGE: A MATCH OF THE SHIPPING ADDRESS CITY, STATE, AND POSTAL CODE FAILED.
ERRORCODE: 10736

Answer:
it solved to change into ppeb.php file
find:

"<Address>".

change to:

"<ShipToAddress>".

find:

"</Address>".

change to:

"</ShipToAddress>".

Complete code before and after

Before:

$msg .="<cpp-header-image>".$url."/ppec/ppec_image/".LOGO."</cpp-header-image>".
"<cpp-header-border-color>"."</cpp-header-border-color>".
"<cpp-header-back-color>"."</cpp-header-back-color>".
"<cpp-payflow-color>"."</cpp-payflow-color>".
"<PaymentAction>"."Sale"."</PaymentAction>".
"<Address>".
"<Name>".$SHIPTONAME."</Name>".
"<Street1>".$SHIPTOSTREET."</Street1>".
"<Street2>".$SHIPTOSTREET2."</Street2>".
"<CityName>".$SHIPTOCITY."</CityName>".
"<StateOrProvince>".$SHIPTOSTATE."</StateOrProvince>".
"<PostalCode>".$SHIPTOZIP."</PostalCode>".
"<Country>".$SHIPTOCOUNTRYCODE."</Country>".
"</Address>".
"<SolutionType>"."Sole"."</SolutionType>".
"<LandingPage>"."Billing"."</LandingPage>".
"</SetExpressCheckoutRequestDetails>".
"</SetExpressCheckoutRequest>".
"</SetExpressCheckoutReq>".
"</soap:Body>".
"</soap:Envelope>";

After:

$msg .="<cpp-header-image>".$url."/ppec/ppec_image/".LOGO."</cpp-header-image>".
"<cpp-header-border-color>"."</cpp-header-border-color>".
"<cpp-header-back-color>"."</cpp-header-back-color>".
"<cpp-payflow-color>"."</cpp-payflow-color>".
"<PaymentAction>"."Sale"."</PaymentAction>".
"<ShipToAddress>".
"<Name>".$SHIPTONAME."</Name>".
"<Street1>".$SHIPTOSTREET."</Street1>".
"<Street2>".$SHIPTOSTREET2."</Street2>".
"<CityName>".$SHIPTOCITY."</CityName>".
"<StateOrProvince>".$SHIPTOSTATE."</StateOrProvince>".
"<PostalCode>".$SHIPTOZIP."</PostalCode>".
"<Country>".$SHIPTOCOUNTRYCODE."</Country>".
"</ShipToAddress>".
"<SolutionType>"."Sole"."</SolutionType>".
"<LandingPage>"."Billing"."</LandingPage>".
"</SetExpressCheckoutRequestDetails>".
"</SetExpressCheckoutRequest>".
"</SetExpressCheckoutReq>".
"</soap:Body>".
"</soap:Envelope>";

Now paypal Express checkout working fine…..

USPS 5.1.0 shipping method with Oscommerce

Step 1: Remove USPS module from within admin panel

Step 2: Upload and overwrite below files
includes/modules/shipping/usps.php
includes/languages/english/modules/shipping/usps.php
If your store has another languages, put this file into other language directories includes/languages//modules/shipping/usps.php;
Translate and edit its content

Step 3: In admin/includes/functions/general.php
FIND:

function tep_mod_select_option($select_array, $key_name, $key_value) 
{
     reset($select_array);
     while (list($key, $value) = each($select_array)) 
     {
     if (is_int($key)) $key = $value;
     $string .= '<br><input type="radio" name="configuration[' . $key_name . ']" value="' . $key . '"';
     if ($key_value == $key) $string .= ' CHECKED';
     $string .= '> ' . $value;
    }
    return $string;
  } 

ADD AFTER ABOVE CODE:

		// USPS Methods - credit to Greg Deeth
		  function tep_cfg_select_multioption($select_array, $key_value, $key = '') {
		    for ($i=0; $i<sizeof($select_array); $i++) {
		      $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
		      $string .= '<br><input type="checkbox" name="' . $name . '" value="' . $select_array[$i] . '"';
		      $key_values = explode( ", ", $key_value);
		      if ( in_array($select_array[$i], $key_values) ) $string .= ' CHECKED';
		      $string .= '> ' . $select_array[$i];
		    }
		    $string .= '<input type="hidden" name="' . $name . '" value="--none--">';
		    return $string;
		  }
		  function tep_cfg_multiinput_list($select_array, $key_value, $key = '') {
		    $key_values = explode( ", ", $key_value);
		
		    for ($i=0; $i<sizeof($select_array); $i++) {
		      $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
		      $string .= '<br><input type="text" name="' . $name . '" value="' . $key_values[$i] . '"> ' . $select_array[$i];
		    }
		    $string .= '<input type="hidden" name="' . $name . '" value="--none--">';
		    return $string;
		  }
		  function tep_cfg_multiinput_duallist_oz($select_array, $key_value, $key = '') {
		    $key_values = explode( ", ", $key_value);
		    $string .= '<center>';
		    for ($i=0; $i<sizeof($select_array); $i++) {
			$current_key_value = current($key_values);
		      $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
		      $string .= '<br><input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>oz</i>';
			$string .= ' <b><</b> ' . $select_array[$i] . ' <u><b><</b></u>';
			next($key_values);
			$current_key_value = current($key_values);
			$string .= '<input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>oz</i>';
			next($key_values);
		    }
		    $string .= '<input type="hidden" name="' . $name . '" value="--none--">';
		    $string .= '</center>';
		    return $string;
		  }
		  function tep_cfg_multiinput_duallist_lb($select_array, $key_value, $key = '') {
		    $key_values = explode( ", ", $key_value);
		    $string .= '<center>';
		    for ($i=0; $i<sizeof($select_array); $i++) {
			$current_key_value = current($key_values);
		      $name = (($key) ? 'configuration[' . $key . '][]' : 'configuration_value');
		      $string .= '<br><input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>lbs</i>';
			$string .= ' <b><</b> ' . $select_array[$i] . ' <u><b><</b></u>';
			next($key_values);
			$current_key_value = current($key_values);
			$string .= '<input type="text" name="' . $name . '" size="3" value="' . $current_key_value . '"><i>lbs</i>';
			next($key_values);
		    }
		    $string .= '<input type="hidden" name="' . $name . '" value="--none--">';
		    $string .= '</center>';
		    return $string;
		  }

FIND:

// Calculates Tax rounding the result
  function tep_calculate_tax($price, $tax) 
{
    return $price * $tax / 100;
  }

ADD AFTER ABOVE CODE:

// Round up function for non whole numbers by GREG DEETH
// The value for the precision variable determines how many digits after the decimal and rounds the last digit up to the next value
// Precision = 0 -> xx.xxxx = x+
// Precision = 1 -> xx.xxxx = xx.+
// Precision = 2 -> xx.xxxx = xx.x+
  function tep_round_up($number, $precision) 
{
	$number_whole = '';
	$num_left_dec = 0;
	$num_right_dec = 0;
	$num_digits = strlen($number);
	$number_out = '';
	$i = 0;
	while ($i + 1 <= strlen($number))
	{
		$current_digit = substr($number, $i, ($i + 1) - $num_digits);
		if ($current_digit == '.') {
			$i = $num_digits + 1;
			$num_left_dec = strlen($number_whole);
			$num_right_dec = ($num_left_dec + 1) - $num_digits;
		} else {
			$number_whole = $number_whole . $current_digit;
			$i = $i + 1;
		}
	}
	if ($num_digits > 3 && $precision < ($num_digits - $num_left_dec - 1) && $precision >= 0) {
		$i = $precision;
		$addable = 1;
		while ($i > 0) {
			$addable = $addable * .1;
			$i = $i - 1;
		} 
		$number_out = substr($number, 0, $num_right_dec + $precision) + $addable;
	} else {
		$number_out = $number;
	}
	return $number_out;
  }

Step 4: In includes/functions/general.php
FIND:

// Wrapper function for round()
  function tep_round($number, $precision) {
    if (strpos($number, '.') && (strlen(substr($number, strpos($number, '.')+1)) > $precision)) {
      $number = substr($number, 0, strpos($number, '.') + 1 + $precision + 1);

      if (substr($number, -1) >= 5) {
        if ($precision > 1) {
          $number = substr($number, 0, -1) + ('0.' . str_repeat(0, $precision-1) . '1');
        } elseif ($precision == 1) {
          $number = substr($number, 0, -1) + 0.1;
        } else {
          $number = substr($number, 0, -1) + 1;
        }
      } else {
        $number = substr($number, 0, -1);
      }
    }

    return $number;
  }

ADD AFTER ABOVE CODE:

// Round up function for non whole numbers by GREG DEETH
// The value for the precision variable determines how many digits after the decimal and rounds the last digit up to the next value
// Precision = 0 -> xx.xxxx = x+
// Precision = 1 -> xx.xxxx = xx.+
// Precision = 2 -> xx.xxxx = xx.x+
  function tep_round_up($number, $precision) {
	$number_whole = '';
	$num_left_dec = 0;
	$num_right_dec = 0;
	$num_digits = strlen($number);
	$number_out = '';
	$i = 0;
	while ($i + 1 <= strlen($number))
	{
		$current_digit = substr($number, $i, ($i + 1) - $num_digits);
		if ($current_digit == '.') {
			$i = $num_digits + 1;
			$num_left_dec = strlen($number_whole);
			$num_right_dec = ($num_left_dec + 1) - $num_digits;
		} else {
			$number_whole = $number_whole . $current_digit;
			$i = $i + 1;
		}
	}
	if ($num_digits > 3 && $precision < ($num_digits - $num_left_dec - 1) && $precision >= 0) {
		$i = $precision;
		$addable = 1;
		while ($i > 0) {
			$addable = $addable * .1;
			$i = $i - 1;
		} 
		$number_out = substr($number, 0, $num_right_dec + $precision) + $addable;
	} else {
		$number_out = $number;
	}
	return $number_out;
  }

Step 5: In admin/modules.php (only much older versions will need this)
FIND:

if (tep_not_null($action)) {
    switch ($action) {
      case 'save':
        while (list($key, $value) = each($HTTP_POST_VARS['configuration'])) {

ADD AFTER ABOVE CODE:

  if( is_array( $value ) )
{
          $value = implode( ", ", $value);
  $value = ereg_replace (", --none--", "", $value);
}

Step 6: SQL changes
Phpmyadmin
configuration table –> structure
edit set_function from 255 to 1020

Step 7: Install USPS module from admin panel and configure

TIPS:
1. phpMyAdmin to update the database -> configuration TABLE
and CHANGE “set_function” to TEXT from VARCHAR.
Afterwards:
A. Remove the USPS module in the admin
B. Re-install the USPS module in the admin
C. The options will appear

2. Make sure you have set your store’s country and postal code in admin -> Configuration -> Shipping/Packaging, as these are used in the rate quote request and if not valid will cause an error.

3. Check for configuration Shipping / Packaging link for Country of Origin and Postal code
This will affect to display USPS shipping rate so please set the value.

Hope it will help you….