Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

[Contribution] Cross Sell (X-Sell) Admin


dreamscape

Recommended Posts

Yeah, have you looked through all the similar contributions, available from the Contributions section of the website? I expect there's quite a few that are reasonably similar, one of which might do what you need?

 

Adam

Actually I have spent quite some time looking through the contribs. Unfortunately, I haven't found one to do what I need. If anyone can help this newbie out, I'd be very thankful. (I looked through all 45 pages of the 'Features' contrib section and nothing :( )

Link to comment
Share on other sites

I've installed this, and it is going to be a great mod, thanks to all of your hard work guys thus far.

 

I have Add to Cart installed, and instead of Buy Now would rather have it as an Add to Cart, with it just staying on the products page.

 

I see this contrib working on someone elses site, http://www.laserarts.com/product_info.php?...products_id=201

 

but the "Buy Now" Just returns to the product listing on my site. www.smoothair.ca/catalog

 

Any progress thus far?

 

Thanks!

 

Geof.

Link to comment
Share on other sites

  • 2 weeks later...

Works perfect 4 me... Thanks! :)

 

 

But after the install of X-Sell i got another problem.

 

When I'm trying to create/delete a product/category i recieve this message:

 

 

Warning: Cannot modify header information - headers already sent by (output started at /home/FA04-15-07-100_2xazch9kxgmd93vyxpnq/seriegrossisten.se/public_html/catalog/admin/includes/languages/svenska.php:1) in /home/FA04-15-07-100_2xazch9kxgmd93vyxpnq/seriegrossisten.se/public_html/catalog/admin/includes/functions/general.php on line 18

 

 

Anyone knows what can be wrong??

I really need some help with this one.. pleeease!

 

Anyway.. here is the general.php code:

 

<?php
/*
$Id: general.php,v 1.160 2003/07/12 08:32:47 hpdl Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2003 osCommerce

Released under the GNU General Public License
*/

////
// Redirect to another page or site
function tep_redirect($url) {
  global $logger;

  header('Location: ' . $url);

  if (STORE_PAGE_PARSE_TIME == 'true') {
    if (!is_object($logger)) $logger = new logger;
    $logger->timer_stop();
  }

  exit;
}

////
// Parse the data used in the html tags to ensure the tags will not break
function tep_parse_input_field_data($data, $parse) {
  return strtr(trim($data), $parse);
}

function tep_output_string($string, $translate = false, $protected = false) {
  if ($protected == true) {
    return htmlspecialchars($string);
  } else {
    if ($translate == false) {
      return tep_parse_input_field_data($string, array('"' => '"'));
    } else {
      return tep_parse_input_field_data($string, $translate);
    }
  }
}

function tep_output_string_protected($string) {
  return tep_output_string($string, false, true);
}

function tep_sanitize_string($string) {
  $string = ereg_replace(' +', ' ', $string);

  return preg_replace("/[<>]/", '_', $string);
}

function tep_customers_name($customers_id) {
  $customers = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
  $customers_values = tep_db_fetch_array($customers);

  return $customers_values['customers_firstname'] . ' ' . $customers_values['customers_lastname'];
}

function tep_get_path($current_category_id = '') {
  global $cPath_array;

  if ($current_category_id == '') {
    $cPath_new = implode('_', $cPath_array);
  } else {
    if (sizeof($cPath_array) == 0) {
      $cPath_new = $current_category_id;
    } else {
      $cPath_new = '';
      $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[(sizeof($cPath_array)-1)] . "'");
      $last_category = tep_db_fetch_array($last_category_query);

      $current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
      $current_category = tep_db_fetch_array($current_category_query);

      if ($last_category['parent_id'] == $current_category['parent_id']) {
        for ($i = 0, $n = sizeof($cPath_array) - 1; $i < $n; $i++) {
          $cPath_new .= '_' . $cPath_array[$i];
        }
      } else {
        for ($i = 0, $n = sizeof($cPath_array); $i < $n; $i++) {
          $cPath_new .= '_' . $cPath_array[$i];
        }
      }

      $cPath_new .= '_' . $current_category_id;

      if (substr($cPath_new, 0, 1) == '_') {
        $cPath_new = substr($cPath_new, 1);
      }
    }
  }

  return 'cPath=' . $cPath_new;
}

function tep_get_all_get_params($exclude_array = '') {
  global $HTTP_GET_VARS;

  if ($exclude_array == '') $exclude_array = array();

  $get_url = '';

  reset($HTTP_GET_VARS);
  while (list($key, $value) = each($HTTP_GET_VARS)) {
    if (($key != tep_session_name()) && ($key != 'error') && (!in_array($key, $exclude_array))) $get_url .= $key . '=' . $value . '&';
  }

  return $get_url;
}

