Jump to content

Recommended Posts

So I am getting this error:

 

Fatal error: Unsupported operand types in /hsphere/local/home/nalsa1/beta.nalsa.com/of/order.php on line 152

 

In order.php:

 

151    $Price = $cost->getPrice($Qtyset, $Qtypd, $Qtygs, $Qtylf, $Qtymes, $Qtybdmm, $Qtycds);

152    $Tax = $cost->getTax($ShipState, $Price);

153    $Shipping = $cost->getShipping($ShipCountry, $ShipState, $Qtyset, $QtyDivision);

154    $Total = sprintf('%.2f', $Price + $Tax + $Shipping);

 

I am sure the problem lies in line 153 the call to function getShipping.

 

The code for that function is as follows:

 

	function getShipping($ShipCountry, $ShipState, $Qtyset, $QtyDivision) 

		{

		if ($ShipCountry == "United States") 

			{
							switch ($ShipState) 
							{

							case 'USVI':
							break;

							case 'Alaska':
							break;


							case 'Hawaii':
							break;

							case 'Puertorico':
							break;

							//SHIPPING RULES FOR CONTIGUOUS USA
							default:

								if ($Qtyset == 1) {

									$Shipping = array
									(
									 "method 1" => array
									 (
									  "method" => "UPS Ground",
									  "price" => "12.00",
									 ),

									 "method 2" => array
									 (
									  "method" => "UPS Second Day Air",
									  "price" => "20.00",)
									 );

								return $Shipping;	

								} else if ($Qtyset > 2) {
									return false;
								} else if ($QtyDivision <= 2) {
									return false;
								} else if ($QtyDivision >= 3) {
									return false;
								}



							}

							}													}     

						}
}

 

 

When I comment out line 152 everthing works as usual. I did a var_dump on the variables which are passed to the function:

 

string(13) "United States" string(8) "New York" string(1) "1" int(0)

 

I'm not sure why $Qtyset is a string when it should be an int, but I tried changing the if statement in the function to if ($Qtyset == "1") to match the string but that didn't work. Any help would be much appreciated!

Link to comment
https://forums.phpfreaks.com/topic/53353-php-fatal-error/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.