douwenan9849 2014-01-26 19:56
浏览 34
已采纳

QuickBooks Web API - 使用consolibyte PHP框架。 - 客户的帐单邮寄地址查询?

I am trying to create a php application that will sync data to QuickBooks. I am using the consolibyte PHP framework/examples. The examples are pretty good, but I am have a very hard time understanding how I can query customer data and print the customer's billing address.

Here is the sample code that works well, for printing the customer's name and id. If you have experience with this framework, I would greatly appreciate any help!

$clientName  = $_POST["clientName"]; 
    // Set the IPP version to v3 
    $IPP->version(QuickBooks_IPP_IDS::VERSION_3);

    $CustomerService = new QuickBooks_IPP_Service_Customer();

    $customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer WHERE CompanyName like '%$clientName%'");



    print '~{"response":[';
    foreach ($customers as $Customer)
    {

        $customerID = str_replace("{-", "", $Customer->getId());
        $customerID = str_replace("}", "", $customerID);

        print('{"QB_customerAddress":"'.$Customer->SHOW BILLING ADDRESS HERE.'", "QB_customerId":"' . $customerID . '", "QB_customerName":"' . $Customer->getFullyQualifiedName().'"},');
    }
    print ']}~=';
  • 写回答

1条回答 默认 最新

  • dqk77945 2014-01-26 21:04
    关注

    The object model follows the Intuit XML/JSON schema exactly.

    So, start by taking a look at Intuit's documentation:

    You'll notice from the documentation that the Customer object has a BillAddr object. For example, quoting from the Intuit docs:

    BillAddr
     data type: PhysicalAddress
     description: Default billing address.
    

    So, not surprisingly, you'll find that your QuickBooks_IPP_Object_Customer object is going to have some methods like:

    // This returns a QuickBooks_IPP_Object_BillAddr object
    $BillAddr = $Customer->getBillAddr();
    
    // This accepts a QuickBooks_IPP_Object_BillAddr object as a parameter
    $Customer->setBillAddr($BillAddr);
    

    If you dig into Intuit's documentation further, you'll notice that the BillAddr node has these bits of data in it:

    Line1
     data type: String
     description: First line of the address.
    
    City
     data type: string
     description: City name.
    
    etc. etc. etc. ...
    

    So... naturally, the address object you got above has methods like:

    $line1 = $BillAddr->getLine1();   // Get the first line of the address
    $BillAddr->setLine1($line1);   // Set the first line of the address
    
    $city = $BillAddr->getCity();   // Get the city name
    $BillAddr->setCity($city);   // Set the city name 
    
     etc. etc. etc. ... 
    

    The objects literally follow EXACTLY what is shown in Intuit's documentation. Also, did you try print_r($Customer);? print_r() will show you pretty much everything the object contains generally.

    So, to get a full address, you'd end up with something like:

    $billaddr = $Customer->getBillAddr();
    
    $addr = '';
    $addr .= $billaddr->getLine1() . "
    <br>";
    $addr .= $billaddr->getLine2() . "
    <br>";
    $addr .= $billaddr->getLine3() . "
    <br>";
    $addr .= $billaddr->getCity() . ',  ' . $billaddr->getCountrySubDivisionCode() . ' ' . $billaddr->getPostalCode() . "
    <br>";
    $addr .= $billaddr->getCountry();
    
    print($addr);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 关于#html5#的问题:H5页面用户手机返回的时候跳转到指定页面例如(语言-javascript)
  • ¥15 无法使用此凭据登录,因为你的域不可用,如何解决?(标签-Windows)
  • ¥15 yolov9的训练时间
  • ¥15 二叉树遍历没有报错但无法正常运行
  • ¥15 在linux系统下vscode运行robocup3d上场球员报错
  • ¥15 Python语言实验
  • ¥15 SAP HANA SQL 增加合计行
  • ¥20 用C#语言解决一个英文打字练习器,有偿
  • ¥15 srs-sip外部服务 webrtc支持H265格式
  • ¥15 在使用abaqus软件中,继承到assembly里的surfaces怎么使用python批量调动