function tep_date_long($raw_date) {
  if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

  $year = (int)substr($raw_date, 0, 4);
  $month = (int)substr($raw_date, 5, 2);
  $day = (int)substr($raw_date, 8, 2);
  $hour = (int)substr($raw_date, 11, 2);
  $minute = (int)substr($raw_date, 14, 2);
  $second = (int)substr($raw_date, 17, 2);

  return strftime(DATE_FORMAT_LONG, mktime($hour, $minute, $second, $month, $day, $year));
}

////
// Output a raw date string in the selected locale date format
// $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS
// NOTE: Includes a workaround for dates before 01/01/1970 that fail on windows servers
function tep_date_short($raw_date) {
  if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;

  $year = substr($raw_date, 0, 4);
  $month = (int)substr($raw_date, 5, 2);
  $day = (int)substr($raw_date, 8, 2);
  $hour = (int)substr($raw_date, 11, 2);
  $minute = (int)substr($raw_date, 14, 2);
  $second = (int)substr($raw_date, 17, 2);

  if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
    return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
  } else {
    return ereg_replace('2037' . '$', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
  }

}

function tep_datetime_short($raw_datetime) {
  if ( ($raw_datetime == '0000-00-00 00:00:00') || ($raw_datetime == '') ) return false;

  $year = (int)substr($raw_datetime, 0, 4);
  $month = (int)substr($raw_datetime, 5, 2);
  $day = (int)substr($raw_datetime, 8, 2);
  $hour = (int)substr($raw_datetime, 11, 2);
  $minute = (int)substr($raw_datetime, 14, 2);
  $second = (int)substr($raw_datetime, 17, 2);

  return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
}

function tep_get_category_tree($parent_id = '0', $spacing = '', $exclude = '', $category_tree_array = '', $include_itself = false) {
  global $languages_id;

  if (!is_array($category_tree_array)) $category_tree_array = array();
  if ( (sizeof($category_tree_array) < 1) && ($exclude != '0') ) $category_tree_array[] = array('id' => '0', 'text' => TEXT_TOP);

  if ($include_itself) {
    $category_query = tep_db_query("select cd.categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.language_id = '" . (int)$languages_id . "' and cd.categories_id = '" . (int)$parent_id . "'");
    $category = tep_db_fetch_array($category_query);
    $category_tree_array[] = array('id' => $parent_id, 'text' => $category['categories_name']);
  }

  $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and c.parent_id = '" . (int)$parent_id . "' order by c.sort_order, cd.categories_name");
  while ($categories = tep_db_fetch_array($categories_query)) {
    if ($exclude != $categories['categories_id']) $category_tree_array[] = array('id' => $categories['categories_id'], 'text' => $spacing . $categories['categories_name']);
    $category_tree_array = tep_get_category_tree($categories['categories_id'], $spacing . '   ', $exclude, $category_tree_array);
  }

  return $category_tree_array;
}

function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') {
  global $currencies, $languages_id;

  if ($exclude == '') {
    $exclude = array();
  }

  $select_string = '<select name="' . $name . '"';

  if ($parameters) {
    $select_string .= ' ' . $parameters;
  }

  $select_string .= '>';

  $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by products_name");
  while ($products = tep_db_fetch_array($products_query)) {
    if (!in_array($products['products_id'], $exclude)) {
      $select_string .= '<option value="' . $products['products_id'] . '">' . $products['products_name'] . ' (' . $currencies->format($products['products_price']) . ')</option>';
    }
  }

  $select_string .= '</select>';

  return $select_string;
}

function tep_options_name($options_id) {
  global $languages_id;

  $options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$languages_id . "'");
  $options_values = tep_db_fetch_array($options);

  return $options_values['products_options_name'];
}

function tep_values_name($values_id) {
  global $languages_id;

  $values = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$values_id . "' and language_id = '" . (int)$languages_id . "'");
  $values_values = tep_db_fetch_array($values);

  return $values_values['products_options_values_name'];
}

function tep_info_image($image, $alt, $width = '', $height = '') {
  if (tep_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) {
    $image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height);
  } else {
    $image = TEXT_IMAGE_NONEXISTENT;
  }

  return $image;
}

function tep_break_string($string, $len, $break_char = '-') {
  $l = 0;
  $output = '';
  for ($i=0, $n=strlen($string); $i<$n; $i++) {
    $char = substr($string, $i, 1);
    if ($char != ' ') {
      $l++;
    } else {
      $l = 0;
    }
    if ($l > $len) {
      $l = 1;
      $output .= $break_char;
    }
    $output .= $char;
  }

  return $output;
}

function tep_get_country_name($country_id) {
  $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'");

  if (!tep_db_num_rows($country_query)) {
    return $country_id;
  } else {
    $country = tep_db_fetch_array($country_query);
    return $country['countries_name'];
  }
}

