Jump to content
blucollarguy

Multi_Vendor_Shipping new thread

Recommended Posts

Part 2 of admin/includes/functions/general.php:

 

////
// 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 = '" . (int)$product_id . "'");

$product_reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where products_id = '" . (int)$product_id . "'");
while ($product_reviews = tep_db_fetch_array($product_reviews_query)) {
  tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$product_reviews['reviews_id'] . "'");
}
tep_db_query("delete from " . TABLE_REVIEWS . " where products_id = '" . (int)$product_id . "'");

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

 function tep_remove_order($order_id, $restock = false) {
if ($restock == 'on') {
  $order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
  while ($order = tep_db_fetch_array($order_query)) {
	tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity + " . $order['products_quantity'] . ", products_ordered = products_ordered - " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id'] . "'");
  }
}

tep_db_query("delete from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'");
tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
tep_db_query("delete from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "'");
tep_db_query("delete from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . (int)$order_id . "'");
tep_db_query("delete from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "'");
 }

 function tep_reset_cache_block($cache_block) {
global $cache_blocks;

for ($i=0, $n=sizeof($cache_blocks); $i<$n; $i++) {
  if ($cache_blocks[$i]['code'] == $cache_block) {
	if ($cache_blocks[$i]['multiple']) {
	  if ($dir = @opendir(DIR_FS_CACHE)) {
		while ($cache_file = readdir($dir)) {
		  $cached_file = $cache_blocks[$i]['file'];
		  $languages = tep_get_languages();
		  for ($j=0, $k=sizeof($languages); $j<$k; $j++) {
			$cached_file_unlink = ereg_replace('-language', '-' . $languages[$j]['directory'], $cached_file);
			if (ereg('^' . $cached_file_unlink, $cache_file)) {
			  @unlink(DIR_FS_CACHE . $cache_file);
			}
		  }
		}
		closedir($dir);
	  }
	} else {
	  $cached_file = $cache_blocks[$i]['file'];
	  $languages = tep_get_languages();
	  for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
		$cached_file = ereg_replace('-language', '-' . $languages[$i]['directory'], $cached_file);
		@unlink(DIR_FS_CACHE . $cached_file);
	  }
	}
	break;
  }
}
 }

 function tep_get_file_permissions($mode) {
// determine type
if ( ($mode & 0xC000) == 0xC000) { // unix domain socket
  $type = 's';
} elseif ( ($mode & 0x4000) == 0x4000) { // directory
  $type = 'd';
} elseif ( ($mode & 0xA000) == 0xA000) { // symbolic link
  $type = 'l';
} elseif ( ($mode & 0x8000) == 0x8000) { // regular file
  $type = '-';
} elseif ( ($mode & 0x6000) == 0x6000) { //bBlock special file
  $type = 'b';
} elseif ( ($mode & 0x2000) == 0x2000) { // character special file
  $type = 'c';
} elseif ( ($mode & 0x1000) == 0x1000) { // named pipe
  $type = 'p';
} else { // unknown
  $type = '?';
}

// determine permissions
$owner['read']	= ($mode & 00400) ? 'r' : '-';
$owner['write']   = ($mode & 00200) ? 'w' : '-';
$owner['execute'] = ($mode & 00100) ? 'x' : '-';
$group['read']	= ($mode & 00040) ? 'r' : '-';
$group['write']   = ($mode & 00020) ? 'w' : '-';
$group['execute'] = ($mode & 00010) ? 'x' : '-';
$world['read']	= ($mode & 00004) ? 'r' : '-';
$world['write']   = ($mode & 00002) ? 'w' : '-';
$world['execute'] = ($mode & 00001) ? 'x' : '-';

// adjust for SUID, SGID and sticky bit
if ($mode & 0x800 ) $owner['execute'] = ($owner['execute'] == 'x') ? 's' : 'S';
if ($mode & 0x400 ) $group['execute'] = ($group['execute'] == 'x') ? 's' : 'S';
if ($mode & 0x200 ) $world['execute'] = ($world['execute'] == 'x') ? 't' : 'T';

return $type .
	   $owner['read'] . $owner['write'] . $owner['execute'] .
	   $group['read'] . $group['write'] . $group['execute'] .
	   $world['read'] . $world['write'] . $world['execute'];
 }

 function tep_remove($source) {
global $messageStack, $tep_remove_error;

if (isset($tep_remove_error)) $tep_remove_error = false;

if (is_dir($source)) {
  $dir = dir($source);
  while ($file = $dir->read()) {
	if ( ($file != '.') && ($file != '..') ) {
	  if (is_writeable($source . '/' . $file)) {
		tep_remove($source . '/' . $file);
	  } else {
		$messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source . '/' . $file), 'error');
		$tep_remove_error = true;
	  }
	}
  }
  $dir->close();

  if (is_writeable($source)) {
	rmdir($source);
  } else {
	$messageStack->add(sprintf(ERROR_DIRECTORY_NOT_REMOVEABLE, $source), 'error');
	$tep_remove_error = true;
  }
} else {
  if (is_writeable($source)) {
	unlink($source);
  } else {
	$messageStack->add(sprintf(ERROR_FILE_NOT_REMOVEABLE, $source), 'error');
	$tep_remove_error = true;
  }
}
 }

