Cheaper By The Day - Turning Auctions Upside Down

ZenCart Software Data Feed Script Addon


Use this ZenCart 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, and make sure you have the correct path to your sites images ($imageURL). 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

require('includes/application_top.php');
ob_start("ob_gzhandler");

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

$category = ''; // A CheaperByTheDay category
$days = ''; // '10' by default
$percentage = ''; // to reduce base price - '0'% by default
$shipping_us = '';
$alaska_hawaii = '';
$canada = '';
$shipping_notes = '';
$condition = ''; // 'new' by default
$imageURL = "http://".$_SERVER['HTTP_HOST'] . DIR_WS_CATALOG . DIR_WS_IMAGES;
// The full URL to your images eg. "http://www.yoursite.com/zen/images/";

#-----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");

$category_information = "
SELECT
categories.categories_id AS curCatID,
categories.parent_id AS parentCatID,
categories_description.categories_name AS catName
FROM
categories,
categories_description
WHERE categories.categories_id = categories_description.categories_id
"
;
$catIndex = array();
$catTempDes = array();
$catTempPar = array();
$processCat = mysqli_query($GLOBALS["___mysqli_ston"], $category_information);
while (
$catRow = mysqli_fetch_object($processCat)) {
   $catKey = $catRow->curCatID;
   $catName = $catRow->catName;
   $catParID = $catRow->parentCatID;
   if($catName != "") {
      $catTempDes[$catKey]=$catName;
      $catTempPar[$catKey]=$catParID;
   }
}
foreach(
$catTempDes as $curID=>$des) {
   $catIndex = findCat($curID, $catTempPar, $catTempDes, $catIndex);
}

$zenCart = "
SELECT
products.products_id AS product_ID,
products_to_categories.categories_id AS category_ID,
products.products_price AS price,
products_description.products_description AS description,
manufacturers.manufacturers_name AS manufacturer,
concat( '"
. $imageURL . "' ,products.products_image) AS image_URL,
products_description.products_name AS title
FROM
products,
products_description,
products_to_categories
left join manufacturers on ( manufacturers.manufacturers_id =
products.manufacturers_id )
WHERE
products.products_id=products_description.products_id
AND products.products_id=products_to_categories.products_id
AND products_status = '1'
ORDER BY
products.products_id ASC
"
;

$processItems = mysqli_query($GLOBALS["___mysqli_ston"], $zenCart);
while (
$row = mysqli_fetch_object($processItems)) {
   $remove = array("\t", "\n", "\r"); // Take out tabs and newlines
   $product_id = $row->product_ID;
   $categories = (empty($category)) ? $catIndex[$row->category_ID] :
$category;
   $days = (empty($days)) ? 10 : $days;
   $max_price = round($row->price, 2);
   $price_reduction = (empty($percentage)) ? 1 : 1 - ($percentage * .01);
   $min_price = round($row->price * $price_reduction, 2);
   $description = str_replace($remove, "", $row->description);
   $brand = $row->manufacturer;
   $image_url = $row->image_URL;
   $title = str_replace($remove, "", $row->title);
   $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
findCat($curID, $catTempPar, $catTempDes, $catIndex) {
   if( (isset($catTempPar[$curID])) && ($catTempPar[$curID] != 0) ) {
      if(isset($catIndex[$catTempPar[$curID]])) {
         $temp=$catIndex[$catTempPar[$curID]];
      } else {
         $catIndex = findCat($catTempPar[$curID], $catTempPar, $catTempDes,
$catIndex);
         $temp = $catIndex[$catTempPar[$curID]];
      }
   }
   if( (isset($catTempPar[$curID])) && (isset($catTempDes[$curID])) &&
(
$catTempPar[$curID] == 0) ) {
      $catIndex[$curID] = $catTempDes[$curID];
   } else {
      $catIndex[$curID] = $temp . " | " . $catTempDes[$curID];
   }
   return $catIndex;
}

?>

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
  
 
The greatest productive force is human selfishness.