function tep_get_zone_name($country_id, $zone_id, $default_zone) {
  $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");
  if (tep_db_num_rows($zone_query)) {
    $zone = tep_db_fetch_array($zone_query);
    return $zone['zone_name'];
  } else {
    return $default_zone;
  }
}

function tep_not_null($value) {
  if (is_array($value)) {
    if (sizeof($value) > 0) {
      return true;
    } else {
      return false;
    }
  } else {
    if ( (is_string($value) || is_int($value)) && ($value != '') && ($value != 'NULL') && (strlen(trim($value)) > 0)) {
      return true;
    } else {
      return false;
    }
  }
}

function tep_browser_detect($component) {
  //global $HTTP_USER_AGENT;

  return stristr($_SERVER['HTTP_USER_AGENT'], $component);
}

function tep_tax_classes_pull_down($parameters, $selected = '') {
  $select_string = '<select ' . $parameters . '>';
  $classes_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
  while ($classes = tep_db_fetch_array($classes_query)) {
    $select_string .= '<option value="' . $classes['tax_class_id'] . '"';
    if ($selected == $classes['tax_class_id']) $select_string .= ' SELECTED';
    $select_string .= '>' . $classes['tax_class_title'] . '</option>';
  }
  $select_string .= '</select>';

  return $select_string;
}

function tep_geo_zones_pull_down($parameters, $selected = '') {
  $select_string = '<select ' . $parameters . '>';
  $zones_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " order by geo_zone_name");
  while ($zones = tep_db_fetch_array($zones_query)) {
    $select_string .= '<option value="' . $zones['geo_zone_id'] . '"';
    if ($selected == $zones['geo_zone_id']) $select_string .= ' SELECTED';
    $select_string .= '>' . $zones['geo_zone_name'] . '</option>';
  }
  $select_string .= '</select>';

  return $select_string;
}

function tep_get_geo_zone_name($geo_zone_id) {
  $zones_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$geo_zone_id . "'");

  if (!tep_db_num_rows($zones_query)) {
    $geo_zone_name = $geo_zone_id;
  } else {
    $zones = tep_db_fetch_array($zones_query);
    $geo_zone_name = $zones['geo_zone_name'];
  }

  return $geo_zone_name;
}

function tep_address_format($address_format_id, $address, $html, $boln, $eoln) {
  $address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'");
  $address_format = tep_db_fetch_array($address_format_query);

  $company = tep_output_string_protected($address['company']);
  if (isset($address['firstname']) && tep_not_null($address['firstname'])) {
    $firstname = tep_output_string_protected($address['firstname']);
    $lastname = tep_output_string_protected($address['lastname']);
  } elseif (isset($address['name']) && tep_not_null($address['name'])) {
    $firstname = tep_output_string_protected($address['name']);
    $lastname = '';
  } else {
    $firstname = '';
    $lastname = '';
  }
  $street = tep_output_string_protected($address['street_address']);
  $suburb = tep_output_string_protected($address['suburb']);
  $city = tep_output_string_protected($address['city']);
  $state = tep_output_string_protected($address['state']);
  if (isset($address['country_id']) && tep_not_null($address['country_id'])) {
    $country = tep_get_country_name($address['country_id']);

    if (isset($address['zone_id']) && tep_not_null($address['zone_id'])) {
      $state = tep_get_zone_code($address['country_id'], $address['zone_id'], $state);
    }
  } elseif (isset($address['country']) && tep_not_null($address['country'])) {
    $country = tep_output_string_protected($address['country']);
  } else {
    $country = '';
  }
  $postcode = tep_output_string_protected($address['postcode']);
  $zip = $postcode;

  if ($html) {
// HTML Mode
    $HR = '<hr>';
    $hr = '<hr>';
    if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults
      $CR = '<br>';
      $cr = '<br>';
      $eoln = $cr;
    } else { // Use values supplied
      $CR = $eoln . $boln;
      $cr = $CR;
    }
  } else {
// Text Mode
    $CR = $eoln;
    $cr = $CR;
    $HR = '----------------------------------------';
    $hr = '----------------------------------------';
  }

  $statecomma = '';
  $streets = $street;
  if ($suburb != '') $streets = $street . $cr . $suburb;
  if ($country == '') $country = tep_output_string_protected($address['country']);
  if ($state != '') $statecomma = $state . ', ';

  $fmt = $address_format['format'];
  eval("\$address = \"$fmt\";");

  if ( (ACCOUNT_COMPANY == 'true') && (tep_not_null($company)) ) {
    $address = $company . $cr . $address;
  }

  return $address;
}