////
// Output the tax percentage with optional padded decimals
 function tep_display_tax_value($value, $padding = TAX_DECIMAL_PLACES) {
if (strpos($value, '.')) {
  $loop = true;
  while ($loop) {
	if (substr($value, -1) == '0') {
	  $value = substr($value, 0, -1);
	} else {
	  $loop = false;
	  if (substr($value, -1) == '.') {
		$value = substr($value, 0, -1);
	  }
	}
  }
}

if ($padding > 0) {
  if ($decimal_pos = strpos($value, '.')) {
	$decimals = strlen(substr($value, ($decimal_pos+1)));
	for ($i=$decimals; $i<$padding; $i++) {
	  $value .= '0';
	}
  } else {
	$value .= '.';
	for ($i=0; $i<$padding; $i++) {
	  $value .= '0';
	}
  }
}

return $value;
 }

 function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {
if (SEND_EMAILS != 'true') return false;

// Instantiate a new mail object
$message = new email(array('X-Mailer: osCommerce'));

// Build the text version
$text = strip_tags($email_text);
if (EMAIL_USE_HTML == 'true') {
  $message->add_html($email_text, $text);
} else {
  $message->add_text($text);
}

// Send message
$message->build_message();
$message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);
 }

 function tep_get_tax_class_title($tax_class_id) {
if ($tax_class_id == '0') {
  return TEXT_NONE;
} else {
  $classes_query = tep_db_query("select tax_class_title from " . TABLE_TAX_CLASS . " where tax_class_id = '" . (int)$tax_class_id . "'");
  $classes = tep_db_fetch_array($classes_query);

  return $classes['tax_class_title'];
}
 }

 function tep_banner_image_extension() {
if (function_exists('imagetypes')) {
  if (imagetypes() & IMG_PNG) {
	return 'png';
  } elseif (imagetypes() & IMG_JPG) {
	return 'jpg';
  } elseif (imagetypes() & IMG_GIF) {
	return 'gif';
  }
} elseif (function_exists('imagecreatefrompng') && function_exists('imagepng')) {
  return 'png';
} elseif (function_exists('imagecreatefromjpeg') && function_exists('imagejpeg')) {
  return 'jpg';
} elseif (function_exists('imagecreatefromgif') && function_exists('imagegif')) {
  return 'gif';
}

return false;
 }

////
// Wrapper function for round() for php3 compatibility
 function tep_round($value, $precision) {
if (PHP_VERSION < 4) {
  $exp = pow(10, $precision);
  return round($value * $exp) / $exp;
} else {
  return round($value, $precision);
}
 }

////
// Add tax to a products price
 function tep_add_tax($price, $tax) {
global $currencies;

if (DISPLAY_PRICE_WITH_TAX == 'true') {
  return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + tep_calculate_tax($price, $tax);
} else {
  return tep_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
}
 }

// Calculates Tax rounding the result
 function tep_calculate_tax($price, $tax) {
global $currencies;

return tep_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
 }

