<h2>Your 5 most recent orders</h2> <br /> <?php include '../whiplash_api.php'; // Substitute your own Whiplash API Key in the example below: $api_key = 'Hc2BHTn3bcrwyPooyYTP'; // 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); /** Find an order by its ID in your store: **/ //$order = $api->get_order_by_originator(YOUR_ORDER_ID); $orders = $api->get_orders(array('limit' => 5)); foreach ($orders as $order) { echo "<p>"; echo "#"; echo $order->id; echo "<br /><strong>"; echo $order->shipping_name; echo "</strong><br />"; echo $order->shipping_address_1; echo "<br />"; if ($order->shipping_address_2 != "") { echo $order->shipping_address_2; echo "<br />";
<h2>Your 50 most recent items</h2> <br /> <?php include '../whiplash_api.php'; // Substitute your own Whiplash API Key in the example below: $api_key = 'Hc2BHTn3bcrwyPooyYTP'; // 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;
<h2>Creating & Updating Order Items</h2> Each time this page is loaded, a new order item is added to the most recent order. At the same time, the quantity of all existing items is increased by 1. <br /><br /> <?php include '../whiplash_api.php'; // Substitute your own Whiplash API Key in the example below: $api_key = 'Hc2BHTn3bcrwyPooyYTP'; // 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); // We just grab the last order, and use its order items as our example $orders = $api->get_orders(array('limit' => 1)); foreach ($orders as $order) { echo "<p>"; echo "#"; echo $order->id; echo "<br /><strong>"; echo $order->shipping_name; echo "</strong><br />"; echo $order->shipping_address_1; echo "<br />"; if ($order->shipping_address_2 != "") { echo $order->shipping_address_2; echo "<br />"; }
<h2>Creating Items</h2> Each time this page is loaded, a new item will be created and its resulting object is displayed. <br /><br /> <?php include '../whiplash_api.php'; // Substitute your own Whiplash API Key in the example below: $api_key = 'Hc2BHTn3bcrwyPooyYTP'; // 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 { // There are two ways to create an order // 1) Create the order first, then create order items individually (multiple API calls) // 2) Create the order with all of its items (one API call) $api = new WhiplashApi($api_key, $api_version, $test); $new_item = $api->create_item(array('sku' => 'NEW_SKU_111', 'name' => 'Test Item', 'description' => 'One Size')); echo "<p>"; echo var_dump($new_item); echo "</p>"; } ?> </div> <!-- /container --> </body> </html>
<?php include '../whiplash_api.php'; // Substitute your own Whiplash API Key in the example below: $api_key = 'Hc2BHTn3bcrwyPooyYTP'; // 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 { // There are two ways to create an order // 1) Create the order first, then create order items individually (multiple API calls) // 2) Create the order with all of its items (one API call) $api = new WhiplashApi($api_key, $api_version, $test); // // Method #1 // $order = $api->create_order(array( // 'shipping_name' => 'John Doe', // 'shipping_address_1' => '1 Infinite Loop', // 'shipping_address_2' => 'APT 6', // 'shipping_city' => 'Ann Arbor', // 'shipping_state' => 'MI', // 'shipping_zip' => '48108', // 'email' => '*****@*****.**' // )); // // $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)); // }