我在亞馬遜工作,好vtiger整合子功能,從亞馬遜MWS客戶端庫的代碼片段看起來像如何讓PHP
if ($order->isSetShippingAddress()) {
echo(" ShippingAddress\n");
$shippingAddress = $order->getShippingAddress();
if ($shippingAddress->isSetName()) {
echo(" Name\n");
echo(" " . $shippingAddress->getName() . "\n");
}
if ($shippingAddress->isSetAddressLine1()) {
echo(" AddressLine1\n");
echo(" " . $shippingAddress->getAddressLine1() . "\n");
}
我要訪問像$shippingAddress->AddressLine1()
子功能項和我的代碼看起來像
$module = 'Invoice';
$shippingAddress = $order->getShippingAddress();
$orderTotal = $order->getOrderTotal();
$record = $client->doCreate($module,Array(
'subject' => $order->getAmazonOrderId(),
'customerno'=> $order->getAmazonOrderId(),
bill_city' => $shippingAddress->getAddressLine1(),
'bill_state'=> $shippingAddress->getStateOrRegion(),
'bill_code' => $shippingAddress->getPostalCode(),
當我嘗試,我得到錯誤
致命錯誤:調用一個非對象的成員函數getAddressLine1()
這是一個範圍錯誤?我如何使用$ shippingAddress的子功能?作者RAW_DUMP 這裏
幫我請
完整代碼
function invokeListOrders(MarketplaceWebServiceOrders_Interface $service, $request)
{
try {
$response = $service->listOrders($request);
if ($response->isSetListOrdersResult()) {
echo(" ListOrdersResult\n");
$listOrdersResult = $response->getListOrdersResult();
if ($listOrdersResult->isSetOrders()) {
echo(" Orders\n");
$orders = $listOrdersResult->getOrders();
$orderList = $orders->getOrder();
foreach ($orderList as $order) {
$shippingAddress = $order->getShippingAddress();
include_once('vtwsclib/Vtiger/WSClient.php');
$url = 'http://vijayholdings.com/admin';
$client = new Vtiger_WSClient($url);
$login = $client->doLogin('admin', 'MYSECRETKEY');
if(!$login) echo 'Login Failed';
else{
$module = 'Invoice';
$shippingAddress = $order->getShippingAddress();
$orderTotal = $order->getOrderTotal();
$record = $client->doCreate($module,Array(
'subject'=>$order->getAmazonOrderId(),
'customerno'=>$order->getAmazonOrderId(),
'invoicestatus'=>'Credit Invoice',/*
'assigned_user_id'=>'spatel',
'currency_id'=>'1',
'conversion_rate'=>'1', not working*/
'bill_street'=>$order->getShippingAddress(),/*
'bill_city'=>$shippingAddress->getCity(),
'bill_state'=>$shippingAddress->getStateOrRegion(),
'bill_code'=>$shippingAddress->getPostalCode(),
'bill_country'=>$order->$shippingAddress->getCounty(), */
'cf_652'=>'Deepdiscounts.co Amazon FBA',/*
'cf_653'=>$shippingAddress->getPhone(),
'cf_656'=>$shippingAddress->getAddressLine2(), */
'cf_660'=>$order->getShipServiceLevel(),
'cf_658'=>$order->getSalesChannel(),
'cf_661'=>$order->getFulfillmentChannel(),
'cf_663'=>$order->getBuyerName(),
'cf_659'=>$order->getBuyerEmail(),
'cf_662'=>$order->getPaymentMethod()
));
}
if($record) {
$recordid = $client->getRecordId($record['id']);
echo "The id is ".$recordid;
}
}
}
}
} catch (MarketplaceWebServiceOrders_Exception $ex) {
echo("Caught Exception: " . $ex->getMessage() . "\n");
echo("Response Status Code: " . $ex->getStatusCode() . "\n");
echo("Error Code: " . $ex->getErrorCode() . "\n");
echo("Error Type: " . $ex->getErrorType() . "\n");
echo("Request ID: " . $ex->getRequestId() . "\n");
echo("XML: " . $ex->getXML() . "\n");
echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
}
輸出爲一次銷售訂單的名單,從中我工作
(1) { ["_fields:protected"]=> array(11) { ["Name"]=> array(2) { ["FieldValue"]=> string(16) "Jason A. Stewart" ["FieldType"]=> string(6) "string" } ["AddressLine1"]=> array(2) { ["FieldValue"]=> string(15) "101 Young Drive" ["FieldType"]=> string(6) "string" } ["AddressLine2"]=> array(2) { ["FieldValue"]=> NULL ["FieldType"]=> string(6) "string" } ["AddressLine3"]=> array(2) { ["FieldValue"]=> NULL ["FieldType"]=> string(6) "string" } ["City"]=> array(2) { ["FieldValue"]=> string(6) "Smyrna" ["FieldType"]=> string(6) "string" } ["County"]=> array(2) { ["FieldValue"]=> NULL ["FieldType"]=> string(6) "string" } ["District"]=> array(2) { ["FieldValue"]=> NULL ["FieldType"]=> string(6) "string" } ["StateOrRegion"]=> array(2) { ["FieldValue"]=> string(2) "TN" ["FieldType"]=> string(6) "string" } ["PostalCode"]=> array(2) { ["FieldValue"]=> string(5) "37167" ["FieldType"]=> string(6) "string" } ["CountryCode"]=> array(2) { ["FieldValue"]=> string(2) "US" ["FieldType"]=> string(6) "string" } ["Phone"]=> array(2) { ["FieldValue"]=> string(10) "6152231070" ["FieldType"]=> string(6) "string" } } }
嗯,我不知道,但我覺得你在這裏缺少報價:[點擊這裏] bill_city」 – 2012-07-31 21:33:55
我評論這是不工作 – 2012-07-31 21:48:41