PHP code example of ultracart / rest_api_v2_sdk_php
1. Go to this page and download the library: Download ultracart/rest_api_v2_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/ */
ultracart / rest_api_v2_sdk_php example snippets
eate a Simple Key: https://ultracart.atlassian.net/wiki/spaces/ucdoc/pages/38688545/API+Simple+Key
$simple_key = '109ee846ee69f50177018ab12f008a00748a25aa28dbdc0177018ab12f008a00';
$api_instance = ultracart\v2\api\OrderApi::usingApiKey($simple_key);
// The UltraCart objects are large. Very large. So we have encapsulated the fields in sub objects allowing you to
// only request the sub objects you need. This is done via the expansion object. The API docs on the main web site
// have more details about expansions: https://www.ultracart.com/api/#expansion.html
$_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.
// this is a detailed example that .length: " . sizeof($order_response->getOrders()) . "\n";
// print out a line for each order *item*
// notice, email is within the billing child object.
foreach ($order_response->getOrders() as $order) {
$order_id = $order->getOrderId();
$email = $order->getBilling()->getEmail(); // notice the email is part of the billing sub object.
foreach($order->getItems() as $item){
echo $order_id . ',' . $email . ',' . $item->getMerchantItemId() . ',' . $item->getQuantity() . "\n";
}
}
} while ($order_response->getMetadata()->getResultSet()->getMore());
} catch (Exception $e) {
echo 'Exception when calling OrderApi->getOrdersByQuery: ', $e->getMessage(), PHP_EOL;
}
echo "</pre></body></html>";