Search code examples
phpinfusionsoft

Infusionsoft API fetch order details todays order, yesterdays orders, last 7 days order details


I am using insufionsoft php API to fetch the details of orders for generating some stats for my reports page. I want to get the details of todays order, yesterdays order, last 7 days orders. I have connected using the API and able to fetch the contact details but I am not able to find any documentation related to fetch order details.

I have connected in this way to fetch contact using email

require_once("../src/isdk.php");
$app = new iSDK;
$app->cfgCon("gtrrde", "<Infusionsoft API key replaced>");
$contacts = $app->findByEmail('[email protected]', array('Id', 'FirstName', 'LastName', 'Email'));

How can I fetch all Order details ??


Solution

  • You're going to want to use a DataService.query to query the Invoice or Job Tables. Since it appears you're using the PHP SDK, your queries will look something like the following:

    $order_details = $app->dsQuery( 
                               (str)$table_name, 
                               (int)$number_of_records_to_return,
                               (int)$page, 
                               (struct)$query,
                               (array)$fields_to_return
                           );    
    

    So, following this pattern, here would be a sample Job Table query to return all Jobs from a specified $date (in the InfusionSoft format):

    Job Table Query:

    $returnFields = array('Id','ShipFirstName', 'ShipLastName');
    $query = array('DateCreated' => $date);
    $jobs = $app->dsQuery("Job", 10, 0, $query, $returnFields);