////////////////////////////////////////////////////////////////////////////////////////////////
//
// Function    : tep_get_zone_code
//
// Arguments   : country           country code string
//               zone              state/province zone_id
//               def_state         default string if zone==0
//
// Return      : state_prov_code   state/province code
//
// Description : Function to retrieve the state/province code (as in FL for Florida etc)
//
////////////////////////////////////////////////////////////////////////////////////////////////
function tep_get_zone_code($country, $zone, $def_state) {

  $state_prov_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone . "'");

  if (!tep_db_num_rows($state_prov_query)) {
    $state_prov_code = $def_state;
  }
  else {
    $state_prov_values = tep_db_fetch_array($state_prov_query);
    $state_prov_code = $state_prov_values['zone_code'];
  }
  
  return $state_prov_code;
}

function tep_get_uprid($prid, $params) {
  $uprid = $prid;
  if ( (is_array($params)) && (!strstr($prid, '{')) ) {
    while (list($option, $value) = each($params)) {
      $uprid = $uprid . '{' . $option . '}' . $value;
    }
  }

  return $uprid;
}

function tep_get_prid($uprid) {
  $pieces = explode('{', $uprid);

  return $pieces[0];
}

function tep_get_languages() {
  $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");
  while ($languages = tep_db_fetch_array($languages_query)) {
    $languages_array[] = array('id' => $languages['languages_id'],
                               'name' => $languages['name'],
                               'code' => $languages['code'],
                               'image' => $languages['image'],
                               'directory' => $languages['directory']);
  }

  return $languages_array;
}

function tep_get_category_name($category_id, $language_id) {
  $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
  $category = tep_db_fetch_array($category_query);

  return $category['categories_name'];
}

function tep_get_orders_status_name($orders_status_id, $language_id = '') {
  global $languages_id;

  if (!$language_id) $language_id = $languages_id;
  $orders_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . (int)$orders_status_id . "' and language_id = '" . (int)$language_id . "'");
  $orders_status = tep_db_fetch_array($orders_status_query);

  return $orders_status['orders_status_name'];
}

function tep_get_orders_status() {
  global $languages_id;

  $orders_status_array = array();
  $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "' order by orders_status_id");
  while ($orders_status = tep_db_fetch_array($orders_status_query)) {
    $orders_status_array[] = array('id' => $orders_status['orders_status_id'],
                                   'text' => $orders_status['orders_status_name']);
  }

  return $orders_status_array;
}

function tep_get_products_name($product_id, $language_id = 0) {
  global $languages_id;

  if ($language_id == 0) $language_id = $languages_id;
  $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
  $product = tep_db_fetch_array($product_query);

  return $product['products_name'];
}

function tep_get_products_description($product_id, $language_id) {
  $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
  $product = tep_db_fetch_array($product_query);

  return $product['products_description'];
}

function tep_get_products_url($product_id, $language_id) {
  $product_query = tep_db_query("select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
  $product = tep_db_fetch_array($product_query);

  return $product['products_url'];
}

////
// Return the manufacturers URL in the needed language
// TABLES: manufacturers_info
function tep_get_manufacturer_url($manufacturer_id, $language_id) {
  $manufacturer_query = tep_db_query("select manufacturers_url from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturer_id . "' and languages_id = '" . (int)$language_id . "'");
  $manufacturer = tep_db_fetch_array($manufacturer_query);

  return $manufacturer['manufacturers_url'];
}

////
// Wrapper for class_exists() function
// This function is not available in all PHP versions so we test it before using it.
function tep_class_exists($class_name) {
  if (function_exists('class_exists')) {
    return class_exists($class_name);
  } else {
    return true;
  }
}

////
// Count how many products exist in a category
// TABLES: products, products_to_categories, categories
function tep_products_in_category_count($categories_id, $include_deactivated = false) {
  $products_count = 0;

  if ($include_deactivated) {
    $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$categories_id . "'");
  } else {
    $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$categories_id . "'");
  }

  $products = tep_db_fetch_array($products_query);

  $products_count += $products['total'];

  $childs_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");
  if (tep_db_num_rows($childs_query)) {
    while ($childs = tep_db_fetch_array($childs_query)) {
      $products_count += tep_products_in_category_count($childs['categories_id'], $include_deactivated);
    }
  }

  return $products_count;
}

////
// Count how many subcategories exist in a category
// TABLES: categories
function tep_childs_in_category_count($categories_id) {
  $categories_count = 0;

  $categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");
  while ($categories = tep_db_fetch_array($categories_query)) {
    $categories_count++;
    $categories_count += tep_childs_in_category_count($categories['categories_id']);
  }

  return $categories_count;
}

////
// Returns an array with countries
// TABLES: countries
function tep_get_countries($default = '') {
  $countries_array = array();
  if ($default) {
    $countries_array[] = array('id' => '',
                               'text' => $default);
  }
  $countries_query = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name");
  while ($countries = tep_db_fetch_array($countries_query)) {
    $countries_array[] = array('id' => $countries['countries_id'],
                               'text' => $countries['countries_name']);
  }

  return $countries_array;
}

