/** * createItem * -- * @param Item $item * @param $sku * @param $description * @return ArrayOfItem|int|mixed|null */ public function createItem(Item $item, $sku, $description) { if ($item != null) { // Instantiate a new ArrayOfItem try { // Set SKU & description of new item $item->setSKU($sku); $item->setDescription($description); // Set array of items, inc. above item. $aoItems = new ArrayOfItem(); $aoItems->setItem([$item]); // return the new [items]. return $aoItems; } catch (Exception $e) { // Something went wrong - error_log & return error message error_log($e->getMessage() . "-" . $e->getTraceAsString()); return $e->getCode(); } } else { return null; } }
<?php require 'autoload.php'; require 'classes/autoload.php'; // Create a new ThreeCentralAPI Class $a = new ThreeCentralAPI("{REDACTED}", "479", "23", "1", "Incapi", "Incapi"); // Retrieve the SoapClient $b = $a->getClient(); // Retrieve the ExternalLoginInformation $external_login_information = $a->getExtLoginData(); // Array of items $aoItems = new ArrayOfItem(); // New item $item = new Item($a->api_customer_id, 0.0, 1.0, 1.0, 1, InventoryMethod::LIFO, 0.99, 12.0, true, true, true, true, true, true, true, true, true, true, true, 5.0, MeasurementSystemType::USImperial, 25.0, 15.0, 10.0, 10.0, false, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 50.0, false, HazMatPackingGroup::aDefault, HazMatFlag::aDefault, 25.0, 0); // set sku of that item $item->setSKU("TEST1"); // set description $item->setDescription("Testing API"); // add item to arr. $aoItems->setItem([$item]); // create order $order = new Order(1); // contact information $contact_info = new ContactInfoExt(3); // company name $contact_info->setCompanyName("Some Company"); // contact information $contact_info->setCustomerName("John Doe"); $contact_info->setDept("IT"); $contact_info->setPhoneNumber1("9547854455"); $contact_info->setName("Johnathon Doe");