////
// Returns the tax rate for a zone / class
// TABLES: tax_rates, zones_to_geo_zones
 function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) {
global $customer_zone_id, $customer_country_id;

if ( ($country_id == -1) && ($zone_id == -1) ) {
  if (!tep_session_is_registered('customer_id')) {
	$country_id = STORE_COUNTRY;
	$zone_id = STORE_ZONE;
  } else {
	$country_id = $customer_country_id;
	$zone_id = $customer_zone_id;
  }
}

$tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " tr left join " . TABLE_ZONES_TO_GEO_ZONES . " za ON tr.tax_zone_id = za.geo_zone_id left join " . TABLE_GEO_ZONES . " tz ON tz.geo_zone_id = tr.tax_zone_id WHERE (za.zone_country_id IS NULL OR za.zone_country_id = '0' OR za.zone_country_id = '" . (int)$country_id . "') AND (za.zone_id IS NULL OR za.zone_id = '0' OR za.zone_id = '" . (int)$zone_id . "') AND tr.tax_class_id = '" . (int)$class_id . "' GROUP BY tr.tax_priority");
if (tep_db_num_rows($tax_query)) {
  $tax_multiplier = 0;
  while ($tax = tep_db_fetch_array($tax_query)) {
	$tax_multiplier += $tax['tax_rate'];
  }
  return $tax_multiplier;
} else {
  return 0;
}
 }

////
// Returns the tax rate for a tax class
// TABLES: tax_rates
 function tep_get_tax_rate_value($class_id) {
$tax_query = tep_db_query("select SUM(tax_rate) as tax_rate from " . TABLE_TAX_RATES . " where tax_class_id = '" . (int)$class_id . "' group by tax_priority");
if (tep_db_num_rows($tax_query)) {
  $tax_multiplier = 0;
  while ($tax = tep_db_fetch_array($tax_query)) {
	$tax_multiplier += $tax['tax_rate'];
  }
  return $tax_multiplier;
} else {
  return 0;
}
 }

 function tep_call_function($function, $parameter, $object = '') {
if ($object == '') {
  return call_user_func($function, $parameter);
} elseif (PHP_VERSION < 4) {
  return call_user_method($function, $object, $parameter);
} else {
  return call_user_func(array($object, $function), $parameter);
}
 }

 function tep_get_zone_class_title($zone_class_id) {
if ($zone_class_id == '0') {
  return TEXT_NONE;
} else {
  $classes_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$zone_class_id . "'");
  $classes = tep_db_fetch_array($classes_query);

  return $classes['geo_zone_name'];
}
 }

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

$zone_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
$zone_class_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " order by geo_zone_name");
while ($zone_class = tep_db_fetch_array($zone_class_query)) {
  $zone_class_array[] = array('id' => $zone_class['geo_zone_id'],
							  'text' => $zone_class['geo_zone_name']);
}

return tep_draw_pull_down_menu($name, $zone_class_array, $zone_class_id);
 }

 function tep_cfg_pull_down_order_statuses($order_status_id, $key = '') {
global $languages_id;

$name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');

$statuses_array = array(array('id' => '0', 'text' => TEXT_DEFAULT));
$statuses_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_name");
while ($statuses = tep_db_fetch_array($statuses_query)) {
  $statuses_array[] = array('id' => $statuses['orders_status_id'],
							'text' => $statuses['orders_status_name']);
}

return tep_draw_pull_down_menu($name, $statuses_array, $order_status_id);
 }

 function tep_get_order_status_name($order_status_id, $language_id = '') {
global $languages_id;

if ($order_status_id < 1) return TEXT_DEFAULT;

if (!is_numeric($language_id)) $language_id = $languages_id;

$status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . (int)$order_status_id . "' and language_id = '" . (int)$language_id . "'");
$status = tep_db_fetch_array($status_query);

return $status['orders_status_name'];
 }

////
// Return a random value
 function tep_rand($min = null, $max = null) {
static $seeded;

if (!$seeded) {
  mt_srand((double)microtime()*1000000);
  $seeded = true;
}

if (isset($min) && isset($max)) {
  if ($min >= $max) {
	return $min;
  } else {
	return mt_rand($min, $max);
  }
} else {
  return mt_rand();
}
 }

// nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n)
 function tep_convert_linefeeds($from, $to, $string) {
if ((PHP_VERSION < "4.0.5") && is_array($from)) {
  return ereg_replace('(' . implode('|', $from) . ')', $to, $string);
} else {
  return str_replace($from, $to, $string);
}
 }

 function tep_string_to_int($string) {
return (int)$string;
 }