////
// return an array with country zones
function tep_get_country_zones($country_id) {
  $zones_array = array();
  $zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' order by zone_name");
  while ($zones = tep_db_fetch_array($zones_query)) {
    $zones_array[] = array('id' => $zones['zone_id'],
                           'text' => $zones['zone_name']);
  }

  return $zones_array;
}

function tep_prepare_country_zones_pull_down($country_id = '') {
// preset the width of the drop-down for Netscape
  $pre = '';
  if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) {
    for ($i=0; $i<45; $i++) $pre .= ' ';
  }

  $zones = tep_get_country_zones($country_id);

  if (sizeof($zones) > 0) {
    $zones_select = array(array('id' => '', 'text' => PLEASE_SELECT));
    $zones = array_merge($zones_select, $zones);
  } else {
    $zones = array(array('id' => '', 'text' => TYPE_BELOW));
// create dummy options for Netscape to preset the height of the drop-down
    if ( (!tep_browser_detect('MSIE')) && (tep_browser_detect('Mozilla/4')) ) {
      for ($i=0; $i<9; $i++) {
        $zones[] = array('id' => '', 'text' => $pre);
      }
    }
  }

  return $zones;
}

////
// Get list of address_format_id's
function tep_get_address_formats() {
  $address_format_query = tep_db_query("select address_format_id from " . TABLE_ADDRESS_FORMAT . " order by address_format_id");
  $address_format_array = array();
  while ($address_format_values = tep_db_fetch_array($address_format_query)) {
    $address_format_array[] = array('id' => $address_format_values['address_format_id'],
                                    'text' => $address_format_values['address_format_id']);
  }
  return $address_format_array;
}

////
// Alias function for Store configuration values in the Administration Tool
function tep_cfg_pull_down_country_list($country_id) {
  return tep_draw_pull_down_menu('configuration_value', tep_get_countries(), $country_id);
}

function tep_cfg_pull_down_zone_list($zone_id) {
  return tep_draw_pull_down_menu('configuration_value', tep_get_country_zones(STORE_COUNTRY), $zone_id);
}

function tep_cfg_pull_down_tax_classes($tax_class_id, $key = '') {
  $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

  $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
  $tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
  while ($tax_class = tep_db_fetch_array($tax_class_query)) {
    $tax_class_array[] = array('id' => $tax_class['tax_class_id'],
                               'text' => $tax_class['tax_class_title']);
  }

  return tep_draw_pull_down_menu($name, $tax_class_array, $tax_class_id);
}

////
// Function to read in text area in admin
function tep_cfg_textarea($text) {
  return tep_draw_textarea_field('configuration_value', false, 35, 5, $text);
}

function tep_cfg_get_zone_name($zone_id) {
  $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_id = '" . (int)$zone_id . "'");

  if (!tep_db_num_rows($zone_query)) {
    return $zone_id;
  } else {
    $zone = tep_db_fetch_array($zone_query);
    return $zone['zone_name'];
  }
}

////
// Sets the status of a banner
function tep_set_banner_status($banners_id, $status) {
  if ($status == '1') {
    return tep_db_query("update " . TABLE_BANNERS . " set status = '1', expires_impressions = NULL, expires_date = NULL, date_status_change = NULL where banners_id = '" . $banners_id . "'");
  } elseif ($status == '0') {
    return tep_db_query("update " . TABLE_BANNERS . " set status = '0', date_status_change = now() where banners_id = '" . $banners_id . "'");
  } else {
    return -1;
  }
}

////
// Sets the status of a product
function tep_set_product_status($products_id, $status) {
  if ($status == '1') {
    return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '1', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
  } elseif ($status == '0') {
    return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
  } else {
    return -1;
  }
}

////
// Sets the status of a product on special
function tep_set_specials_status($specials_id, $status) {
  if ($status == '1') {
    return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'");
  } elseif ($status == '0') {
    return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");
  } else {
    return -1;
  }
}

////
// Sets timeout for the current script.
// Cant be used in safe mode.
function tep_set_time_limit($limit) {
  if (!get_cfg_var('safe_mode')) {
    set_time_limit($limit);
  }
}

////
// Alias function for Store configuration values in the Administration Tool
function tep_cfg_select_option($select_array, $key_value, $key = '') {
  $string = '';

  for ($i=0, $n=sizeof($select_array); $i<$n; $i++) {
    $name = ((tep_not_null($key)) ? 'configuration[' . $key . ']' : 'configuration_value');

    $string .= '<br><input type="radio" name="' . $name . '" value="' . $select_array[$i] . '"';

    if ($key_value == $select_array[$i]) $string .= ' CHECKED';

    $string .= '> ' . $select_array[$i];
  }

  return $string;
}

