PHP code example of stanislavqq / iikoapi

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

    

stanislavqq / iikoapi example snippets

 php
use stanislavqq\iikoapi\Api;

$iiko = new Api([
    'login' => 'demoDelivery',
    'password' => 'PI1yFaKFCGvvJKi'
]);

echo $iiko->getToken();
 php
use stanislavqq\iikoapi\Organization; 

$orgList = $iiko->getOrganizationList();
$organization = new Organization($orgList[0]);

echo $organization->id;
echo $organization->name;
 php
$organization = new Organization($orgList[0]);

$iiko->setOrganization($organization);
$menu = $iiko->getNomenclature(); //Вернет массив обьектов класса Product

foreach($menu as $product) {
    echo $product->name;
}
 php 

$product = $iiko->createProduct();
$product->name = 'Паста по-итальянски';

$order = $iiko->createOrder();
$order->setProduct($product);