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

Link to comment
Share on other sites

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'];?

Link to comment
Share on other sites

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.

Link to comment
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.