Jump to content


Corporate Sponsors


Latest News: (loading..)

- - - - -

help with fedex web services


7 replies to this topic

#1 techs21

  • Community Member
  • 238 posts
  • Real Name:adam

Posted 08 August 2011, 21:10

I am having a problem with this add-on when a customer tries to pay for an order via paypal they get this error
Fatal error: Cannot redeclare cmp() (previously declared in /home2/techsonh/public_html/includes/modules/shipping/fedexwebservices.php:225) in /home2/techsonh/public_html/includes/modules/shipping/fedexwebservices.php on line 225

paypal and fedex said its not them so I need to see if I can get this fixed

any help appreciated thanks

#2 ckpepper02

  • Community Member
  • 27 posts
  • Real Name:Chris
  • Gender:Male
  • Location:USA

Posted 09 December 2011, 21:19

I need this answer also!

#3 web-project

  • Community Member
  • 4,310 posts
  • Real Name:Alex
  • Gender:Male
  • Location:Hertfordshire, UK

Posted 09 December 2011, 21:35

post the code of fedexwebservices.php on line 225, please?
Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!
8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.
Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.
Any issues with oscommerce, I am here to help you.

#4 ckpepper02

  • Community Member
  • 27 posts
  • Real Name:Chris
  • Gender:Male
  • Location:USA

Posted 10 December 2011, 17:58

Line 225 starts here:

function cmp($a, $B) {
   if ($a['cost'] == $b['cost']) {
	 return 0;
   }
   return ($a['cost'] < $b['cost']) ? -1 : 1;
  }  
 
  usort($methods, 'cmp');

I tested and turns out that this error only occurs when using Paypal Express payment module with it. After the users selects shipping, they are sent to paypal to log in. This error shows up when paypal sends them back to checkout.

#5 web-project

  • Community Member
  • 4,310 posts
  • Real Name:Alex
  • Gender:Male
  • Location:Hertfordshire, UK

Posted 10 December 2011, 21:08

why:
function cmp($a, $B ) {

as it should be:
function cmp($a, $b ) {

you have the issue that the cmp() function is declared twice, as for the rest of code is fine, looking on example from the php.net and comparing to the following code:
<?php
function cmp($a, $b )
{
	if ($a == $b {
		return 0;
	}
	return ($a < $b ? -1 : 1;
}
$a = array(3, 2, 5, 6, 1);
usort($a, "cmp");
foreach ($a as $key => $value) {
	echo "$key: $value\n";
}
?>
http://php.net/manua...ction.usort.php
Please read this line: Do you want to find all the answers to your questions? click here. As for contribution database it's located here!
8 people out of 10 don't bother to read installation manuals. I can recommend: if you can't read the installation manual, don't bother to install any contribution yourself.
Before installing contribution or editing/updating/deleting any files, do the full backup, it will save to you & everyone here on the forum time to fix your issues.
Any issues with oscommerce, I am here to help you.

#6 ckpepper02

  • Community Member
  • 27 posts
  • Real Name:Chris
  • Gender:Male
  • Location:USA

Posted 10 December 2011, 23:37

I don't know why the code pasted in with a captial '$B', but it's a '$b' in the code as well.

#7 ckpepper02

  • Community Member
  • 27 posts
  • Real Name:Chris
  • Gender:Male
  • Location:USA

Posted 12 December 2011, 15:51

Still have not fixed the issue. But I did see that the cmp function was wrapped inside a foreach method. Tried moving it outside of that foreach and I got the same error on a different line. So no real progress here.

#8 jerrygarciuh

  • Community Member
  • 10 posts
  • Real Name:David Martin

Posted 28 March 2012, 17:47

This can be fixed like so:



if (!function_exists('cmp')) {
	function cmp($a, $B) {
		if ($a['cost'] == $b['cost']) {
			return 0;
		}
		return ($a['cost'] < $b['cost']) ? -1 : 1;
	}
}

Edited by jerrygarciuh, 28 March 2012, 17:49.