
Prefer to Use Google Sheets? Here is a direct link with all our inventory updated hourly: Google Sheets »
<?php
/*********************************
* Pull Shipped.com Inventory Feed
* Call J at +1 765-327-8369 or
* email J@Shipped.com for help!
*********************************/
$inventory_feed_url = "https://shipped.com/inventory-json.php";
// $debug = "yes"; // uncomment to debug <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
if ($debug == "yes") {
// Report all PHP errors
ini_set("error_reporting", E_ALL);
ini_set("display_errors","on");
error_reporting(E_ALL);
error_reporting(-1);
error_reporting(E_ALL & ~E_NOTICE); // SHOW ALL ERRORS EXCEPT NOTICES
}
function pre($array,$name_of_array=""){
$out = "<pre>";
if (!empty($name_of_array)) { $out .= "<b>$name_of_array</b> is"; }
if (!empty($array)) { $out .= " an "; } else { $out .= " empty"; }
$out .= print_r($array, true);
$out .= "</pre>";
return $out;
}
// PULL Updated Shipped.com Inventory Feed in JSON
$json = file_get_contents($inventory_feed_url);
if (!$json) { echo "Can't load Shipped.com Inventory... Try debug first and then try loading https://shipped.com/inventory-json.php in your browser to see if the feed is broken. Call/email J if feed broken."; exit; }
$inventory_array = json_decode($json,TRUE);
if ($debug == "yes") { echo pre($inventory_array); }
foreach ($inventory_array as $key => $box) { // Loop through each Inventory Item
$wholesaler = $box['wholesaler'];
$wholesaler_inventory_id = $box['wholesaler_inventory_id'];
$datetime_retreived_pst = $box['datetime_PST']; // Time you retrieved the feed in Pacific Standard Time (PST).
$quantity_ready = $box['quantity_ready']; // Ingated and ready for sale
$quantity_inbound = $box['quantity_inbound']; // Inbound and available for pre-sale
$inbound_eta_date = $box['inbound_eta_date']; // The estimated arrival date of the first container for inbound inventory
$size = $box['size']; // 20, 40, 40HC, 45HC, etc
$rating = $box['rating']; // WWT, CW, IICL, NEW
$color_ral = $box['color_ral']; // The RAL color of the container
$color_html_hex = $box['color_html_hex']; // The color of the container represented in HTML HEX colors for use on a webpage to visually show the color
$color_desc = $box['color_desc']; // The name of the color in words
$specs = $box['specs']; // EOD = Easy Open Doors (3 handle), FLP = Forklift Pockets, LBOX = Integrated Lockbox, HLH = High Locking Handles, etc.
if (!empty($box['bic_codes'])) {
foreach ($box['bic_codes'] as $bic_num => $bic) { // Pull all BIC codes for this item into an array
$bics[$wholesaler_inventory_id][$bic_num] = $bic;
}
}
if (!empty($box['media'])) {
foreach ($box['media'] as $media_key => $one_media) { // Put all media files into an array
$media[$wholesaler_inventory_id][$media_key] = $one_media;
}
}
$depot_id = $box['depot_id']; // The depot id. Can be used to match our depot to your own list of depots.
$depot = $box['depot_name']; // The depot company name
$depot_address = $box['depot_address'];
$city = $box['city'];
$state = $box['state']; // State, Region or Province
$country = $box['country'];
$msrp = $box['msrp']; // The suggested retail price for each of these containers
$wholesale_price = $box['wholesale_price']; // Our wholesale price for each of these containers
$online_checkout_link = $box['online_checkout_link']; // Direct link to our shopping cart
// Here is where you should insert all the above values into your database...
}