PHP code example of afosto / active-ants

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

    

afosto / active-ants example snippets


App::start($endpoint, $username, $password, $cacheDirectory);

$product = Product::model()
        ->setName('testProduct')
        ->setSku('testSku');

if ($product->save()) {
    echo "Product was saved";
}

$item = OrderItem::model()
        ->setSku('testSku')
        ->setGrossPrice(1.21)
        ->setName('Test Product')
        ->setTaxRate(21);

$address = Address::model()
        ->setName('Afosto SaaS BV')
        ->setAddress('Protonstraat', 9, 'a')
        ->setCity('Groningen')
        ->setCountry('NL')
        ->setPostalcode('9743AL');

$order = Order::model()
        ->setEmail('[email protected]')
        ->setOrderId('#1')
        ->setPhoneNumber('0507119519')
        ->addOrderItem($item)
        ->setBillingAddress($address)
        ->setShippingAddress($address);

if ($order->save()) {
    echo "Order was saved";
}

foreach (Stock::model()->findAll() as $stock) {
    echo $stock->sku . ': ' . $stock->stock . "\n";
}