////
// Parse and secure the cPath parameter values
 function tep_parse_category_path($cPath) {
// make sure the category IDs are integers
$cPath_array = array_map('tep_string_to_int', explode('_', $cPath));

// make sure no duplicate category IDs exist which could lock the server in a loop
$tmp_array = array();
$n = sizeof($cPath_array);
for ($i=0; $i<$n; $i++) {
  if (!in_array($cPath_array[$i], $tmp_array)) {
	$tmp_array[] = $cPath_array[$i];
  }
}

return $tmp_array;
 }
?>


Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Share this post


Link to post
Share on other sites
The telephone number should be easy to do. Add
customers_telephone,

to the $delivery_address_query string in line 331. Anywhere in the list is fine. Then add

 . $vendor_delivery_address_list['customers_telephone'] . '<br><br>'

to the end of Line 355 (just before the semicolon. The last bit could be placed wherever you want it in the email string (Lines 346 to 356 in my copy.)

 

Having options like this that can be turned off or on in the Admin sounds like a good idea. If you can think of other things (besides telephone number) that should be added, post them here. They can be added to a later edition of MVS. If Craig agrees that this is a good idea, of course.

 

Regards

Jim

 

Thanks Jim.

 

I decided to code in an option so if the character "^" appears in Vendor Additional Info, then the email to the vendor includes the customers phone number. I suppose in some cases you might be not want to give vendors too much customer information !!

 

if (strpos($vendor_order['vendor_add_info'], "^") === false) {
$email = $email . '<br><br>';
} else {   
$email = $email . '<br><br>' . $vendor_delivery_address_list['customers_telephone'] . '<br><br>';
}

 

Cheers,

 

Paul.

Share this post


Link to post
Share on other sites
Part 2 of admin/includes/functions/general.php:

 

////>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

return $tmp_array;
 }
?>

I think you have a bigger problem: MS1. You are not using MS2 and MVS will be difficult at best to get working on your site. Can you update to MS2? Your problems would disappear if you do.

 

Good luck, Craig :)


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites
Thanks Jim.

 

I decided to code in an option so if the character "^" appears in Vendor Additional Info, then the email to the vendor includes the customers phone number. I suppose in some cases you might be not want to give vendors too much customer information !!

 

if (strpos($vendor_order['vendor_add_info'], "^") === false) {
$email = $email . '<br><br>';
} else {   
$email = $email . '<br><br>' . $vendor_delivery_address_list['customers_telephone'] . '<br><br>';
}

 

Cheers,

 

Paul.

That was an interesting approach Paul. Very nice.

 

Craig :)


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites

So I need the MVS 2.0 if I do what page is that contribution at?


Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Share this post


Link to post
Share on other sites

I just finished loading the newest version of MVS. Was easy to accomplish and the instructions were well written. However ---- I do have a problem now. I received the following when attempting to call up the admin:

 

1146 - Table 'ltldoc_osc1.TABLE_VENDOR_CONFIGURATION' doesn't exist

 

select configuration_key as cfgKey, configuration_value as cfgValue from TABLE_VENDOR_CONFIGURATION

 

[TEP STOP]

 

Now I am certain that I followed the instruction to the letter. What did I do wrong???

 

Kurt

Edited by ltldoc

Share this post


Link to post
Share on other sites
So I need the MVS 2.0 if I do what page is that contribution at?

 

I believe what he is telling you is that you need to upgrade your oscommerce. There is no (at least none that I can find) version 2.0 of MVS. Right now I believe it only goes to V1.1.

 

Kurt

Share this post


Link to post
Share on other sites
I believe what he is telling you is that you need to upgrade your oscommerce. There is no (at least none that I can find) version 2.0 of MVS. Right now I believe it only goes to V1.1.

 

Kurt

 

 

Well I am using MS2

Edited by mtechama

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Share this post


Link to post
Share on other sites
I just finished loading the newest version of MVS. Was easy to accomplish and the instructions were well written. However ---- I do have a problem now. I received the following when attempting to call up the admin:

 

1146 - Table 'ltldoc_osc1.TABLE_VENDOR_CONFIGURATION' doesn't exist

 

