Jump to content

PHP If else statement with exception


spaceranger

Recommended Posts

i have some code that im editing for an auction website, the thing is that i need the $all_unpaid = false if the bid_amount is zero, I tried several tweaks but no results, perhaps some1 can have some suggestions?

 

 

function direct_payment_multiple ($invoice_id, $items_array, $dp_array, $buyer_id)
{
	$output = false;

	$nb_sub_arrays = count($dp_array);
	if ($nb_sub_arrays)
	{
		$array_result = $dp_array[0];

		for ($i=1; $i<$nb_sub_arrays; $i++)
		{
			$array_result = @array_intersect($array_result, $dp_array[$i]);
		}

		$all_unpaid = true;
		for ($i=0; $i<$nb_sub_arrays; $i++)
		{
			$all_unpaid = (!$items_array[$i]['direct_payment_paid'] && !$items_array[$i]['flag_paid'] && $items_array[$i]['bid_amount'] > 0) ? $all_unpaid : false;
		}

		$same_currency = true;
		$currency = $items_array[0]['currency'];
		for ($i=0; $i<$nb_sub_arrays; $i++)
		{
			$same_currency = ($currency == $items_array[$i]['currency']) ? $same_currency : false;
		}
	}

	$output = (is_array($array_result) && $all_unpaid) ? true : false;

	return $output;
}

 

some overview some overview, this auction website allows users to place a bid of 0.00, if no-one outbids them then they get the item for free, however if someone does outbid them then regular code applies so if payment has been made and is greater then zero then all_unpaid is true, if payment equal to zero or there is no payment then all_unpaid is false

 

spam removed

Link to comment
https://forums.phpfreaks.com/topic/258124-php-if-else-statement-with-exception/
Share on other sites

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.