PHP code example of pankovalxndr / dalli-sdk-php
1. Go to this page and download the library: Download pankovalxndr/dalli-sdk-php 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/ */
pankovalxndr / dalli-sdk-php example snippets
$client = new Client(new \GuzzleHttp\Client(), 'my_awsome_token', Endpoint::MSK);
$items = [];
$item = new Item();
$order = new Order();
$receiver = new Receiver();
$receiver->setAddress('ул. Константина Константинопольского, д.1 к1')
->setTown('г. Москва')
->setPerson('Константин Константинопольский')
->setPhone('+7 000 000 00 00')
->setDate(new DateTime('2022-12-25'))
->setTimeMin('9:00')
->setTimeMax('22:00');
$item->setQuantity(2)
->setName('Моя тестовая товарная позиция')
->setWeight(3.15)
->setRetPrice(50.0)
->setInshPrice(5.0)
->setOriginCountry('RU')
->setGtd('10702030')
->setSuppCompany('Компания поставщик')
->setSuppPhone('+7 000 000 00 00')
->setSuppInn('3664069397')
->setType(1);
$items[] = $item;
$order->setNumber('sdk-001')
->setReceiver($receiver)
->setService(1)
->setWeight(3.15)
->setQuantity(1)
->setPayType(PayType::CASH)
->setPrice(150.0) // стоимость товарных позиций + стоимость доставки
->setPriced(50.0)
->setInshPrice(500.0)
->setInstruction('Максимально аккуратно')
->setItems($items);
$request = new CreateBasketRequest();
$request->addOrder($order);
$response = $client->sendCreateBasketRequest($request);
foreach ($response as $order) {
$error = $order->getErrors();
$success = $order->getSuccess();
if ($success)
echo $success->getBarcode() . PHP_EOL; // Штрих-код заказа в системе Dalli
}
bash
composer