将WooCommerce订单发送到NetSuite

时间:2015-01-30 17:22:08

标签: php netsuite

我正在尝试使用Rest API从WooCommerce获取订单,并将该信息作为销售订单添加到NetSuite中。我可以成功地从WooCommerce获取订单信息,但是在使用PHPToolkit将订单添加到NetSuite时我没有成功。以下是我到目前为止的情况:

<?php

/*
 * Add a customer to Netsuite.
 * 
 * paramtypesmap
 *  
 */

require_once 'includes/functions.php';

// create array of fields
$itemArr = array();
$i = 0;
$service = new NetSuiteService();

$salesOrder = new SalesOrder();

$salesOrder->entity = new RecordRef();
$salesOrder->entity->internalId = 512;
$salesOrder->entity->type = 'customer';

$salesOrder->shipDate = formatDate('2014-10-06T07:12:57.000-07:00');

$service = new NetSuiteService();
$service->setSearchPreferences(false, 1000);

$siteCategory = new SearchMultiSelectField();
$siteCategory->operator = "anyOf";
$siteCategory->searchValue = array('internalId' => 512);

$search = new ItemSearchBasic();
$search->internalId = $siteCategory;

$request = new SearchRequest();
$request->searchRecord = $search;

$searchResponse = $service->search($request);
$products = $searchResponse->searchResult->recordList->record; 


$salesOrder->itemList = new SalesOrderItemList();
$item = new SalesOrderItem();
$item->item = new RecordRef();
$item->item->internalId = 531;
$item->quantity = 1;
//removeEmpty($item->item);
//removeEmpty($item);

$item->price = new RecordRef();
$item->price->internalId = 1;
$item->amount = 55.3;


$salesOrder->itemList->item=array(0=>$item);


//Equivalent too print_r
pr($item);

//Equivalent too print_r
pr($salesOrder);

removeEmpty($salesOrder);

$request = new AddRequest();
$request->record  = $salesOrder;

//$service->setFields($purchaseOrderFields);

$response = $service->add($request);
if (!$response->writeResponse->status->isSuccess) {
    echo getErrors($response->writeResponse);
} else {
    echo success($response->writeResponse->baseRef->internalId);
}
?>

我只是试图从头开始工作以查看需要哪些字段以及如何构建它们,但是在运行时我一直收到此错误:

Please choose a child matrix item

我花了最近几天试图尝试一些Google Fu来解决这个问题,但幸运的是我找不到任何东西。任何人都可以帮我这个吗?

2 个答案:

答案 0 :(得分:1)

根据错误消息,您尝试提交父矩阵项而不是子项。通过检查内部ID为531的项目记录来验证它。

答案 1 :(得分:0)

实现正确内部ID的最佳方法是将Matrix项目直接从NetSuite导入WooCommerce作为可变产品。为每个变体分配内部ID。