PHP code example of hector68 / yandex-delivery
1. Go to this page and download the library: Download hector68/yandex-delivery 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/ */
hector68 / yandex-delivery example snippets
$config = \Hector68\YandexDelivery\config\ApiProxyConfig($method_keys, $data);
$order_items = [
new Item([
'orderitem_name' => 'Test',
'orderitem_quantity' => '2',
'orderitem_cost' => rand(1,500)
]),
new Item([
'orderitem_name' => 'Test2',
'orderitem_quantity' => 1,
'orderitem_cost' => rand(1,500)
])
];
$deliverypoint = new DeliveryPoint([
'city' => 'Москва',
'street' => 'Советская 20'
]);
$recipient = new Recipient([
'first_name' => 'Имя',
'last_name' => 'Фамилия',
'phone' => '+7999999999',
'email' => '[email protected] '
]);
$delivery = new Delivery(
[
'to_yd_warehouse' => 1,
'pickuppoint' => null,
'delivery' => 1385,
'tariff' => 1565,
'direction' => 699,
'interval' => 3421
]
);
$order = new Order(
[
'order_num' => '2',
'order_items' => $order_items,
'delivery' => $delivery,
'deliverypoint' => $deliverypoint,
'recipient' => $recipient,
]
);
$api = new YdApi($config);
$result = $api->createOrder($order);