$addResponse = $service->add($request);
if (!$addResponse->writeResponse->status->isSuccess) {
    echo "ADD ERROR";
    exit;
} else {
    echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId;
}
echo "\n-----------------------\n";
$gr = new GetRequest();
$gr->baseRef = new RecordRef();
$gr->baseRef->internalId = $addResponse->writeResponse->baseRef->internalId;
// code completion does not work here since baseRef is baseRef in the GetRequest def comment
$gr->baseRef->type = "purchaseOrder";
// code completion does not work here since baseRef is BaseRef in the GetRequest def comment
//$getResponse = $sc->__soapCall("get", array($gr), NULL, $passportheader);
$getResponse = $service->get($gr);
if (!$getResponse->readResponse->status->isSuccess) {
    echo "GET ERROR";
    exit;
} else {
    echo "GET SUCCESS";
}
echo "\n-----------------------\n";
$po2 = $getResponse->readResponse->record;
$po2->memo = "updated";
$po2->itemList->replaceAll = false;
$poi = new PurchaseOrderItem();
$poi->item = new RecordRef();
$poi->item->internalId = 458;
$poi->quantity = 5;
$po2->itemList->item = array($poi);
<?php

namespace NetSuite\WebServices;

require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$service->setPassport($nsaccount = 'MYACCT1', $nsemail = '*****@*****.**', $nsrole = '3', $nspassword = '******');
$request = new GetRequest();
$request->baseRef = new RecordRef();
$request->baseRef->internalId = "883";
$request->baseRef->type = "customer";
$getResponse = $service->get($request);
if (!$getResponse->readResponse->status->isSuccess) {
    echo "GET ERROR";
} else {
    $customer = $getResponse->readResponse->record;
    echo "GET SUCCESS, customer:";
    echo "\nCompany name: " . $customer->companyName;
    echo "\nInternal Id: " . $customer->internalId;
    echo "\nEmail: " . $customer->email . "\n";
    $addressBookListArray = $customer->addressbookList->addressbook;
    if (is_array($addressBookListArray)) {
        foreach ($addressBookListArray as $address) {
            echo "\nAddress:\n";
            echo $address->label . "\n" . $address->attention . "\n" . $address->addressee . "\n" . $address->phone . "\n" . $address->city . "\n" . $address->state . "\n" . $address->zip . "\n" . $address->country . "\n\n";
        }
    } else {
        $address = $addressBookListArray;
        echo "\nAddress:\n";
        echo $address->label . "\n" . $address->attention . "\n" . $address->addressee . "\n" . $address->phone . "\n" . $address->city . "\n" . $address->state . "\n" . $address->zip . "\n" . $address->country . "\n\n";
    }
Пример #3
0
 private function _isOrderInNetSuite($order_id, $ns_user = 1)
 {
     $service = new NetSuiteService(NULL, [], $ns_user);
     $request = new GetRequest();
     $request->baseRef = new RecordRef();
     $request->baseRef->externalId = $order_id . ".0";
     $request->baseRef->type = "salesOrder";
     $getResponse = $service->get($request);
     $code = $getResponse->readResponse->status->statusDetail[0]->code;
     $this->netsuite_order = $getResponse->readResponse->record;
     if ($code == "INVALID_KEY_OR_REF") {
         $this->netsuite_order->code = $code;
     }
     if (!$getResponse->readResponse->status->isSuccess) {
         return FALSE;
     } else {
         return TRUE;
     }
 }