Jump to content

array Fatal error: Unsupported operand types


mrooks1984

Recommended Posts

hello, i am trying to get my array result to keep adding up the result into the $option_price varible, but i am getting this message:

 

Fatal error: Unsupported operand types on line 209

 

so put that part of the code on here to see if someone can help.

 

$option_price = '0.00';
		foreach ($product_option_prices as $product_option_price) {
			$option_price .= $option_price + $product_option_price['option_price'];
		}

 

thanks all

$product_option_prices['option_price'] is another array. That is why you're getting the unsupported operand type error; you're attempting to do 4.125 + array. You can see why that won't work, yes?

hi, i this is how i am getting the information into the array

 

		//get option prices
		foreach($_POST['option_price'] as $key => $value){
			if($value !=''){	
				$product_option_prices[] = array("option_price" => $_POST['option_price']);
			}
		}

and this is the price bit again

 

this is the full print out: Array ( [option_value] => Array ( [1] => Black [2] => Bacon ) ) Array ( [0] => Array ( [option_price] => Array ( [1] => 5.00 [2] => 0.00 ) ) [1] => Array ( [option_price] => Array ( [1] => 5.00 [2] => 0.00 ) ) ) 0

		$option_price = 0;
		if (isset($product_option_values)) {
		foreach ($product_option_values as $product_option_value);
		foreach ($product_option_prices as $product_option_price) {
			//$option_price += $product_option_price['option_price'];
		}
		print_r($product_option_value);
		print_r($product_option_prices);

		}

i thought this is how i call that array  $product_option_price['option_price'];?

hello, hoping someone can help i am stuck on the last bit.

 

		if (isset($product_option_values)) {
		foreach ($store_variations_values as $store_variation_values) {
		foreach ($product_option_values as $product_option_value) {
			if($product_option_value == $store_variation_values['title']) {
				$option_value_price += $store_variation_values['price'];
			}
			}	
		}

 

the code above doesent seem to be working i am getting no errors but its not adding it up the if($product_option_value == $store_variation_values['title']) is supposed to compare the option value and get the price for that item from the array, its working it out as 0 and should be 23 including the second value of the loop (1 is 22 and the other is 1) hoping someone could point out were i have gone wrong.

Archived

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

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