// Whiplash sandbox Key $api_version = ''; // OPTIONAL: Leave this blank to use the most recent API $test = true; // OPTIONAL: If test is true, this will use your sandbox account if ($api_key == '') { echo 'To get started, enter your Whiplash API Key into the source code of this page. <br /><br /> Once that\'s done, reload.'; } else { $api = new WhiplashApi($api_key, $api_version, $test); /** Create an item **/ // $item1 = $api->create_item(array('sku' => 'Item 12345', 'title' => 'Awesome item 3!')); /** Find items by SKU (NOTE: since multiple items may have the same SKU, this returns an array) **/ // $items = $api->get_items_by_sku(ITEM_SKU); /** Find an item by its ID in your store: **/ //$item = $api->get_item_by_originator(YOUR_ITEM_ID); $items = $api->get_items(); foreach ($items as $item) { echo "<p>"; echo "#"; echo $item->id; echo "<br /><strong>"; echo $item->sku; echo "</strong><br />"; echo $item->title; echo "<br />"; echo $item->description; echo "<br />"; echo "In Stock: "; echo $item->quantity; echo "<br />"; echo "</p>";
echo "<br />"; if ($order->shipping_address_2 != "") { echo $order->shipping_address_2; echo "<br />"; } echo $order->shipping_city; echo ", "; echo $order->shipping_state; echo " "; echo $order->shipping_zip; echo "<br />"; echo $order->email; echo "<br />"; echo "</p>"; // Create a new order item $items = $api->get_items(array('limit' => 1)); foreach ($items as $item) { $new_item = $api->create_order_item(array('quantity' => 1, 'item_id' => $item->id, 'order_id' => $order->id)); // print_r($new_item); foreach ($order->order_items as $order_item) { // Add 1 to the quantity of all existing items $api->update_order_item($order_item->id, array('quantity' => $order_item->quantity + 1)); if ($order_item->packaging != 1) { echo $order_item->quantity; echo " x "; echo $order_item->description; echo "<br />"; } } } }