将具有地址详细信息的客户添加到 QuickBooks
我正在开发 Saas,并且一直在使用 Keith Palmer 的 PHP Dev Kit.
I'm working on a Saas and have been using Keith Palmer's PHP Dev Kit.
在大多数情况下,它运行得非常好 - 我可以下载客户、添加客户和添加发票,这正是我想要实现的.
For the most part, it has worked really well - I can download customers, add customers and add invoices which is what I wanted to achieve.
但是,在添加客户时,我似乎无法添加地址和电话详细信息.我尝试了各种策略,但都没有奏效.因为我需要在某种程度上同步数据,所以我真的需要它来添加这些字段.
However, when Adding the customer, I don't seem to be able to add the address and phone details. I've tried various strategies and none have worked. As I need to sync the data to some degree, I really need it to add these fields.
我的客户对象是用 $Customer = new QuickBooks_IPP_Object_Customer();
我尝试创建一个$Address = new QuickBooks_IPP_Object_Address()
然后在填充地址对象后使用 $Customer->addAddress($Address)
添加,但仍然没有.
I tried creating a
$Address = new QuickBooks_IPP_Object_Address()
and then adding with $Customer->addAddress($Address)
after populating the address object, but still nothing.
基本信息保存完好,但地址有什么问题?
The basic details are saved fine, but what am I doing wrong with the address?
我浏览了示例(这是我获得要保存的基本详细信息的方式),但没有看到如何添加.
I looked through the examples (which is how I got the basic details to save) but didn't see how to add this.
有人知道如何保存地址详细信息吗?
Does anyone know how to save the address details?
假设您使用的是最新的 v3 API 和来自 GitHub 的最新代码,您的代码应该如下所示:
Assuming you're using the newest, v3 APIs, and the latest code from GitHub, your code should look something like this:
$CustomerService = new QuickBooks_IPP_Service_Customer();
$Customer = new QuickBooks_IPP_Object_Customer();
$Customer->setTitle('Mr');
$Customer->setGivenName('Keith');
$Customer->setMiddleName('R');
$Customer->setFamilyName('Palmer');
$Customer->setDisplayName('Keith R Palmer Jr ' . mt_rand(0, 1000));
// Phone #
$PrimaryPhone = new QuickBooks_IPP_Object_PrimaryPhone();
$PrimaryPhone->setFreeFormNumber('860-532-0089');
$Customer->setPrimaryPhone($PrimaryPhone);
// Bill address
$BillAddr = new QuickBooks_IPP_Object_BillAddr();
$BillAddr->setLine1('72 E Blue Grass Road');
$BillAddr->setLine2('Suite D');
$BillAddr->setCity('Mt Pleasant');
$BillAddr->setCountrySubDivisionCode('MI');
$BillAddr->setPostalCode('48858');
$Customer->setBillAddr($BillAddr);
if ($resp = $CustomerService->add($Context, $realm, $Customer))
{
print('Our new customer ID is: [' . $resp . ']');
}
else
{
print($CustomerService->lastError($Context));
}
您可以在此处获取最新代码:
You can get the latest code here:
此处包含一个示例:
对象可用的方法完全反映 Intuit 定义的 XML 节点名称在他们的文档中.
The methods available for the objects exactly mirror the XML node names that Intuit defines in their docs.
所以,如果他们有一个名为:
So, if they have a node named:
- 账单地址
然后你就会有一个对应的对象:
Then you'll have a corresponding object:
- QuickBooks_IPP_Object_BillAddr
如果它们有节点名称:
- 第 1 行
- 第 2 行
- 城市
- CountrySubDivisionCode
然后你就会有相应的方法:
Then you'll have corresponding methods:
- ->setLine1($val) 和 ->getLine1()
- ->setLine2($val) 和 ->getLine2()
- ->setCity($val) 和 ->getCity()
- ->setCountrySubDivisionCode($val) 和 ->getCountrySubDivisionCode()