if ($API->getCustomerByName($customers_name, '_quickbooks_ca_customer_getbyname_callback', $primary_key_of_customer_in_your_application)) {
    print 'Queued up a request to fetch a customer named "' . $customers_name . '"!' . "\n";
}
// Adding a new customer to QuickBooks
//
// This example shows how to queue up a request to add a new customer to
//	QuickBooks. Remember that the Name element of a customer is unique within
//	QuickBooks, and the request will fail and send you back an error message if
//	another customer in QuickBooks already has that name.
$name = 'Shannon\'s Company (' . mt_rand() . ')';
$fname = 'Shannon';
$lname = 'Daniels';
// (the mt_rand() call is just so I don't get duplicate customer errors while testing)
$Customer = new QuickBooks_Object_Customer();
// This is a unique name (usually a company name) for the customer
$Customer->setName($name);
$Customer->setFirstName($fname);
$Customer->setLastName($lname);
$Customer->setShipAddress('134 Stonemill Road', '', '', '', '', 'Toronto', '', 'Ontario', 'H1B 12L', 'Canada');
// Country
$Customer->setMiddleName('B.');
$Customer->setSalutation('Ms.');
$Customer->setPhone('1.860.634.1602');
// Queue up the actual request to be sent to QuickBooks via the Web Connector
//
// Notice that we also provide the primary key of this customer from within our
//	application, so we can create a mapping which maps this customer to the
//	QuickBooks primary key.
//
// We also provide a priority, we want to make sure that this request runs
//	*before* the request below, because we need to create the customer *before*
Example #2
0
 public static function listEstimatesModifiedAfter($method, $action, $ID, $err, $qbxml, $Iterator, $qbres)
 {
     $API = QuickBooks_API_Singleton::getInstance();
     $Integrator = QuickBooks_Integrator_Singleton::getInstance();
     while ($Estimate = $Iterator->next()) {
         // Let's check if this estimate already exists in the system
         $EstimateID = null;
         if ($API->hasApplicationID(QUICKBOOKS_OBJECT_ESTIMATE, $Estimate->getTxnID())) {
             $EstimateID = $API->fetchApplicationID(QUICKBOOKS_OBJECT_ESTIMATE, $Estimate->getTxnID());
         }
         // Now, there's a customer assigned to this estimate, let's make sure the customer exists
         if ($API->hasApplicationID(QUICKBOOKS_OBJECT_CUSTOMER, $Estimate->getCustomerListID())) {
             // Great, it exists!
         } else {
             // Uh oh... create it!
             $Customer = new QuickBooks_Object_Customer();
             $Customer->setListID($Estimate->getCustomerListID());
             $Customer->setName($Estimate->getCustomerName());
             $Integrator->setCustomer(null, $Customer);
         }
         // There are line items assigned to this estimate too, and each line item has a product...
         //foreach ($Estimate->listLineItems
         $Integrator->setEstimate($EstimateID, $Estimate);
     }
     return true;
 }