PHP code example of ecomlogic / php-sdk
1. Go to this page and download the library: Download ecomlogic/php-sdk library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ecomlogic / php-sdk example snippets
$client = new \Ecomlogic\ApiClient(
'https://demo.ecomlogic.com',
'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH',
'v5'
);
try {
$response = $client->request->ordersGet('M-2342');
} catch (\Ecomlogic\Exception\CurlException $e) {
echo "Connection error: " . $e->getMessage();
}
if ($response->isSuccessful()) {
echo $response->order['totalSumm'];
// or $response['order']['totalSumm'];
// or
// $order = $response->getOrder();
// $order['totalSumm'];
} else {
echo sprintf(
"Error: [HTTP-code %s] %s",
$response->getStatusCode(),
$response->getErrorMsg()
);
// error details
if (isset($response['errors'])) {
print_r($response['errors']);
}
}
$client = new \Ecomlogic\ApiClient(
'https://demo.ecomlogic.com',
'T9DMPvuNt7FQJMszHUdG8Fkt6xHsqngH',
'v4'
);
try {
$response = $client->request->ordersCreate(array(
'externalId' => 'some-shop-order-id',
'firstName' => 'John',
'lastName' => 'Doe',
'items' => array(
//...
),
'delivery' => array(
'code' => 'dhl',
)
));
} catch (\Ecomlogic\Exception\CurlException $e) {
echo "Connection error: " . $e->getMessage();
}
if ($response->isSuccessful() && 201 === $response->getStatusCode()) {
echo 'Order successfully created. Order ID into eComlogic = ' . $response->id;
// or $response['id'];
// or $response->getId();
} else {
echo sprintf(
"Error: [HTTP-code %s] %s",
$response->getStatusCode(),
$response->getErrorMsg()
);
// error details
if (isset($response['errors'])) {
print_r($response['errors']);
}
}