PHP code example of soukicz / zbozicz

1. Go to this page and download the library: Download soukicz/zbozicz 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/ */

    

soukicz / zbozicz example snippets




use Soukicz\Zbozicz\Client;
use Soukicz\Zbozicz\Order;
use Soukicz\Zbozicz\CartItem;

$client = new Client(1234567890, "fedcba9876543210123456789abcdef", true);

$order = new Order('OBJ21101');
$order
    ->setEmail('[email protected]')
    ->setDeliveryType('PPL')
    ->addCartItem((new CartItem)
        ->setId('ABC1')
        ->setName('NAZEV PRODUKTU')
        ->setUnitPrice(1000)
        ->setQuantity(2)
    )
    ->addCartItem((new CartItem)
        ->setId('ABC2')
        ->setName('NAZEV PRODUKTU')
        ->setUnitPrice(2000)
    );

$client->sendOrder($order);


use Soukicz\Zbozicz\Client;
use Soukicz\Zbozicz\Order;
use Soukicz\Zbozicz\CartItem;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Client\Pool;

$client = new Client(1234567890, "fedcba9876543210123456789abcdef", true);
$requests = [];
foreach($orders as $order){
    $requests[$order->geId()] = $client->createRequest($order);
}

$httpClient = new \GuzzleHttp\Client();
$pool = new Pool($httpClient, $requests, [
    'concurrency' => 5,
    'fulfilled' => function (Response $response, $index) {
        echo "Order '$index' accepted\n";
    },
    'rejected' => function ($reason, $index) {
        echo "Order '$index' not accepted: " . $reason . "\n";
    },
]);