Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7599985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:47:58+00:00 2026-05-30T22:47:58+00:00

i have some code that im editing for an auction website, the thing is

  • 0

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

hey @TecBrat, i deleted this line

$all_unpaid = (!$items_array[$i]['direct_payment_paid'] && !$items_array[$i]['flag_paid'] && $items_array[$i]['bid_amount'] > 0) ? $all_unpaid : false; 

and replaced it with this

$all_unpaid =true;
if ((!$items_array[$i]['direct_payment_paid'] && !$items_array[$i]['flag_paid'] )
    || !$items_array[$i]['bid_amount'] > 0)
  {
    $all_unpaid =false;
  }

however it seems to do the same as b4

i changed it to this

                $all_unpaid =true;
if (($items_array[$i]['direct_payment_paid'] || $items_array[$i]['flag_paid'] )
    || $items_array[$i]['bid_amount'] > 0)
  {
    $all_unpaid =false;
  }

still appears to be the same as b4

currently this is what im working with

    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 =true; if (($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;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:47:59+00:00Added an answer on May 30, 2026 at 10:47 pm

    this line:

    $all_unpaid = (!$items_array[$i]['direct_payment_paid'] && !$items_array[$i]['flag_paid'] && $items_array[$i]['bid_amount'] > 0) ? $all_unpaid : false;
    

    is a good example of why I prefer this style:

    if(condition){do stuff}
    

    I think I translated that correctly as

    if (!$items_array[$i]['direct_payment_paid'] 
        && !$items_array[$i]['flag_paid'] 
        && $items_array[$i]['bid_amount'] > 0)
      {
        $all_unpaid =$all_unpaid;
      }
    else
      {
        $all_unpaid = false
      } 
    

    …

    I tested this script at http://www.tecbrat.com/conditional_testing.php

    <?php
    
    $items_array['direct_payment_paid']=(int)$_GET['direct_payment_paid'];
    $items_array['flag_paid']=(int)$_GET['flag_paid'];
    $items_array['bid_amount']=$_GET['bid_amount'];
    
    // simplified from //function direct_payment_multiple ($invoice_id, $items_array, $dp_array, $buyer_id)    
    function direct_payment_multiple_tester ($items_array)
      {
        $all_unpaid =true;
        if ($items_array['direct_payment_paid'] || $items_array['flag_paid']
            || !$items_array['bid_amount'] > 0)
          {
            $all_unpaid =false;
          }
        return $all_unpaid;
      }
    
    if (direct_payment_multiple_tester ($items_array))
      {
        echo "we still need payment";
      }
     else
      {
        echo "We received payment, or there is no charge.";
      }
    
    echo '<pre>';
    print_r($items_array);
    echo '</pre>';
    ?>
    

    Try it with a few different query strings to see what happens.

    http://www.tecbrat.com/conditional_testing.php?direct_payment_paid=1&flag_paid=0&bid_amount=50

    http://www.tecbrat.com/conditional_testing.php?direct_payment_paid=0&flag_paid=1&bid_amount=50

    http://www.tecbrat.com/conditional_testing.php?direct_payment_paid=1&flag_paid=1&bid_amount=50

    http://www.tecbrat.com/conditional_testing.php?direct_payment_paid=0&flag_paid=0&bid_amount=0

    http://www.tecbrat.com/conditional_testing.php?direct_payment_paid=0&flag_paid=0&bid_amount=50

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that gives a user id to a utility that then
I have some code that uses the shared gateway pattern to implement an inversion
I have some code that raises PropertyChanged events and I would like to be
I have some code that looks like: template<unsigned int A, unsigned int B> int
I have some code that generates image of a pie chart. It's a general
I have some code that effectively does this : File file = new File(C:\\Program
I have some code that I am putting in the code-behind of a master
I have some code that uses the Oracle function add_months to increment a Date
I have some code that prints out databse values into a repeater control on
I have some code that produces a set of primary key values that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.