My name is Andrey. I’m a senior developer at Simtech Development. I’m developing the Stuart integration with the CS-Cart e-commerce platform for my client.
I have an issue with getting the Job ID value. After creating the job, I’m trying to get the JobID
$job->getId();
but this method contains the null value in the response. Also, I can see the created job in the Sandbox administration panel.
Could you advise what is wrong?
I’m using following code:
// Initializing Client
$environment = ($this->settings['test_mode']) == 'Y' ? \Stuart\Infrastructure\Environment::SANDBOX : \Stuart\Infrastructure\Environment::PRODUCTION;
$api_client_id = $this->settings['client_id'];
$api_client_secret = $this->settings['client_secret'];
$authenticator = new \Stuart\Infrastructure\Authenticator($environment, $api_client_id, $api_client_secret);
$httpClient = new \Stuart\Infrastructure\HttpClient($authenticator);
$client = new \Stuart\Client($httpClient);
// Creating Job
$job = new \Stuart\Job();
$pickup_address = $order_info['product_groups'][$shipping_data['group_key']]['package_info']['origination'];
$dropoff_address = array(
'address' => $order_info['s_address'],
'zipcode' => $order_info['s_zipcode'],
'city' => $order_info['s_city']
);
$job->addPickup($this->prepareAddress($pickup_address))
->setContactCompany($pickup_address['name'])
->setContactPhone($pickup_address['phone']);
$job->addDropOff($this->prepareAddress($dropoff_address))
->setPackageType(self::SMALL_PACKAGE)
->setContactFirstName($order_info['firstname'])
->setContactLastName($order_info['lastname'])
->setContactPhone($order_info['s_phone'])
->setClientReference($order_info['order_id'] . '_' . TIME);
$validate_job = $client->validateJob($job);
if ($validate_job) {
$client->createJob($job);
$job_id = $job->getId();
print_r($job_id); // see null value!
}