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);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题