select configuration_key as cfgKey, configuration_value as cfgValue from TABLE_VENDOR_CONFIGURATION

 

[TEP STOP]

 

Now I am certain that I followed the instruction to the letter. What did I do wrong???

 

Kurt

This is an easy fix, in admin/includes/database_tables.php:

=============
Find Line 57
=============

 define('TABLE_ZONES', 'zones');


============================================
Add After Line 57 and before the closing ?>
============================================

  //MVS start
 define('TABLE_VENDORS', 'vendors');
 define('TABLE_VENDORS_INFO', 'vendors_info');
 define('TABLE_VENDOR_CONFIGURATION', 'vendor_configuration');
 define('TABLE_ORDERS_SHIPPING', 'orders_shipping');
 define('TABLE_PACKAGING', 'packaging');
  //MVS end

Note that this was my bug, I have the wrong data to add in this block of the admin install instructions.

 

V1.2 just got started.

 

Sorry about that.


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites
So I need the MVS 2.0 if I do what page is that contribution at?

NO, the version of osCommerce you are running is not compatible with MVS, or vice/versa. Kurt is right, you will need to upgrade your website first, then add MVS.

 

Sorry, Craig :(


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites

well I am using oscommerce-2.2ms2


Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Share this post


Link to post
Share on other sites
well I am using oscommerce-2.2ms2

That is difficult. Your dates on the id's of the files you posted are 2002, and some of the code that is there, is no longer in those files. the error "tep_array_merge" is from a function that was added in MS2 2.2. So I don't think it really is MS2 2.2.

 

What you could try is to download the latest osC, and do a diff on these particular files, being very careful not to delete any of the code in the original file on your site, but you could add to it from the newer version. Or upgrade the whole site.

 

Craig :)


Happy Coding!

Craig Garrison Sr

Anything worth having, is worth working for.

Multi Vendor Shipping V1.1 Demo Catalog

3 Vendors, each category, "buy" a product from each category to see how MVS works during checkout.

Multi Vendor Shipping V1.1 Demo Admin

login: webmaster@blucollarsales.com

pass: mvs_demo

MVS Thread:

Multi-Vendor Shipping

My contribs:

Download Multi Vendor Shipping V1.1

Vendor Email

Vendor Info in easypopulate

EZ Price Updater

And more to come!

Share this post


Link to post
Share on other sites
well I am using oscommerce-2.2ms2

The version of includes/functions/general.php that you are using is current for MS2, but your version of application_top.php is older. You are also getting error messages complaining about functions being missing, yet those functions are a part of stock MS2. So no, your version is not really MS2. Perhaps it is a CVS that slightly predates MS2. In any case, you have a lot of work to do to bring this code up to the point of being usable with MVS.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Man I am totally confused here................. Ok what did I just download of OScommerce? oscommerce-2.2ms2 that is what I just downloaded

Edited by mtechama

Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Share this post


Link to post
Share on other sites
is this a way to I can tell?

 

i.e.:

 

$Id: english.php,v 1.114 2003/07/09 18:13:39 dgw_ Exp $

Yes. download a current copy of MS2 and compare those headers to the same files in your version. Most should match. See the notes in the distribution about the files that have been updated recently -- those few files will not match.

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
Yes. download a current copy of MS2 and compare those headers to the same files in your version. Most should match. See the notes in the distribution about the files that have been updated recently -- those few files will not match.

 

Regards

Jim

 

I just downloaded the current zip file


Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Share this post


Link to post
Share on other sites
This is an easy fix, in admin/includes/database_tables.php:

=============
Find Line 57
=============

 define('TABLE_ZONES', 'zones');
============================================
Add After Line 57 and before the closing ?>
============================================

  //MVS start
 define('TABLE_VENDORS', 'vendors');
 define('TABLE_VENDORS_INFO', 'vendors_info');
 define('TABLE_VENDOR_CONFIGURATION', 'vendor_configuration');
 define('TABLE_ORDERS_SHIPPING', 'orders_shipping');
 define('TABLE_PACKAGING', 'packaging');
  //MVS end

Note that this was my bug, I have the wrong data to add in this block of the admin install instructions.

 

V1.2 just got started.

 

Sorry about that.

 