////
// Alias function for module configuration keys
function tep_mod_select_option($select_array, $key_name, $key_value) {
  reset($select_array);
  while (list($key, $value) = each($select_array)) {
    if (is_int($key)) $key = $value;
    $string .= '<br><input type="radio" name="configuration[' . $key_name . ']" value="' . $key . '"';
    if ($key_value == $key) $string .= ' CHECKED';
    $string .= '> ' . $value;
  }

  return $string;
}

////
// Retreive server information
function tep_get_system_information() {
  global $HTTP_SERVER_VARS;

  $db_query = tep_db_query("select now() as datetime");
  $db = tep_db_fetch_array($db_query);

  list($system, $host, $kernel) = preg_split('/[\s,]+/', @exec('uname -a'), 5);

  return array('date' => tep_datetime_short(date('Y-m-d H:i:s')),
               'system' => $system,
               'kernel' => $kernel,
               'host' => $host,
               'ip' => gethostbyname($host),
               'uptime' => @exec('uptime'),
               'http_server' => $HTTP_SERVER_VARS['SERVER_SOFTWARE'],
               'php' => PHP_VERSION,
               'zend' => (function_exists('zend_version') ? zend_version() : ''),
               'db_server' => DB_SERVER,
               'db_ip' => gethostbyname(DB_SERVER),
               'db_version' => 'MySQL ' . (function_exists('mysql_get_server_info') ? mysql_get_server_info() : ''),
               'db_date' => tep_datetime_short($db['datetime']));
}

function tep_generate_category_path($id, $from = 'category', $categories_array = '', $index = 0) {
  global $languages_id;

  if (!is_array($categories_array)) $categories_array = array();

  if ($from == 'product') {
    $categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$id . "'");
    while ($categories = tep_db_fetch_array($categories_query)) {
      if ($categories['categories_id'] == '0') {
        $categories_array[$index][] = array('id' => '0', 'text' => TEXT_TOP);
      } else {
        $category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
        $category = tep_db_fetch_array($category_query);
        $categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']);
        if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
        $categories_array[$index] = array_reverse($categories_array[$index]);
      }
      $index++;
    }
  } elseif ($from == 'category') {
    $category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
    $category = tep_db_fetch_array($category_query);
    $categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']);
    if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
  }

  return $categories_array;
}

function tep_output_generated_category_path($id, $from = 'category') {
  $calculated_category_path_string = '';
  $calculated_category_path = tep_generate_category_path($id, $from);
  for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {
    for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) {
      $calculated_category_path_string .= $calculated_category_path[$i][$j]['text'] . ' > ';
    }
    $calculated_category_path_string = substr($calculated_category_path_string, 0, -16) . '<br>';
  }
  $calculated_category_path_string = substr($calculated_category_path_string, 0, -4);

  if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP;

  return $calculated_category_path_string;
}

function tep_get_generated_category_path_ids($id, $from = 'category') {
  $calculated_category_path_string = '';
  $calculated_category_path = tep_generate_category_path($id, $from);
  for ($i=0, $n=sizeof($calculated_category_path); $i<$n; $i++) {
    for ($j=0, $k=sizeof($calculated_category_path[$i]); $j<$k; $j++) {
      $calculated_category_path_string .= $calculated_category_path[$i][$j]['id'] . '_';
    }
    $calculated_category_path_string = substr($calculated_category_path_string, 0, -1) . '<br>';
  }
  $calculated_category_path_string = substr($calculated_category_path_string, 0, -4);

  if (strlen($calculated_category_path_string) < 1) $calculated_category_path_string = TEXT_TOP;

  return $calculated_category_path_string;
}

function tep_remove_category($category_id) {
  $category_image_query = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'");
  $category_image = tep_db_fetch_array($category_image_query);

  $duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where categories_image = '" . tep_db_input($category_image['categories_image']) . "'");
  $duplicate_image = tep_db_fetch_array($duplicate_image_query);

  if ($duplicate_image['total'] < 2) {
    if (file_exists(DIR_FS_CATALOG_IMAGES . $category_image['categories_image'])) {
      @unlink(DIR_FS_CATALOG_IMAGES . $category_image['categories_image']);
    }
  }

  tep_db_query("delete from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'");
  tep_db_query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "'");
  tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$category_id . "'");

  if (USE_CACHE == 'true') {
    tep_reset_cache_block('categories');
    tep_reset_cache_block('also_purchased');
  }
}

