- PHP 5.2 and Up
- An Orkiv Inventory account, with valid API Credentials
- We recommend using Twitter Bootstrap for building websites with Inventory.php
Download the PHP file 'inventory.core.php' included in this repo
Initialize the class with the following code. Replace accountid
with your actual account ID and apikey
with a valid Key generated for your account.
You can access all of this information under the settings section of your account.
- Setup
- Initialization
- Getting Inventory data
- Inventory Group object
- Performing a query
- Get all categories
- Category Object
- Get inventory items
- Item object
- Accessing cart checkout
- Orders
- Order object
- onSubscription event
Move the php file inventory.php
to your website's root. include
the file wherever functionality is desired!
The snippet below initializes the class
<?php
include "inventory.core.php";
$manager = new InvManager(array(
"id" => "accountid",
"key" => "apikey"
));
?>
Used to download all of your inventory data.
This will return a JSON object with key result
, which is an array of inventory group objects.
<?php
$someobject = $manager->all()->result;
name
: Name of category.items
: Array of Item objects.
InvMaster::query(int page,string categoryid, string min_price, string max_price, mixed $additionalquery [ );
When querying you can turn Price min and max constraints off by using the string value OFF
.
The first page is always 0. The method below is a DEFAULT call to the api without any search constraints. Since the category field is (empty) ""
it will not take the category value of each item into consideration when performing the query.
$manager->query(0,"","OFF","OFF",array());
The additional query field can be used to query for other fields contained with the item. Please see the example below.
$query = array('color' => 'yellow');
$data = $manager->query(0, "","OFF","OFF", $query)->result;
retrieve all categories.
This method returns a mixed array with key result
, this key is an array of category objects
Example :
<?php
$someobject = $manager->categories()->result;
name
: Name of category.id
: ID of category.children
: Array of category objects, with the exception being thatsampleimage
is used as a system generated image for that category.tmp
: System generated image for that category.
Get all items.
This method returns a mixed array with key result
, this key is an array of item objects
Get a specified item.
This method returns the desired item object within key result
.
Examples :
To simply get all items you can call on the method below, and the method following is used to GET an individual item.
<?php
$someobject = $manager->items()->result;
print_r($someobject);
$someitem = $manager->item(ITEMID)->result;
?>
The script above will output the items retrieved. If you're inventory is of vast amount we recommend using querying instead of this method.
ID
: ID of itemcategory
: Category ID of item.desc
: Richtext description of item.name
: Name of item.ordprice
: Integer value of price.price
: String value of price.quantity
: Item inventory quantity.media
: Array of strings. Each string is a url to an item's image.Buy
: Direct buy link of item.
Creating items via api can be useful for importing previous inventory items by adding them programmatically.
//add function is used to create a new item
$myitemname = "Banana";
$manager->add($myitemname, array("price" => "10000","customfield" => "somevalue"));
Updating an item's properties can be useful for updating item data to match actual inventory data. The code below will update an item's price and quantity. Any non-existing key supplied will be added automatically.
//valid item id needed
$ITEMID = "AAAAA";
$manager->update($ITEMID,array("price" => 9000, "quantity" => "20"));
//ITEMID still being "AAAAA"
$manager->delete($ITEMID);
https://orkiv.com/i/cart-checkout/?YOURACCOUNTID=SAMPLEITEMID,SAMPLEITEMID2&SAMPLEITEMID=quantity
Cart checkout is accessed via link. You may add as many desired items to include in checkout.
$request = $manager->order($order_id);
$order = $request->result;
If the Order exists it will return a json object as the Result if the Order was not found, the result will be 404
This will retrieve all the orders within an account.
$request = $manager->orders();
$orders = $request->result;
info_email
: Customer emailinfo_first
: Customer first nameinfo_last
: Customer last namephone
: Customer phone number (U.S. format)shipset
: Customer billing address matches shipping addressinfo_adr1
: Customer billing address line 1info_adr2
: Customer billing address line 2info_cty
: Customer billing cityinfo_zip
: Customer billing zipstate
: Customer billing stateinfo_sadr1
: Customer shipping address line 1info_sadr2
: Customer shipping address line 2info_scty
: Customer shipping cityinfo_szip
: Customer shipping zipsstate
: Customer shipping statetax_amount
: Float value of tax amount for this order in hundreds. Divide by 100 for USD valueshipping_amount
: Float value of shipping total in USD. No conversion neededamount_total
: Float value of total order in USD.order_id
: Unique order ID
Returns an array of order objects matching the supplied criteria.
Example :
<?php
$order = $manager->orders(array("order_id" => "AAA"))->result;
?>
An event is a post request that Inventory performs after a successful transaction. This is useful to create any additional login accounts for the services that you are selling.
This function will create an event.
Example :
// Setup Post Data
$postData = array("email" => "foo", "check" => "bar");
//Creating an webhook
$manager->write("url", "serviceID", $postData );
Nano Identifiers are dynamic post variables that can be used in URL callbacks. It allows the personalization of each callback request. You can only assign order data to nano identifiers. In the example below we will create a web hook and use a nano identifier pointing to the customer's email
//sample Nano Identifier
$nano = "@:info_email";
// Setup Post Data
$postData = array("email" => $nano, "check" => "@:order_id");
//Creating an webhook
$manager->write("url", "serviceID", $postData );
2016 Orkiv Retail Solutions LLC