Thanks for your help. Its working like a dream now. Wish all these contributions were as smooth to take care of and as well documented. Good Job.

 

Kurt

Share this post


Link to post
Share on other sites
Man I am totally confused here................. Ok what did I just download of OScommerce? oscommerce-2.2ms2 that is what I just downloaded

I just pulled a fresh copy, and admin/includes/application_top.php says that it is:

  $Id: application_top.php,v 1.162 2003/07/12 09:39:03 hpdl Exp $

Yours is clearly much older. Did you install some other contribution that overwrote files?

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
Yes. download a current copy of MS2 and compare those headers to the same files in your version. Most should match. See the notes in the distribution about the files that have been updated recently -- those few files will not match.

 

Regards

Jim

 

 

is that mine or yours?


Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Share this post


Link to post
Share on other sites

Jim are you saying that I got to modify changes in all these files?

 

catalog/admin/includes/classes/email.php

catalog/admin/includes/classes/split_page_results.php

catalog/admin/includes/classes/upload.php

catalog/admin/includes/functions/database.php

catalog/admin/includes/functions/general.php

catalog/admin/includes/functions/html_output.php

catalog/admin/categories.php

catalog/admin/file_manager.php

catalog/admin/orders.php

 

catalog/includes/classes/email.php

catalog/includes/classes/shopping_cart.php

catalog/includes/classes/split_page_results.php

catalog/includes/functions/database.php

catalog/includes/functions/general.php

catalog/includes/functions/html_output.php

catalog/includes/functions/sessions.php

catalog/address_book_process.php (051113)

catalog/advanced_search_result.php

catalog/index.php

catalog/redirect.php


Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Share this post


Link to post
Share on other sites

Went to set up my vendors and found this message at the bottom of the configuration screen:

 

Fatal error: Call to undefined function: tep_get_country_list() in /home/ltldoc/public_html/ltldoc01/admin/vendors.php on line 393

 

Line 393 of Vendors.php says this:

 

echo tep_get_country_list('vendor_country', $vInfo->vendor_country);

 

Did I miss making an appropriate entry when changing the file??

 

Thanks

 

Kurt

Share this post


Link to post
Share on other sites
is that mine or yours?

Just to be certain, I downloaded all four current copies of osCommerce (zip and tarball, two sources.) All four of them match the header that I pasted above. Yours doesn't. I don't know where you got that copy, but it's not stock MS2. I see notes in your application_top.php about other contributions that have been added: mltship, featured items, paypalipn. If you got this as a "loaded" or already-modified version of osCommerce, it was not based on MS2. If you are just starting out, then go get a real copy of MS2 and start from there. If not, you have a lot of work to do.

 

Regards

Jim

Edited by kymation

See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
I just pulled a fresh copy, and admin/includes/application_top.php says that it is:

  $Id: application_top.php,v 1.162 2003/07/12 09:39:03 hpdl Exp $

Yours is clearly much older. Did you install some other contribution that overwrote files?

 

Regards

Jim

 

well this is mine: admin/includes/application_top.php

 

 $Id: application_top.php,v 1.162 2003/07/12 09:39:03 hpdl Exp $


Wade Morris

Amarillo, Texas

 

Before you do any changes on your site you need to do BACKUP! BACKUP!

Share this post


Link to post
Share on other sites
Went to set up my vendors and found this message at the bottom of the configuration screen:

 

Fatal error: Call to undefined function: tep_get_country_list() in /home/ltldoc/public_html/ltldoc01/admin/vendors.php on line 393

 

Line 393 of Vendors.php says this:

 

echo tep_get_country_list('vendor_country', $vInfo->vendor_country);

 

Did I miss making an appropriate entry when changing the file??

 

Thanks

 

Kurt

tep_get_country_list is a standard part of osCommerce: includes/functions/html_output.php, Line 288. What have you people been getting into lately? The Twilight Zone?

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites
well this is mine: admin/includes/application_top.php

 

 $Id: application_top.php,v 1.162 2003/07/12 09:39:03 hpdl Exp $

The one that you posted on the previous page is

$Id: application_top.php,v 1.1.4.2 2002/06/19 14:14:02 mdima Exp $

?????

 

Regards

Jim


See my profile for a list of my addons and ways to get support.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×