function tep_remove_product($product_id) {
  $product_image_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");
  $product_image = tep_db_fetch_array($product_image_query);

  $duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " where products_image = '" . tep_db_input($product_image['products_image']) . "'");
  $duplicate_image = tep_db_fetch_array($duplicate_image_query);

  if ($duplicate_image['total'] < 2) {
    if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image['products_image'])) {
      @unlink(DIR_FS_CATALOG_IMAGES . $product_image['products_image']);
    }
  }

  tep_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "'");
  tep_db_query("delete from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");
  tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'");
  tep_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "'");
  tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$product_id . "'");
  tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . (int)$product_id . "'");
  tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id =

Link to comment
Share on other sites

Works perfect 4 me... Thanks! :)

But after the install of X-Sell i got another problem.

 

When I'm trying to create/delete a product/category i recieve this message:

Warning: Cannot modify header information - headers already sent by (output started at /home/FA04-15-07-100_2xazch9kxgmd93vyxpnq/seriegrossisten.se/public_html/catalog/admin/includes/languages/svenska.php:1) in /home/FA04-15-07-100_2xazch9kxgmd93vyxpnq/seriegrossisten.se/public_html/catalog/admin/includes/functions/general.php on line 18

Anyone knows what can be wrong??

I really need some help with this one.. pleeease!

 

Anyway.. here is the general.php code:

 

...

[code]

[right][post=666030]<{POST_SNAPBACK}>[/post][/right]

 

You have extra blank lines after the last lines in your svenska.php and your general.php files. Open each one, delete the extra blank lines after the last ?> and make sure you upload the files through an ftp program and NOT through your file manager.

Edited by chynathedragon
Link to comment
Share on other sites

  • 2 weeks later...

I would like to add a button in product_info.php: [accessories]

 

When i press that button the xsell file should open in a popup window.

 

I can make the popup window but the new window is blank.

 

Any body has an idea on how to open the xsell file in a new window instead of having it in the product_info?

Link to comment
Share on other sites

  • 2 weeks later...

Hello.

 

I installed xsell last week and it worked fine. I had to uninstall the entire shop and start over because I screwed something up trying to install another mod. I reinstalled everything last night and now I get this error page when I try to install in admin.

 

The requested URL /admin/FILENAME_XSELL_PRODUCTS was not found on this server.

 

