私は amazon から vtiger への統合に取り組んでおり、amazon MWS クライアント ライブラリのコード スニペットは次のようになります。
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 のサブ関数を使用するにはどうすればよいですか??
お願い助けて
完全なコード
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");
}
RAW_DUMP の出力は、私が作業しているリストの 1 つの販売注文 フォームです。
(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) "スマーナ" ["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"]=> 文字列(10) "6152231070" ["FieldType"]=> string(6) "文字列" } } }