我正在创建几乎准备好的wordpress woocommerce网站,现在我想要的是,我想将我的所有客户,用户,订单,产品和交易等导入我的quickbook桌面。
从文档中,我已经达到了这样的程度:我可以使用此处提供的示例文件QB PHP SDK轻松地将客户从站点升级到QB桌面。
我的基本问题是,我将如何获得QBDesktop所需但在我的网站上无法获得的销售订单,采购订单等。
我还从这里创建了所有表[QB Transaction tables] [2],现在点是如何在这些表中插入数据。如果我假设我使用wordpress webhooks在这些表中输入一些信息,那么现在我所知道的字段也是如此,这个文件名也有import
数据库。那么这意味着从网站导入到QBWC或从QBDesktop导入到QBWC。
文档似乎让我感到困惑,我的最终目标是将东西从我的网站移到QBDesktop,之后我会尝试逆向过程。
更新:
我在你的sdk docs/example_app_web_connector
内做了更改。
这是qbwc.php
:
<?php
/**
* Example Web Connector application
*
* This is a very simple application that allows someone to enter a customer
* name into a web form, and then adds the customer to QuickBooks.
*
* @author Keith Palmer <keith@consolibyte.com>
*
* @package QuickBooks
* @subpackage Documentation
*/
/**
* Require some configuration stuff
*/
require_once dirname(__FILE__) . '/config.php';
/**
* Require some callback functions
*/
require_once dirname(__FILE__) . '/functions.php';
// Map QuickBooks actions to handler functions
$map = array(
QUICKBOOKS_ADD_CUSTOMER => array( '_quickbooks_customer_add_request', '_quickbooks_customer_add_response' ),
QUICKBOOKS_ADD_ITEM => array( '_quickbooks_item_add_request', '_quickbooks_item_add_response' ),
QUICKBOOKS_ADD_ESTIMATE =>array( '_quickbooks_estimate_add_request', '_quickbooks_estimate_add_response' ),
QUICKBOOKS_ADD_SALESORDER => array( '_quickbooks_salesorder_add_request', '_quickbooks_salesorder_add_response' ),
QUICKBOOKS_ADD_SALESRECEIPT => array( '_quickbooks_salesreceipt_add_request', '_quickbooks_salesreceipt_add_response' ),
QUICKBOOKS_ADD_INVOICE => array( '_quickbooks_invoice_add_request', '_quickbooks_invoice_add_response' ),
QUICKBOOKS_ADD_PURCHASEORDER => array( '_quickbooks_purchaseorder_add_request', '_quickbooks_purchaseorder_add_response' ),
);
// This is entirely optional, use it to trigger actions when an error is returned by QuickBooks
$errmap = array(
'*' => '_quickbooks_error_catchall', // Using a key value of '*' will catch any errors which were not caught by another error handler
);
// An array of callback hooks
$hooks = array(
);
// Logging level
$log_level = QUICKBOOKS_LOG_DEVELOP; // Use this level until you're sure everything works!!!
// What SOAP server you're using
$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN; // A pure-PHP SOAP server (no PHP ext/soap extension required, also makes debugging easier)
$soap_options = array( // See http://www.php.net/soap
);
$handler_options = array(
'deny_concurrent_logins' => false,
'deny_reallyfast_logins' => false,
); // See the comments in the QuickBooks/Server/Handlers.php file
$driver_options = array( // See the comments in the QuickBooks/Driver/<YOUR DRIVER HERE>.php file ( i.e. 'Mysql.php', etc. )
);
$callback_options = array(
);
// Create a new server and tell it to handle the requests
// __construct($dsn_or_conn, $map, $errmap = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_PHP, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $callback_options = array()
$Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
$response = $Server->handle(true, true);
?>
这是我的functions.php
:
<?php
/**
* Example Web Connector application
*
* This is a very simple application that allows someone to enter a customer
* name into a web form, and then adds the customer to QuickBooks.
*
* @author Keith Palmer <keith@consolibyte.com>
*
* @package QuickBooks
* @subpackage Documentation
*/
/**
* Generate a qbXML response to add a particular customer to QuickBooks
*/
function _quickbooks_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
// Grab the data from our MySQL database
$arr = mysql_fetch_assoc(mysql_query("SELECT * FROM my_customer_table WHERE id = " . (int) $ID));
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerAddRq requestID="' . $requestID . '">
<CustomerAdd>
<Name>' . $arr['name'] . '</Name>
<CompanyName>' . $arr['name'] . '</CompanyName>
<FirstName>' . $arr['fname'] . '</FirstName>
<LastName>' . $arr['lname'] . '</LastName>
</CustomerAdd>
</CustomerAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
/**
* Receive a response from QuickBooks
*/
function _quickbooks_customer_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
mysql_query("
UPDATE
my_customer_table
SET
quickbooks_listid = '" . mysql_real_escape_string($idents['ListID']) . "',
quickbooks_editsequence = '" . mysql_real_escape_string($idents['EditSequence']) . "'
WHERE
id = " . (int) $ID);
}
/**
* Catch and handle an error from QuickBooks
*/
function _quickbooks_error_catchall($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg)
{
mysql_query("
UPDATE
my_customer_table
SET
quickbooks_errnum = '" . mysql_real_escape_string($errnum) . "',
quickbooks_errmsg = '" . mysql_real_escape_string($errmsg) . "'
WHERE
id = " . (int) $ID);
}
/*-------------------------------------------------------new---------------------------------------*/
/**
* Generate a qbXML response to add a particular Items to QuickBooks
*/
function _quickbooks_item_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
// Grab the data from our MySQL database
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<ItemInventoryAddRq requestID="' . $requestID . '">
<ItemInventoryAdd>
<Name>Item Name 1</Name>
<SalesDesc>your sales description here</SalesDesc>
<SalesPrice>85.00</SalesPrice>
<IncomeAccountRef>
<FullName>Sales</FullName>
</IncomeAccountRef>
<COGSAccountRef>
<FullName>Cost of Goods Sold</FullName>
</COGSAccountRef>
<AssetAccountRef>
<FullName>Inventory Asset</FullName>
</AssetAccountRef>
</ItemInventoryAdd>
</ItemInventoryAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
/**
* Receive a response from QuickBooks
*/
function _quickbooks_item_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
}
/**
* Generate a qbXML response to add a particular Estimate to QuickBooks
*/
function _quickbooks_estimate_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
// Grab the data from our MySQL database
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<EstimateAddRq requestID="' . $requestID . '">
<EstimateAdd>
<CustomerRef>
<FullName>Keith Company</FullName>
</CustomerRef>
<TxnDate>2007-12-14</TxnDate>
<RefNumber>9668</RefNumber>
<BillAddress>
<Addr1>56 Cowles Road</Addr1>
<City>Willington</City>
<State>CT</State>
<PostalCode>06279</PostalCode>
<Country>United States</Country>
</BillAddress>
<EstimateLineAdd>
<ItemRef>
<FullName>Item Name 1</FullName>
</ItemRef>
<Desc>Item 1 Description Goes Here</Desc>
<Quantity>1</Quantity>
<Rate>295</Rate>
</EstimateLineAdd>
<EstimateLineAdd>
<ItemRef>
<FullName>Item Name 2</FullName>
</ItemRef>
<Desc>Item 2 Description Goes Here</Desc>
<Quantity>3</Quantity>
<Rate>25</Rate>
</EstimateLineAdd>
</EstimateAdd>
</EstimateAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
/**
* Receive a response from QuickBooks
*/
function _quickbooks_estimate_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
}
/**
*
* @param string $requestID You should include this in your qbXML request (it helps with debugging later)
* @param string $action The QuickBooks action being performed (CustomerAdd in this case)
* @param mixed $ID The unique identifier for the record (maybe a customer ID number in your database or something)
* @param array $extra Any extra data you included with the queued item when you queued it up
* @param string $err An error message, assign a value to $err if you want to report an error
* @param integer $last_action_time A unix timestamp (seconds) indicating when the last action of this type was dequeued (i.e.: for CustomerAdd, the last time a customer was added, for CustomerQuery, the last time a CustomerQuery ran, etc.)
* @param integer $last_actionident_time A unix timestamp (seconds) indicating when the combination of this action and ident was dequeued (i.e.: when the last time a CustomerQuery with ident of get-new-customers was dequeued)
* @param float $version The max qbXML version your QuickBooks version supports
* @param string $locale
* @return string A valid qbXML request
*/
function _quickbooks_salesreceipt_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
/*
<CustomerRef>
<ListID>80003579-1231522938</ListID>
</CustomerRef>
*/
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<SalesReceiptAddRq requestID="' . $requestID . '">
<SalesReceiptAdd>
<CustomerRef>
<FullName>Keith Palmer Jr.</FullName>
</CustomerRef>
<TxnDate>2009-01-09</TxnDate>
<RefNumber>16466</RefNumber>
<BillAddress>
<Addr1>Keith Palmer Jr.</Addr1>
<Addr3>134 Stonemill Road</Addr3>
<City>Storrs-Mansfield</City>
<State>CT</State>
<PostalCode>06268</PostalCode>
<Country>United States</Country>
</BillAddres>
<SalesReceiptLineAdd>
<ItemRef>
<FullName>Gift Certificate</FullName>
</ItemRef>
<Desc>$25.00 gift certificate</Desc>
<Quantity>1</Quantity>
<Rate>25.00</Rate>
<SalesTaxCodeRef>
<FullName>NON</FullName>
</SalesTaxCodeRef>
</SalesReceiptLineAdd>
<SalesReceiptLineAdd>
<ItemRef>
<FullName>Book</FullName>
</ItemRef>
<Desc>The Hitchhiker\'s Guide to the Galaxy</Desc>
<Amount>19.95</Amount>
<SalesTaxCodeRef>
<FullName>TAX</FullName>
</SalesTaxCodeRef>
</SalesReceiptLineAdd>
</SalesReceiptAdd>
</SalesReceiptAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
/**
* Receive a response from QuickBooks
*/
function _quickbooks_salesreceipt_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
}
function _quickbooks_salesorder_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<SalesOrderAddRq requestID="' . $requestID . '">
<SalesOrderAdd>
<CustomerRef>
<FullName>BhagyaMazire</FullName>
</CustomerRef>
<TxnDate>2013-05-23</TxnDate>
<RefNumber>23112628110</RefNumber>
<BillAddress>
<Addr1>Pam Barker</Addr1>
<Addr2>500 Kirts Boulevard</Addr2>
<Addr3/>
<City>Troy</City>
<State>Mi</State>
<PostalCode>48084</PostalCode>
<Country>US</Country>
</BillAddress>
<ShipAddress>
<Addr1/>
<Addr2>7322 Southwest Freeway </Addr2>
<Addr3>Ste, 170</Addr3>
<City>Houston</City>
<State>TX</State>
<PostalCode>77074</PostalCode>
<Country>US</Country>
</ShipAddress>
<ItemSalesTaxRef>
<FullName>Out of State</FullName>
</ItemSalesTaxRef>
<Memo>Shipping to Pinnacle Senior Care Houston </Memo>
<SalesOrderLineAdd>
<ItemRef>
<FullName>Booklets:CB1-101</FullName>
</ItemRef>
<Desc>CHF</Desc>
<Quantity>15</Quantity>
<Amount>59.25</Amount>
</SalesOrderLineAdd>
<SalesOrderLineAdd>
<ItemRef>
<FullName>Booklets:CB3-101</FullName>
</ItemRef>
<Desc>High Blood Pressure</Desc>
<Quantity>15</Quantity>
<Amount>59.25</Amount>
</SalesOrderLineAdd>
<SalesOrderLineAdd>
<ItemRef>
<FullName>Booklets:DB1-101</FullName>
</ItemRef>
<Desc>Diabetes Type 1 or 2 with Insulin</Desc>
<Quantity>15</Quantity>
<Amount>59.25</Amount>
</SalesOrderLineAdd>
<SalesOrderLineAdd>
<ItemRef>
<FullName>Booklets:DB2-101</FullName>
</ItemRef>
<Desc>Diabetes Type 1 or 2 w/o Insulin</Desc>
<Quantity>15</Quantity>
<Amount>59.25</Amount>
</SalesOrderLineAdd>
</SalesOrderAdd>
</SalesOrderAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
/**
* Receive a response from QuickBooks
*/
function _quickbooks_salesorder_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
}
//------------ INVOICE ------------------------------
function _quickbooks_invoice_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InvoiceAddRq requestID="' . $requestID . '">
<InvoiceAdd>
<CustomerRef>
<ListID>90001-1263558758</ListID>
<FullName>BhagyaMazire</FullName>
</CustomerRef>
<TxnDate>2010-01-15</TxnDate>
<RefNumber>21011</RefNumber>
<BillAddress>
<Addr1>ConsoliBYTE, LLC</Addr1>
<Addr2>134 Stonemill Road</Addr2>
<Addr3 />
<City>Mansfield</City>
<State>CT</State>
<PostalCode>06268</PostalCode>
<Country>United States</Country>
</BillAddress>
<ShipAddress>
<Addr1>ConsoliBYTE, LLC</Addr1>
<Addr2>Attn: Keith Palmer</Addr2>
<Addr3>56 Cowles Road</Addr3>
<City>Willington</City>
<State>CT</State>
<PostalCode>06279</PostalCode>
<Country>United States</Country>
</ShipAddress>
<TermsRef>
<FullName>Net 30</FullName>
</TermsRef>
<SalesRepRef>
<FullName>KRP</FullName>
</SalesRepRef>
<Memo>Test memo goes here.</Memo>
<InvoiceLineAdd>
<ItemRef>
<FullName>test</FullName>
</ItemRef>
<Desc>Test item description</Desc>
<Quantity>1.00000</Quantity>
<Rate>15.00000</Rate>
</InvoiceLineAdd>
</InvoiceAdd>
</InvoiceAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
/**
* Receive a response from QuickBooks
*/
function _quickbooks_invoice_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
}
//-------------- PURCHASE ORDER --------------------------------------
function _quickbooks_purchaseorder_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<PurchaseOrderAddRq requestID="' . $requestID . '">
<PurchaseOrderAdd>
<VendorRef>
<FullName>Test Vendor</FullName>
</VendorRef>
<TxnDate>2013-01-02</TxnDate>
<RefNumber>3434</RefNumber>
<PurchaseOrderLineAdd>
<ItemRef>
<FullName>My Item Name</FullName>
</ItemRef>
<Desc>Test description.</Desc>
<Quantity>5</Quantity>
<Rate>29.95</Rate>
</PurchaseOrderLineAdd>
</PurchaseOrderAdd>
</PurchaseOrderAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
/**
* Receive a response from QuickBooks
*/
function _quickbooks_purchaseorder_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
}
/**
* Build a request to import sales orders already in QuickBooks into our application
*/
function _quickbooks_salesorder_import_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
// Iterator support (break the result set into small chunks)
$attr_iteratorID = '';
$attr_iterator = ' iterator="Start" ';
if (empty($extra['iteratorID']))
{
// This is the first request in a new batch
$last = _quickbooks_get_last_run($user, $action);
_quickbooks_set_last_run($user, $action); // Update the last run time to NOW()
// Set the current run to $last
_quickbooks_set_current_run($user, $action, $last);
}
else
{
// This is a continuation of a batch
$attr_iteratorID = ' iteratorID="' . $extra['iteratorID'] . '" ';
$attr_iterator = ' iterator="Continue" ';
$last = _quickbooks_get_current_run($user, $action);
}
// Build the request
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="' . $version . '"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<SalesOrderQueryRq ' . $attr_iterator . ' ' . $attr_iteratorID . ' requestID="' . $requestID . '">
<MaxReturned>' . QB_QUICKBOOKS_MAX_RETURNED . '</MaxReturned>
<ModifiedDateRangeFilter>
<FromModifiedDate>' . $last . '</FromModifiedDate>
</ModifiedDateRangeFilter>
<IncludeLineItems>true</IncludeLineItems>
<OwnerID>0</OwnerID>
</SalesOrderQueryRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
/**
* Get the last date/time the QuickBooks sync ran
*
* @param string $user The web connector username
* @return string A date/time in this format: "yyyy-mm-dd hh:ii:ss"
*/
function _quickbooks_get_last_run($user, $action)
{
$type = null;
$opts = null;
return QuickBooks_Utilities::configRead(QB_QUICKBOOKS_DSN, $user, md5(__FILE__), QB_QUICKBOOKS_CONFIG_LAST . '-' . $action, $type, $opts);
}
/**
* Set the last date/time the QuickBooks sync ran to NOW
*
* @param string $user
* @return boolean
*/
function _quickbooks_set_last_run($user, $action, $force = null)
{
$value = date('Y-m-d') . 'T' . date('H:i:s');
if ($force)
{
$value = date('Y-m-d', strtotime($force)) . 'T' . date('H:i:s', strtotime($force));
}
return QuickBooks_Utilities::configWrite(QB_QUICKBOOKS_DSN, $user, md5(__FILE__), QB_QUICKBOOKS_CONFIG_LAST . '-' . $action, $value);
}
/**
*
*
*/
function _quickbooks_get_current_run($user, $action)
{
$type = null;
$opts = null;
return QuickBooks_Utilities::configRead(QB_QUICKBOOKS_DSN, $user, md5(__FILE__), QB_QUICKBOOKS_CONFIG_CURR . '-' . $action, $type, $opts);
}
/**
*
*
*/
function _quickbooks_set_current_run($user, $action, $force = null)
{
$value = date('Y-m-d') . 'T' . date('H:i:s');
if ($force)
{
$value = date('Y-m-d', strtotime($force)) . 'T' . date('H:i:s', strtotime($force));
}
return QuickBooks_Utilities::configWrite(QB_QUICKBOOKS_DSN, $user, md5(__FILE__), QB_QUICKBOOKS_CONFIG_CURR . '-' . $action, $value);
}
?>
我只使用ADD
功能,我收到以下错误: -
Error_for_import_but_i_am_using_add
由于
答案 0 :(得分:0)
请按照此页面上链接的快速入门指南进行操作:
请参阅以下其他评论:
我的基本问题是,我将如何获得销售订单,采购订单等。
将客户引入QuickBooks的方式相同。写一个请求函数。写一个响应函数。把事情排队。
如果您遇到问题,请发布您的代码,以便我们了解您到目前为止所做的工作。
QBDesktop中需要但在我的网站中不可用的内容。
这些东西都不是QuickBooks严格要求所必需的。请与您的会计师联系,详细了解您应该将哪些类型的对象推送到QuickBooks。
我还从这里创建了所有表QB Transaction表,
这可能不是正确的做法。您应该遵循快速启动。
现在点是如何在这些表中插入数据。
你为什么要那样做?您已经拥有WooCommerce数据库中的数据。为什么不直接使用您已有的数据?
那么这意味着从网站导入到QBWC或从QBDesktop导入到QBWC。
从QuickBooks导入到网站。例如与你想要完成的事情相反。