I haven't changed anything and went back through the instructions 3 yimes to be sure I didn't miss anything. What happened? How do I get this installed again? :(

Thanks!

Clesha

Link to comment
Share on other sites

Hello.

 

I installed xsell last week and it worked fine.  I had to uninstall the entire shop and start over because I screwed something up trying to install another mod.  I reinstalled everything last night and now I get this error page when I try to install in admin.

 

The requested URL /admin/FILENAME_XSELL_PRODUCTS was not found on this server.

 

I haven't changed anything and went back through the instructions 3 yimes to be sure I didn't miss anything.  What happened?  How do I get this installed again?  :(

 

 

Can someone help me with this?

Thanks!

Clesha

Link to comment
Share on other sites

BUY NOW BUTTON IN PROGRESS

 

Hello, I was wondering if anybody could help me with x-sell, I started playing with the code, because it was not working with Ultimate SEO URLs v2.1. There was a problem with buy now button - I know I'm not alone, so perhaps we could finish it together!

 

It is important to start from the beginning I think. After I've installed SEO URLs, I was having this problem:

Let's say I had a product A where I was promoting, x-selling product B. When clicked on product's B "Buy Now" button, it should (and before SEO install it was) add product B in the basket. It was however adding product A - WRONG.

Link of image was showing:

http://www.originalabsinthe.com/absinthe-spoon-p-45.html

And Buy Now button was showing:

http://www.originalabsinthe.com/index.php?...&action=buy_now

 

Both product IDs were different!!

 

I noticed that there were 2 product_id's in the URL - for example:

index.php?cPath=21&products_id=56&action=buy_now&products_id=45

 

I was advised to get one of them out of the URL. In the X-SELL module I would need to change the tep_get_all_params() function to also add products_id.

 

That was the history so far and I think that SEO URLs just highlighted wrong code in x-sell module. So I started experimenting:

 

In /includes/modules/xsell_products.php I found this bit of code:

<a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>');

and I changed it like this:

<a href="' . tep_href_link(FILENAME_DEFAULT, 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>');

You can see it here.

It seems to work but unfortunately there are two problems at the moment:

1/ on mouseover, you'll notice that both image and name of the product are displaying

http://www.originalabsinthe.com/absinthe-spoon-p-45.html

but the Buy Now button will display non SEO link:

http://www.originalabsinthe.com/index.php?products_id=45&action=buy_now

 

It wouldn't bother me that much, but it will get worse :angry:

 

2/ if you click Buy Now button -> it adds product in the basket :thumbsup: -> now try click on Continue Shopping and you'll receive this message:

 

"Redirection limit for this URL exceeded. Unable to load the requested page. This may be caused by cookies that are blocked." And I don't think that the problem is with SEO URLs. :'(

 

Perhaps somebody with better PHP knowledge could help to finish it? Otherwise it will take me another six months until I learn more php! :blink:

 

Thanks for your help. And I hope it may help others with X-sell and SEO installed because both are great contributions that will boost your sales (if we can make them work together).

 

Alex

Absinthe Original Liquor Store

Link to comment
Share on other sites

BUY NOW BUTTON SORTED!!! :thumbsup:

 

OK, nobody wanted to help, so I decided to battle myself.

 

In /includes/modules/xsell_products.php find this bit of code:

<a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>');

And replace with this:

<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>');

 

Now, your "Buy Now" button will behive again! I've tested in my shop with SEO URLs installed and if it worked there, it will definitely work in yours as well! :-"

 

If you wish to see it in action, please feel free to have a look!

Absinthe Original Liquor Store

Link to comment
Share on other sites

Hi.

 

I need to ask a really stupid question.

 

After reading through the posts I'm seeing that Cross Sell also needs to be installed. Is this correct or does the xsell admin include the whole package? I have xsell admin installed but not cross sell. It shows up in my admin, but I can't figure out how to assign it to a specific product.

 

Before I install cross sell, do I need this to get xsell admin to work? If not, can I assign products to specific products?

Thanks!

Clesha

Link to comment
Share on other sites

BUY NOW BUTTON SORTED!!!  :thumbsup:

 

OK, nobody wanted to help, so I decided to battle myself.

 

In /includes/modules/xsell_products.php find this bit of code:

<a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>');

And replace with this:

<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>');

 

Now, your "Buy Now" button will behive again! I've tested in my shop with SEO URLs installed and if it worked there, it will definitely work in yours as well! :-"

 

If you wish to see it in action, please feel free to have a look!

 

Works Perfectly Now!!

WOW - U the man. Sorry was not around to put some input into it , but was away and on my return saw this solution.

You should add this into the contributions for others to download as an update.

 

Cheers!

Kunal

Link to comment
Share on other sites

Please help me!

This is what I get after installation X-Sell v2-MS2 - Cross Sell for MS2 from 30 Aug 2005 of mr_absinthe

Fatal error: Cannot instantiate non-existent class: contentboxheadingg in /home/xxxxx/public_html/xxxxx/includes/modules/xsell_products.php on line 37

In the place where it as to be infobox "We Also Recommend"

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

 

I have install this version:

 

xsell_v2.2_1

 

When, i browse product_info.php, i got this error:

 

Fatal error: Cannot instantiate non-existent class: contentboxheading in /home/httpd/vhosts/xxxxx/httpdocs/main/includes/modules/xsell_products.php on line 37

 

Thanks to help me =)

 

Bye.

Edited by zuckbin
Link to comment
Share on other sites

I have this installed and working fine but I also have "Advanced CartBox" in there.

 

My problem is when I go to add a product from the "Recommended" list with the "Display Cart After Adding Product" turned off so it stays on the original product it goes to "product not found". I am not sure where the bug is at... the CartBox or the X-Sell mods.

 

Actually I am sure it is X-Sell because I just fixed the bad "buy now" buttons and that is when it messed up on me.

 

Example product url:

http://www.buybuttonparts.com/shop/1434-st...r-kit-p-52.html

 

Any help would be greatly appreciated.

 

Lyle

Link to comment
Share on other sites

  • 3 weeks later...
BUY NOW BUTTON SORTED!!! :thumbsup:

 

OK, nobody wanted to help, so I decided to battle myself.

 

In /includes/modules/xsell_products.php find this bit of code:

<a href="' . tep_href_link(FILENAME_DEFAULT, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>');

And replace with this:

<a href="' . tep_href_link(basename($PHP_SELF), 'action=buy_now&products_id=' . $xsell['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $xsell['products_name'] . TEXT_NOW) .'</a>');

 

Now, your "Buy Now" button will behive again! I've tested in my shop with SEO URLs installed and if it worked there, it will definitely work in yours as well! :-"

 

If you wish to see it in action, please feel free to have a look!

Yep - I agree this works when you show the cart after each purchase, but what if you do not go to the shopping cart after each purchase - when I use this, I get list page with 'Product Not Found' displayed. The item has been successfully added to the cart, but we loose the original product info page we were on - Anybody know how I can fix this??????

Link to comment
Share on other sites

Yep - I agree this works when you show the cart after each purchase, but what if you do not go to the shopping cart after each purchase - when I use this, I get list page with 'Product Not Found' displayed. The item has been successfully added to the cart, but we loose the original product info page we were on - Anybody know how I can fix this??????

Somebody else out there must have this problem and have a solution. I know it's got to do with the product id being reset when you press the buy now button - but I would really love some help here guys!!!!! :wacko:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...