Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
breakoutModefull-width
languagephp
<?php

require_once __DIR__ . '/vendor/autoload.php';

// Configure API key authorization: ultraCartSimpleApiKey
ultracart\v2\Configuration::getDefaultConfiguration()->setApiKey('x-ultracart-simple-key', 'YOUR API KEY HERE');

// Disable SSL verification if we're having issues with this PHP install not having the proper CA installed.  Fix your CA for a production environment!
// Set debug to true if you need more information on request/response
$client = new GuzzleHttp\Client(['verify' => false, 'debug' => false]);

$api_instance = new ultracart\v2\Apiapi\OrderApi(
    $client,
    ultracart\v2\Configuration::getDefaultConfiguration(),
    new ultracart\v2\HeaderSelector("2016-10-01")
);

$order_batch_query = new \ultracart\v2\models\OrderQueryBatch();

$order_ids = array();

array_push($order_ids, "DEMO-2019132482");
array_push($order_ids, "DEMO-2019132481");
array_push($order_ids, "DEMO-2019132480");
array_push($order_ids, "DEMO-2019132479");
array_push($order_ids, "DEMO-2019132478");
array_push($order_ids, "DEMO-2019132477");
array_push($order_ids, "DEMO-2019132476");
array_push($order_ids, "DEMO-2019132475");
array_push($order_ids, "DEMO-2019132474");
array_push($order_ids, "DEMO-2019132473");
array_push($order_ids, "DEMO-2019132472");
array_push($order_ids, "DEMO-2019132471");

$order_batch_query->setOrderIds($order_ids);

$_expand = "affiliate,affiliate.ledger,auto_order,billing,buysafe,channel_partner,checkout,coupon,customer_profile,digital_order,edi,fraud_score,gift,gift_certificate,internal,item,linked_shipment,marketing,payment,payment.transaction,quote,salesforce,shipping,summary,taxes"; // string | The object expansion to perform on the result.

try {
    $result = $api_instance->getOrdersBatch($order_batch_query, $_expand);

    if ($result->getSuccess()) {
        echo 'Retrieved ' . count($result->getOrders()) . PHP_EOL;

        for ($i = 0; $i < count($result->getOrders()); $i++) {
            echo $result->getOrders()[$i]->getOrderId() . " payment: " . $result->getOrders()[$i]->getPayment()->getPaymentMethod() . PHP_EOL;

            // Put your code here to process each of the orders that came back
            var_dump($result->getOrders()[$i]->getBilling());
        }
    } else {
        echo 'Failed to retrieve orders' . PHP_EOL;
        var_dump($result);
    }
} catch (Exception $e) {
    echo 'Exception when calling OrderApi->getOrdersBatch: ', $e->getMessage(), PHP_EOL;
}

?>