Closed irricheck closed 2 years ago
The LineItems should be an array, and you are creating the array here:
$arr_lineitems=[];
array_push($arr_lineitems, $lineitem);
However you are then only passing a single item in here:
$invoice->setLineItems($lineitem);
Does it work any better if you change it to:
$invoice->setLineItems($arr_lineitems);
?
Hey @irricheck We've tested this locally and cannot replicate your function not defined issue. Additionally, confirmed the method is available on the Invoice model.
/**
* Sets line_items
*
* @param \XeroAPI\XeroPHP\Models\Accounting\LineItem[]|null $line_items See LineItems
*
* @return $this
*/
public function setLineItems($line_items)
{
$this->container['line_items'] = $line_items;
return $this;
}
Please reopen the issue if your still experiencing the error
When I create a new invoice, I get an error that setLineItems is not valid, yet all samples I can find online says its the way to add the line items to an invoice before creating it. Must be missing something
here is my code: