Hi all,
I'm currently using a class that integrates with our accounting system and trying to build invoices from our online payment gateway.
As part of the invoice, I'd obviously like to be able to have a list of all the 'products' being sold which need to be added line-by-line to the invoice - however, I'm having some difficulty building the array that is submitted to our accounting API to achieve this.
The code to build an invoice with two line items would be:
$new_invoice = array(
array(
"Type"=>"ACCREC",
"Contact" => array(
"ContactID" => $customer['id']
),
"Date" => date("Y-m-d"),
"DueDate" => date("Y-m-d"),
"Status" => "SUBMITTED",
"LineAmountTypes" => "Inclusive",
"LineItems"=> array(
"LineItem" => array(
array(
"Description" => "Item 1",
"Quantity" => "1.0000",
"UnitAmount" => "Amount 1",
"AccountCode" => "210",
"Tracking" => array(
"TrackingCategory" => array (
"Name" => "Show",
"Option" => "Tracking ID 1"
)
)
)
array(
"Description" => "Item 2",
"Quantity" => "1.0000",
"UnitAmount" => "Amount 2",
"AccountCode" => "210",
"Tracking" => array(
"TrackingCategory" => array (
"Name" => "Show",
"Option" => "Tracking ID 2"
)
)
)
)
)
)
);
Now the key part here is obviously the LineItems array - which has an array in it called "LineItem" which then has a various number of 'sub-arrays' for each line item.
What I'm basically trying to achieve would be something similar to:
"LineItems"=> array(
"LineItem" => array(
do {
array(
"Description" => "Item 1",
"Quantity" => "1.0000",
"UnitAmount" => "Amount 1",
"AccountCode" => "210",
"Tracking" => array(
"TrackingCategory" => array (
"Name" => "Show",
"Option" => "Tracking ID 1"
)
)
)
} while($row_lineitem = mysql_fetch_row($lineitem));
))
But this produces a PHP error when it encounters the WHILE statement. Any ideas how to produce something similar while avoiding this error?
Would appreciate the help! Thanks guys!
Cheers,
Jamie