Cheaper By The Day - Turning Auctions Upside Down

CubeCart Software Data Feed Script Addon


Use this CubeCart Shopping Cart PHP/MySQL script to create an on-the-fly, tab-delimited plain text (.txt) file that our site can visit daily to automatically upload and update your items at Cheaper By The Day. All you need to do is copy this file into your ROOT cart directory. Once you have it up and running, Sign In at Cheaper By The Day, go to Edit Your Profile, and submit the link to your script.

<?php

include_once("includes/ini.inc.php");
include_once(
"includes/global.inc.php");
include_once(
"classes/db.inc.php");
include_once(
"includes/functions.inc.php");
ob_start("ob_gzhandler");
$db = new db();
$config = fetchDbConfig("config");

#-----You may edit the following universal variables as required-----#

$category = ''; // A CheaperByTheDay category
$days = ''; // '10' by default
$shipping_us = '';
$alaska_hawaii = '';
$canada = '';
$shipping_notes = '';
$condition = ''; // 'new' by default

#-----Do not edit below this line-----#

$feed[] = array ("product_id", "categories", "days", "max_price",
"min_price", "shipping_us", "alaska_hawaii", "canada", "shipping_notes",
"description", "brand", "condition", "image_url", "title");

$cubecart = "
SELECT
"
.$glob['dbprefix']."CubeCart_inventory.productId,
"
.$glob['dbprefix']."CubeCart_inventory.price,
"
.$glob['dbprefix']."CubeCart_inventory.sale_price,
"
.$glob['dbprefix']."CubeCart_inventory.description,
"
.$glob['dbprefix']."CubeCart_inventory.image,
"
.$glob['dbprefix']."CubeCart_inventory.name,
"
.$glob['dbprefix']."CubeCart_category.cat_name,
"
.$glob['dbprefix']."CubeCart_category.cat_father_id
FROM
"
.$glob['dbprefix']."CubeCart_inventory
INNER JOIN "
.$glob['dbprefix']."CubeCart_category ON
"
.$glob['dbprefix']."CubeCart_inventory.cat_id =
"
.$glob['dbprefix']."CubeCart_category.cat_id
WHERE
"
.$glob['dbprefix']."CubeCart_inventory.quantity >= 1
"
;

$items = $db->select($cubecart);
if (
$items == TRUE) {
   for ($i=0; $i<count($items); $i++) {
      $remove = array("\t", "\n", "\r"); // Take out tabs and newlines
      $product_id = $items[$i]['productID'];
      $categories = (empty($category)) ? getCategories($items[$i]
[
'cat_name'], $items[$i]['cat_father_id']) : $category;
      $days = (empty($days)) ? 10 : $days;
      $max_price = round($items[$i]['price'], 2);
      $salePrice = salePrice($items[$i]['price'], $items[$i]['sale_price']);
      $min_price = ($salePrice > 0) ? round($salePrice, 2) : $max_price;
      $description = str_replace($remove, "", $items[$i]['description']);
      $brand = '';
      $baseImageURL = $glob[storeURL] . '/images/uploads/';
      $image_url = ($items[$i]['image']) ? $baseImageURL . $items[$i]
[
'image'] : '';
      $title = str_replace($remove, "", $items[$i]['name']);
      $feed[] = array ($product_id, $categories, $days, $max_price,
$min_price, $shipping_us, $alaska_hawaii, $canada, $shipping_notes, $description, $brand, $condition, $image_url, $title);
   }
}

header("Content-type: text/plain");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
foreach (
$feed as $line) { echo implode("\t", $line) . "\n"; }
ob_end_flush();
((
is_null($___mysqli_res = mysqli_close($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);

function
getCategories ($subcategory, $parentID) {
   $query = "SELECT cat_name FROM ".$glob['dbprefix']."CubeCart_category
WHERE cat_father_id = $parentID ORDER BY cat_name ASC"
;
   $category = $db->select($query);
   $categories = ($category == TRUE) ? implode ('|', $category) . '|' .
$subcategory : $subcategory;
   return $categories;
}

?>

product_id - A unique alphanumeric identifier for the item - your internal ID code. - e.g. 01flx

categories - The item's category and subcategory separated by a '|'. When possible, match these with the categories used at Cheaper By The Day (use form below). - e.g. computers | pda & handhelds

days - The number of days duration you would like the price to be reduced from your maximum price, to the minimum price. You can choose either a 3, 5, 7, or 10 day listing. - e.g. 5

max_price - The highest price you would like to sell your item for. Do not include the dollar sign. - e.g. 75.68

min_price - The lowest price you would like to sell your item for. - e.g. 54.35

shipping_us* - The amount you will charge for shipping within the Continental US - e.g. 5.99

alaska_hawaii* - The amount you will charge when shipping to Alaska and Hawaii - e.g. 0.00 (A value of 0.00 would indicate that you do not offer shipping to this location.)

canada* - The amount you will charge when shipping to Canada - e.g. 7.85

shipping_notes* - Additional shipping information that you would like to include. Maximum length of 80 characters.

description* - The description of the item.

brand* - The brand name, manufacturer, or publisher of the product. Maximum length of 30 characters. - e.g. Sony

condition* - The condition of the product. Acceptable values are new, used, and refurbished.

image_url* - The URL of an associated, full-sized image for the item. (Must include the http:// portion.) - e.g. http://www.yourwebsite.com/image1.jpg

title - The title of the item. Maximum length of 60 characters.

* Can be left blank, but the field must still exist.




Sign In | Register

Categories
  
 
View All Listings - 7199
Antiques
Art
Baby - 6
Books - 4
Cameras & Photo - 131
Cheaper Motors - 117
Clothing - 200
Coins
Collectibles - 56
Computers - 69
Dolls & Bears
Electronics - 704
Games - 260
Health & Beauty - 214
Hobbies & Crafts - 3
Home & Garden - 2550
Jewelry & Watches - 136
Memorabilia
Miscellaneous - 4
Movies - 307
Music - 1
Musical Instruments - 32
Office Supplies - 16
Pets - 13
Phones - 530
Real Estate - 4
Shoes & Accessories - 1743
Sports & Outdoors - 20
Stamps
Tickets
Toys - 79
Travel
 

Fun Fact
  
 
It's impossible to sneeze with your eyes open.