Quickbooks API PHP how to send invoice email to customer

one text

Solution:

It took me a couple days of searching because the documentation is no help at all but I had the exact same issue as you and could find no solution so I wanted to share. The issue is that the Select queries return an object slightly different than the FindById function.

With the Select Function, even if there is only one record returned, you will receive something like this:

Array ( [0] => QuickBooksOnline\API\Data\IPPInvoice Object ( [Deposit] => [AllowIPNPayment] => false [AllowOnlinePayment] => false [AllowOnlineCreditCardPayment] => false (etc, etc)

When you do the FindById by inserting the ID number manually (which works) the return will look like this:

QuickBooksOnline\API\Data\IPPInvoice Object ( [Deposit] => [AllowIPNPayment] => false [AllowOnlinePayment] => false [AllowOnlineCreditCardPayment] => false (etc, etc)

To resolve this I just added a line that extracts the 0 element:

$this_invoice_trimmed = $this_invoice[0];

My resultant code that worked now looks like this: (I was using DocNumber rather than ID because I did not have the ID but the concept is the same)

$dataService->throwExceptionOnError(true);
$this_invoice = $dataService->Query("select * from Invoice where DocNumber='$qbo_doc_number'");
$this_invoice_trimmed = $this_invoice[0];
    
$result = $dataService->SendEmail($this_invoice_trimmed);

Source