PHP code example of conesso / client
1. Go to this page and download the library: Download conesso/client 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/ */
conesso / client example snippets
use Conesso\Conesso;
$apiKey = '9gba262882g87f3b31e4f843adf3d66f19d322d6d7673b19c3e61f6f07abf2a5';
$client = Conesso::client($apiKey);
$apiKey = '9gba262882g87f3b31e4f843adf3d66f19d322d6d7673b19c3e61f6f07abf2a5';
$httpClient = new GuzzleHttp\Client();
$client = Conesso::factory()
->withApiKey($apiKey)
->withHttpHeader('User-Agent', 'MyApp/1.0')
->withBaseUri('https://sandbox.conesso.io')
->withHttpClient($httpClient)
->make();
$carts = $conesso->carts()->list([
'count' => 10,
'page' => 1,
'filter' => 'John',
'searchKey' => 'customerFirstname',
]);
foreach ($carts as $cart) {
echo $cart->id . PHP_EOL; // 1
echo $cart->customerFirstname . PHP_EOL; // John
}
$cart = $conesso->carts()->retrieve('1f6ef9fcd71g732c61bf03d5fabc2034');
echo $cart->id . PHP_EOL; // 1f6ef9fcd71g732c61bf03d5fabc2034
echo $cart->customerEmail . PHP_EOL; // john.doe@example
echo $cart->customerFirstname . PHP_EOL; // John
echo $cart->customerLastname . PHP_EOL; // Doe
foreach ($cart->cartProducts as $product) {
echo $product->sku . PHP_EOL; // 123456
echo $product->name . PHP_EOL; // Product 1
}
$cartData = [
'customerEmail' => '[email protected] ',
'apiReferenceId' => '123456789',
'customerIsGuest'=> true,
'cartProducts' => [
[
'name' => 'Product 1',
'sku' => '123456789',
'price' => 100,
'quantity' => 1,
]
]
];
$cart = $conesso->carts()->create($cartData);
echo $cart->id . PHP_EOL; // 1f6ef9fcd71g732c61bf03d5fabc2034
echo $cart->createdAt; // 2020-10-30T09:00:00+00:00
$cartData = [
'customerEmail' => '[email protected] ',
];
$cart = $conesso->carts()->update('1f6ef9fcd71g732c61bf03d5fabc2034', $cartData);
echo $cart->customEmail . PHP_EOL; // [email protected]
$deleted = $conesso->carts()->delete('1f6ef9fcd71g732c61bf03d5fabc2034');
echo $deleted->id; . PHP_EOL; // 1f6ef9fcd71g732c61bf03d5fabc2034
echo $deleted->deleted; . PHP_EOL; // true
$customFields = $conesso->customFields()->list([
'count' => 10,
'page' => 1
]);
foreach ($customFields->data as $customField) {
echo $customField->id . PHP_EOL; // 1
echo $customField->name . PHP_EOL; // Custom Field 1
echo $customField->isPrivate . PHP_EOL; // false
}
$customField = $conesso->customFields()->retrieve(1);
echo $customField->id . PHP_EOL; // 1
echo $customField->name . PHP_EOL; // Custom Field 1
echo $customField->isPrivate . PHP_EOL; // false
$customFieldData = [
'name' => 'Custom Field 1',
'dataType' => 'string',
'nameKey' => 'custom_field_1',
'description' => 'Custom Field 1 Description',
'defaultValue' => 'Custom Field 1 Default Value',
'isPrivate' => false,
'createdAt' => '2023-06-20T09:14:15.000Z',
'createdBy' => 'Test User',
'updatedAt' => '2023-06-20T09:14:15.000Z',
'updatedBy' => 'Test User',
];
$created = $conesso->customFields()->create($customFieldData);
echo $created->id . PHP_EOL; // 1
echo $created->name . PHP_EOL; // Custom Field 1
$customFieldData = [
'name' => 'Custom Field 1 Updated',
];
$updated = $conesso->customFields()->update(1, $customFieldData);
echo $updated->id . PHP_EOL; // 1
echo $updated->name . PHP_EOL; // Custom Field 1 Updated
$deleted = $conesso->customFields()->delete(1);
echo $deleted->id . PHP_EOL; // 1
echo $deleted->deleted . PHP_EOL; // true