Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

I added it into product_info in the header between the php tags, however it seems that there is more to it because it still adds the 2 prices together for me.

You need to change the part that is just before the // EOF SPPC attributes mod to:

   for ($n = 0; $n < count($products_options); $n++) {
	  $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
		  if ($new_price) {
			$original_price = $new_price;
		  } else {
			$original_price = $product_info['products_price'];
		  }
		  if ($products_options[$n]['price_prefix'] == "-") // in case price lowers, don't add values, subtract 
		  {
				$show_price = 0.0 + $original_price - $products_options[$n]['options_values_price']; // force float (in case) using the 0.0;
			} else {
			  $show_price = 0.0 + $original_price + $products_options[$n]['options_values_price']; // force float (in case) using the 0.0;
			}
	  if ($products_options[$n]['options_values_price'] != '0') {
	  $options_text .= ' (' .  $currencies->display_price($show_price, tep_get_tax_rate($listing[$x]['products_tax_class_id'])) .') ';
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $currencies->display_price( $show_price, tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}
// EOF SPPC attributes mod

Link to comment
Share on other sites

Jan, thank you again for the help, but unfortunately I have a hard time following you. I'm sorry, but this is all very new to me, and there is far too much code in here for me to work with.

 

I changed the files as you mentioned in the product_info.php, and I see it modified something, but the price still is double. What it did was it displayed the doubled price in the style drop down box, so when you add it to cart it shows the same price, but I actually want to display the price that is on the front of the displayed page.

 

Look at this product so that you know what I am talking about: http://mishudesigns.com/osc/product_info.p...;products_id=46

 

I want the actual price to be $10.00, but you see that in the drop down option it displays it for $20.

 

As far as the displaying issue, I can't figure out what I need to change it to. I looked at the code and I just can't follow what you posted sorry. The odd thing is, the homepage works fine.

http://mishudesigns.com/osc/index.php

 

I can view details and add the product to cart. It seems to detect the product and all.

Link to comment
Share on other sites

Hello, I'm looking for some advice.

 

I operate a retail store which can be viewed at www.pagan-magic.co.uk and want to move into wholesale, from the documentation this mod would appear to be the correct one, but I just want to check a couple of things before I start.

 

Is there anyway to apply a discount to all of the products rather than price each one individually, I have over 4000 items listed so to do this manually would take some time!

 

I have just under 1000 customers registered, would they automatically be set as the deafult retail after the install?

 

What I am concerned about is causing the site to go off-line or prevent my regular customers from ordering while I set this up, any pointers would be greatly appreciated.

 

Many thanks

Link to comment
Share on other sites

Hello DawnG,

 

Are you just using SPPC? Or are you using quantity price breaks also. As far as the discount, do you mean as a whole group, such as I want to give group(1) Dealers 40% off retail?

 

Jr

Link to comment
Share on other sites

If you have made your Trusted group the default retail one (customer group id 0) all new customers will be set up with the default customer group, namely 0 and then that would happen yes.

 

 

Yes that was what i thought too. Of-course I did put the "Not Trusted" group as default.

The thing is that the customers in PWA seems not to be effected by this group settings?

 

I have one payment module possible for one group and the other for the other group.

But the PWA customers have both options?

 

So the question is still the same...

 

/Martin

Link to comment
Share on other sites

But the PWA customers have both options?

 

So the question is still the same...

I don't know at what point PWA enters any information in the table customers, but if it is after checkout_payment then yes, all payment options will be shown. That is because the query:

select IF(c.customers_payment_allowed <> '', c.customers_payment_allowed, cg.group_payment_allowed) as payment_allowed from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_GROUPS . " cg where c.customers_id = '" . $customer_id . "' and cg.customers_group_id =  '" . $customer_group_id . "'"

Wouldn't have given a result back and then the "if all fails" option of showing all payment options is taken:

   } else { // default
   $this->modules = explode(';', MODULE_PAYMENT_INSTALLED);
  }
// EOF Separate Pricing Per Customer

If that is the case, forget about checking the special settings for a customer but only query customers_groups for the payment options with:

select cg.group_payment_allowed as payment_allowed from " . TABLE_CUSTOMERS_GROUPS . " cg where cg.customers_group_id =  '" . $customer_group_id . "'"

Edited by Jan Zonjee
Link to comment
Share on other sites

unfortunately I have a hard time following you. I'm sorry, but this is all very new to me, and there is far too much code in here for me to work with.

Never mind then. Try changing this part:

$product_query = tep_db_query("select products_description, products_id from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$listing['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

to:

$product_query = tep_db_query("select products_description, products_id from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$listing[$x]['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

 

I changed the files as you mentioned in the product_info.php, and I see it modified something, but the price still is double. What it did was it displayed the doubled price in the style drop down box, so when you add it to cart it shows the same price, but I actually want to display the price that is on the front of the displayed page.

Well, if you enter an attribute price of + 10 then you will add $10 dollar to your price if you select that attribute. You don't enter net prices for a product when you edit that. You enter a price (or a price reduction or no price) for each attribute (a product can have several attributes).

Link to comment
Share on other sites

Is there anyway to apply a discount to all of the products rather than price each one individually, I have over 4000 items listed so to do this manually would take some time!

In a way yes and in a way no. You can do them all at once. This is mentioned in the download, changelog_v420.txt, Tips and Tricks:

How to add all prices to the product_groups table when they are a fraction of the retail price for a certain customer group:
http://www.oscommerce.com/forums/index.php?showtopic=53436&view=findpost&p=574372

 

I have just under 1000 customers registered, would they automatically be set as the deafult retail after the install?

Yes, when you do the sql for the installation they should all get a "0" as the default retail customer group. Even when I'm wrong you do that in one small query.

 

What I am concerned about is causing the site to go off-line or prevent my regular customers from ordering while I set this up, any pointers would be greatly appreciated.

It is best to first edit a copy of your shop and database on your own computer to see if everything works as it should. Then you do the sql part on the live shop and ftp the changed files to the live shop. If you follow the sequence from the install.html (which starts in the admin) then you should have very little to no down-time.

Link to comment
Share on other sites

If that is the case, forget about checking the special settings for a customer but only query customers_groups for the payment options with:

select cg.group_payment_allowed as payment_allowed from " . TABLE_CUSTOMERS_GROUPS . " cg where cg.customers_group_id =  '" . $customer_group_id . "'"

 

The thing is that I'm not sure WA puts any information in the customer table or atleast it is not stored.

PWA customers all have customer_id=0.

 

OK I think i will try to set up a if funtion in the "if all fails" part that checkes if it is a PWA customer. and then run a payment module setup for the group Not trusted. But I'm not sure how to do this. Do you think it is possible to do following?

 

select cg.group_payment_allowed as payment_allowed from " . TABLE_CUSTOMERS_GROUPS . " cg where cg.customers_group_id =  '0'

 

But then how to list the module?

 

 

Thank you/

M

Link to comment
Share on other sites

Wouldn't have given a result back and then the "if all fails" option of showing all payment options is taken:

   } else { // default
   $this->modules = explode(';', MODULE_PAYMENT_INSTALLED);
  }
// EOF Separate Pricing Per Customer

 

I actually goot it working now!

I made an extra if part in the "if all fails" part according to the following code:

 

	} else { // default

if ($customer_id == '0') {
	$customer_payment_query = tep_db_query("select cg.group_payment_allowed as payment_allowed from " . TABLE_CUSTOMERS_GROUPS . " cg where cg.customers_group_id = '0'");
if ($customer_payment = tep_db_fetch_array($customer_payment_query)  ) {
   if (tep_not_null($customer_payment['payment_allowed'])) {
$temp_payment_array = explode(';', $customer_payment['payment_allowed']);
  $installed_modules = explode(';', MODULE_PAYMENT_INSTALLED);
  for ($n = 0; $n < sizeof($installed_modules); $n++) {
	  // check to see if a payment method is not de-installed
	  if ( in_array($installed_modules[$n], $temp_payment_array ) ) {
		  $payment_array[] = $installed_modules[$n];
	  }
  } // end for loop
	$this->modules = $payment_array;
}
}
	} else {
		 $this->modules = explode(';', MODULE_PAYMENT_INSTALLED);
	}
  }
// EOF Separate Pricing Per Customer

 

 

if ($customer_id == '0') The customers of PWA always have the customer Id 0.

 

As the first $customer_payment_query is set to the payment allowed for customer group #0 (the not trusted group) I will probaby make a new group #2 that is the PWA group and change + to 2 in the code. In this way I will be able to set payment modules and other criterias for this group only...

 

Do you think this will be stable?

 

 

/Martin

Link to comment
Share on other sites

Hello Jan, yes that fixed the details and everything. What I am trying to do now is hide certain products that aren't available to customers, only to Wholesale users.

I'm trying to implement your mod into the site, however I am running into a few problems. Due to the fact that my shop is customized and has a custom template, it seems as though the index.php & other files aren't the same. I got most of the things implements and I uploaded the mysql table and everything there seems to work fine. I was wondering if you can take a lok at my index.php & application_top.php and tell me where I need to add your code so that your script works on my site. I will post them here.

 

Application_top.php

<?php
/*
 $Id: application_top.php,v 1.280 2003/07/12 09:38:07 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// start the timer for the page parse time log
 define('PAGE_PARSE_START_TIME', microtime());

// set the level of error reporting
 error_reporting(E_ALL & ~E_NOTICE);



// check if register_globals is enabled.
// since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
 if (function_exists('ini_get')) {
ini_get('register_globals') or exit('FATAL ERROR: register_globals is disabled in php.ini, please enable it!');
 }

// Set the local configuration parameters - mainly for developers
 if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');

// include server parameters
 require('includes/configure.php');

 if (strlen(DB_SERVER) < 1) {
if (is_dir('install')) {
  header('Location: install/index.php');
}
 }

// define the project version
 define('PROJECT_VERSION', 'osCommerce 2.2-MS2');

// set the type of request (secure or not)
 $request_type = (getenv('HTTPS') == 'on') ? 'SSL' : 'NONSSL';

// set php_self in the local scope
 if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];

 if ($request_type == 'NONSSL') {
define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG);
 } else {
define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG);
 }

// include the list of project filenames
 require(DIR_WS_INCLUDES . 'filenames.php');

// include the list of project database tables
 require(DIR_WS_INCLUDES . 'database_tables.php');

// customization for the design layout
 define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125)

// include the database functions
 require(DIR_WS_FUNCTIONS . 'database.php');

// make a connection to the database... now
 tep_db_connect() or die('Unable to connect to database server!');

// set the application parameters
 $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);
 while ($configuration = tep_db_fetch_array($configuration_query)) {
define($configuration['cfgKey'], $configuration['cfgValue']);
 }

// if gzip_compression is enabled, start to buffer the output
 if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) && (PHP_VERSION >= '4') ) {
if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) {
  if (PHP_VERSION >= '4.0.4') {
	ob_start('ob_gzhandler');
  } else {
	include(DIR_WS_FUNCTIONS . 'gzip_compression.php');
	ob_start();
	ob_implicit_flush();
  }
} else {
  ini_set('zlib.output_compression_level', GZIP_LEVEL);
}
 }

// set the HTTP GET parameters manually if search_engine_friendly_urls is enabled
 if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {
if (strlen(getenv('PATH_INFO')) > 1) {
  $GET_array = array();
  $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF);
  $vars = explode('/', substr(getenv('PATH_INFO'), 1));
  for ($i=0, $n=sizeof($vars); $i<$n; $i++) {
	if (strpos($vars[$i], '[]')) {
	  $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1];
	} else {
	  $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1];
	}
	$i++;
  }

  if (sizeof($GET_array) > 0) {
	while (list($key, $value) = each($GET_array)) {
	  $HTTP_GET_VARS[$key] = $value;
	}
  }
}
 }

// define general functions used application-wide
 require(DIR_WS_FUNCTIONS . 'general.php');
 require(DIR_WS_FUNCTIONS . 'html_output.php');

// set the cookie domain
 $cookie_domain = (($request_type == 'NONSSL') ? HTTP_COOKIE_DOMAIN : HTTPS_COOKIE_DOMAIN);
 $cookie_path = (($request_type == 'NONSSL') ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH);

// include cache functions if enabled
 if (USE_CACHE == 'true') include(DIR_WS_FUNCTIONS . 'cache.php');

// include shopping cart class
 require(DIR_WS_CLASSES . 'shopping_cart.php');

// include navigation history class
 require(DIR_WS_CLASSES . 'navigation_history.php');

// some code to solve compatibility issues
 require(DIR_WS_FUNCTIONS . 'compatibility.php');

// check if sessions are supported, otherwise use the php3 compatible session class
 if (!function_exists('session_start')) {
define('PHP_SESSION_NAME', 'osCsid');
define('PHP_SESSION_PATH', $cookie_path);
define('PHP_SESSION_DOMAIN', $cookie_domain);
define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY);

include(DIR_WS_CLASSES . 'sessions.php');
 }

// define how the session functions will be used
 require(DIR_WS_FUNCTIONS . 'sessions.php');

// set the session name and save path
 tep_session_name('osCsid');
 tep_session_save_path(SESSION_WRITE_DIRECTORY);

// set the session cookie parameters
  if (function_exists('session_set_cookie_params')) {
session_set_cookie_params(0, $cookie_path, $cookie_domain);
 } elseif (function_exists('ini_set')) {
ini_set('session.cookie_lifetime', '0');
ini_set('session.cookie_path', $cookie_path);
ini_set('session.cookie_domain', $cookie_domain);
 }

// set the session ID if it exists
  if (isset($HTTP_POST_VARS[tep_session_name()])) {
 tep_session_id($HTTP_POST_VARS[tep_session_name()]);
  } elseif ( ($request_type == 'SSL') && isset($HTTP_GET_VARS[tep_session_name()]) ) {
 tep_session_id($HTTP_GET_VARS[tep_session_name()]);
  }

// start the session
 $session_started = false;
 if (SESSION_FORCE_COOKIE_USE == 'True') {
tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain);

if (isset($HTTP_COOKIE_VARS['cookie_test'])) {
  tep_session_start();
  $session_started = true;
}
 } elseif (SESSION_BLOCK_SPIDERS == 'True') {
$user_agent = strtolower(getenv('HTTP_USER_AGENT'));
$spider_flag = false;

if (tep_not_null($user_agent)) {
  $spiders = file(DIR_WS_INCLUDES . 'spiders.txt');

  for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {
	if (tep_not_null($spiders[$i])) {
	  if (is_integer(strpos($user_agent, trim($spiders[$i])))) {
		$spider_flag = true;
		break;
	  }
	}
  }
}

if ($spider_flag == false) {
  tep_session_start();
  $session_started = true;
}
 } else {
tep_session_start();
$session_started = true;
 }

// set SID once, even if empty
 $SID = (defined('SID') ? SID : '');

// verify the ssl_session_id if the feature is enabled
 if ( ($request_type == 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'True') && (ENABLE_SSL == true) && ($session_started == true) ) {
$ssl_session_id = getenv('SSL_SESSION_ID');
if (!tep_session_is_registered('SSL_SESSION_ID')) {
  $SESSION_SSL_ID = $ssl_session_id;
  tep_session_register('SESSION_SSL_ID');
}

if ($SESSION_SSL_ID != $ssl_session_id) {
  tep_session_destroy();
  tep_redirect(tep_href_link(FILENAME_SSL_CHECK));
}
 }

// verify the browser user agent if the feature is enabled
 if (SESSION_CHECK_USER_AGENT == 'True') {
$http_user_agent = getenv('HTTP_USER_AGENT');
if (!tep_session_is_registered('SESSION_USER_AGENT')) {
  $SESSION_USER_AGENT = $http_user_agent;
  tep_session_register('SESSION_USER_AGENT');
}

if ($SESSION_USER_AGENT != $http_user_agent) {
  tep_session_destroy();
  tep_redirect(tep_href_link(FILENAME_LOGIN));
}
 }

// verify the IP address if the feature is enabled
 if (SESSION_CHECK_IP_ADDRESS == 'True') {
$ip_address = tep_get_ip_address();
if (!tep_session_is_registered('SESSION_IP_ADDRESS')) {
  $SESSION_IP_ADDRESS = $ip_address;
  tep_session_register('SESSION_IP_ADDRESS');
}

if ($SESSION_IP_ADDRESS != $ip_address) {
  tep_session_destroy();
  tep_redirect(tep_href_link(FILENAME_LOGIN));
}
 }

// create the shopping cart & fix the cart if necesary
 if (tep_session_is_registered('cart') && is_object($cart)) {
if (PHP_VERSION < 4) {
  $broken_cart = $cart;
  $cart = new shoppingCart;
  $cart->unserialize($broken_cart);
}
 } else {
tep_session_register('cart');
$cart = new shoppingCart;
 }

// include currencies class and create an instance
 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

// include the mail classes
 require(DIR_WS_CLASSES . 'mime.php');
 require(DIR_WS_CLASSES . 'email.php');

// set the language
 if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) {
if (!tep_session_is_registered('language')) {
  tep_session_register('language');
  tep_session_register('languages_id');
}

include(DIR_WS_CLASSES . 'language.php');
$lng = new language();

if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
  $lng->set_language($HTTP_GET_VARS['language']);
} else {
  $lng->get_browser_language();
}

$language = $lng->language['directory'];
$languages_id = $lng->language['id'];
 }

// include the language translations

 require(DIR_WS_LANGUAGES . $language . '.php');

// currency
 if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) {
if (!tep_session_is_registered('currency')) tep_session_register('currency');

if (isset($HTTP_GET_VARS['currency'])) {
  if (!$currency = tep_currency_exists($HTTP_GET_VARS['currency'])) $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
} else {
  $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
}
 }

// navigation history
 if (tep_session_is_registered('navigation')) {
if (PHP_VERSION < 4) {
  $broken_navigation = $navigation;
  $navigation = new navigationHistory;
  $navigation->unserialize($broken_navigation);
}
 } else {
tep_session_register('navigation');
$navigation = new navigationHistory;
 }
 $navigation->add_current_page();

// Shopping cart actions
 if (isset($HTTP_GET_VARS['action'])) {
// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled
if ($session_started == false) {
  tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
}

if (DISPLAY_CART == 'true') {
  $goto =  FILENAME_SHOPPING_CART;
  $parameters = array('action', 'cPath', 'products_id', 'pid');
} else {
  $goto = basename($PHP_SELF);
  if ($HTTP_GET_VARS['action'] == 'buy_now') {
	$parameters = array('action', 'pid', 'products_id');
  } else {
	$parameters = array('action', 'pid');
  }
}
switch ($HTTP_GET_VARS['action']) {
  // customer wants to update the product quantity in their shopping cart
  case 'update_product' : for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) {
							if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) {
							  $cart->remove($HTTP_POST_VARS['products_id'][$i]);
							} else {
							  if (PHP_VERSION < 4) {
								// if PHP3, make correction for lack of multidimensional array.
								reset($HTTP_POST_VARS);
								while (list($key, $value) = each($HTTP_POST_VARS)) {
								  if (is_array($value)) {
									while (list($key2, $value2) = each($value)) {
									  if (ereg ("(.*)\]\[(.*)", $key2, $var)) {
										$id2[$var[1]][$var[2]] = $value2;
									  }
									}
								  }
								}
								$attributes = ($id2[$HTTP_POST_VARS['products_id'][$i]]) ? $id2[$HTTP_POST_VARS['products_id'][$i]] : '';
							  } else {
								$attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : '';
							  }
							  $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
  // customer adds a product from the products page
  case 'add_product' :	if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
							$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
  // performed by the 'buy now' button in product listings and review page
  case 'buy_now' :		if (isset($HTTP_GET_VARS['products_id'])) {
							if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
							  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
							} else {
							  $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
  case 'notify' :		 if (tep_session_is_registered('customer_id')) {
							if (isset($HTTP_GET_VARS['products_id'])) {
							  $notify = $HTTP_GET_VARS['products_id'];
							} elseif (isset($HTTP_GET_VARS['notify'])) {
							  $notify = $HTTP_GET_VARS['notify'];
							} elseif (isset($HTTP_POST_VARS['notify'])) {
							  $notify = $HTTP_POST_VARS['notify'];
							} else {
							  tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
							}
							if (!is_array($notify)) $notify = array($notify);
							for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
							  $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'");
							  $check = tep_db_fetch_array($check_query);
							  if ($check['count'] < 1) {
								tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");
							  }
							}
							tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
						  } else {
							$navigation->set_snapshot();
							tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
						  }
						  break;
  case 'notify_remove' :  if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {
							$check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
							$check = tep_db_fetch_array($check_query);
							if ($check['count'] > 0) {
							  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
							}
							tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));
						  } else {
							$navigation->set_snapshot();
							tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
						  }
						  break;
  case 'cust_order' :	 if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {
							if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
							  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
							} else {
							  $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
}
 }

// include the who's online functions
 require(DIR_WS_FUNCTIONS . 'whos_online.php');
 tep_update_whos_online();

// include the password crypto functions
 require(DIR_WS_FUNCTIONS . 'password_funcs.php');

// include validation functions (right now only email address)
 require(DIR_WS_FUNCTIONS . 'validations.php');

// split-page-results
 require(DIR_WS_CLASSES . 'split_page_results.php');

// infobox
 require(DIR_WS_CLASSES . 'boxes.php');

// auto activate and expire banners
 require(DIR_WS_FUNCTIONS . 'banner.php');
 tep_activate_banners();
 tep_expire_banners();

// auto expire special products
 require(DIR_WS_FUNCTIONS . 'specials.php');
 tep_expire_specials();

// calculate category path
 if (isset($HTTP_GET_VARS['cPath'])) {
$cPath = $HTTP_GET_VARS['cPath'];
 } elseif (isset($HTTP_GET_VARS['products_id']) && !isset($HTTP_GET_VARS['manufacturers_id'])) {
$cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);
 } else {
$cPath = '';
 }

 if (tep_not_null($cPath)) {
$cPath_array = tep_parse_category_path($cPath);
$cPath = implode('_', $cPath_array);
$current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
 } else {
$current_category_id = 0;
 }

// include the breadcrumb class and start the breadcrumb trail
 require(DIR_WS_CLASSES . 'breadcrumb.php');
 $breadcrumb = new breadcrumb;

 //$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
 //$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));

// add category names or the manufacturer name to the breadcrumb trail
 if (isset($cPath_array)) {
for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {
  $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'");
  if (tep_db_num_rows($categories_query) > 0) {
	$categories = tep_db_fetch_array($categories_query);
	$breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
  } else {
	break;
  }
}
 } elseif (isset($HTTP_GET_VARS['manufacturers_id'])) {
$manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
if (tep_db_num_rows($manufacturers_query)) {
  $manufacturers = tep_db_fetch_array($manufacturers_query);
  $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']));
}
 }

// add the products model to the breadcrumb trail
 if (isset($HTTP_GET_VARS['products_id'])) {
$model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
if (tep_db_num_rows($model_query)) {
  $model = tep_db_fetch_array($model_query);
  $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
}
 }

// initialize the message stack for output messages
 require(DIR_WS_CLASSES . 'message_stack.php');
 $messageStack = new messageStack;

// set which precautions should be checked
 define('WARN_INSTALL_EXISTENCE', 'true');
 define('WARN_CONFIG_WRITEABLE', 'true');
 define('WARN_SESSION_DIRECTORY_NOT_WRITEABLE', 'true');
 define('WARN_SESSION_AUTO_START', 'true');
 define('WARN_DOWNLOAD_DIRECTORY_NOT_READABLE', 'true');
?>

 

Index.php

<?php
/*
 $Id: index.php,v 1.1 2003/06/11 17:37:59 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

// the following cPath references come from application_top.php
 $category_depth = 'top';
 if (isset($cPath) && tep_not_null($cPath)) {
$categories_products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
$cateqories_products = tep_db_fetch_array($categories_products_query);
if ($cateqories_products['total'] > 0) {
  $category_depth = 'products'; // display products
} else {
  $category_parent_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$current_category_id . "'");
  $category_parent = tep_db_fetch_array($category_parent_query);
  if ($category_parent['total'] > 0) {
	$category_depth = 'nested'; // navigate through the categories
  } else {
	$category_depth = 'products'; // category has no products, but display the 'no products' message
  }
}
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_DEFAULT);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

 <tr><td valign="top">
  <table border="0" cellspacing="0" cellpadding="0" style="width:100%;">
<tr><td style="background-color:#131516" valign="top" class="bg9"><?=tep_image(DIR_WS_IMAGES.'m21.gif')?></td>
	<td width="100%" style="background-color:#B4C016;">
	 <table border="0" cellspacing="0" cellpadding="0" style="width:100%;">
	  <tr><td width="213" class="bg12" valign="top"><?php require(DIR_WS_INCLUDES . 'column_left.php'); ?></td>
		  <td width="16"><?php echo tep_draw_separator('spacer.gif', '16', '1'); ?></td>
		  <td width="100%" class="bg13" valign="top">

<?php

 if ($category_depth == 'nested') {
// BOF SPPC Hide categories from groups
$category_query = tep_db_query("select cd.categories_name, c.categories_image from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$current_category_id . "' and cd.categories_id = '" . (int)$current_category_id . "' and cd.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', categories_hide_from_groups) = 0");
// EOF SPPC Hide categories from groups

$category = tep_db_fetch_array($category_query);

?>

<?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?>


<?

 } elseif ($category_depth == 'products' || isset($HTTP_GET_VARS['manufacturers_id'])) {
// create column list
$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
					 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
					 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
					 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
					 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
					 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
					 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE,
					 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);

asort($define_list);

$column_list = array();
reset($define_list);
while (list($key, $value) = each($define_list)) {
  if ($value > 0) $column_list[] = $key;
}

$select_column_list = '';

for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
  switch ($column_list[$i]) {
	case 'PRODUCT_LIST_MODEL':
	  $select_column_list .= 'p.products_model, ';
	  break;
	case 'PRODUCT_LIST_NAME':
	  $select_column_list .= 'pd.products_name, ';
	  break;
	case 'PRODUCT_LIST_MANUFACTURER':
	  $select_column_list .= 'm.manufacturers_name, ';
	  break;
	case 'PRODUCT_LIST_QUANTITY':
	  $select_column_list .= 'p.products_quantity, ';
	  break;
	case 'PRODUCT_LIST_IMAGE':
	  $select_column_list .= 'p.products_image, ';
	  break;
	case 'PRODUCT_LIST_WEIGHT':
	  $select_column_list .= 'p.products_weight, ';
	  break;
  }
}

// show the products of a specified manufacturer
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only a specific category
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'";
}
} else {
// show the products in a given categorie
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['filter_id'])) {
// We are asked to show only specific catgeory
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$HTTP_GET_VARS['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from ((" . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
}
}


if ( (!isset($HTTP_GET_VARS['sort'])) || (!ereg('[1-8][ad]', $HTTP_GET_VARS['sort'])) || (substr($HTTP_GET_VARS['sort'], 0, 1) > sizeof($column_list)) ) {
  for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
	if ($column_list[$i] == 'PRODUCT_LIST_NAME') {
	  $HTTP_GET_VARS['sort'] = $i+1 . 'a';
	  $listing_sql .= " order by pd.products_name";
	  break;
	}
  }
} else {
  $sort_col = substr($HTTP_GET_VARS['sort'], 0 , 1);
  $sort_order = substr($HTTP_GET_VARS['sort'], 1);
  $listing_sql .= ' order by ';
  switch ($column_list[$sort_col-1]) {
	case 'PRODUCT_LIST_MODEL':
	  $listing_sql .= "p.products_model " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
	  break;
	case 'PRODUCT_LIST_NAME':
	  $listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
	  break;
	case 'PRODUCT_LIST_MANUFACTURER':
	  $listing_sql .= "m.manufacturers_name " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
	  break;
	case 'PRODUCT_LIST_QUANTITY':
	  $listing_sql .= "p.products_quantity " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
	  break;
	case 'PRODUCT_LIST_IMAGE':
	  $listing_sql .= "pd.products_name";
	  break;
	case 'PRODUCT_LIST_WEIGHT':
	  $listing_sql .= "p.products_weight " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
	  break;
	case 'PRODUCT_LIST_PRICE':
	  $listing_sql .= "final_price " . ($sort_order == 'd' ? 'desc' : '') . ", pd.products_name";
	  break;
  }
}

// optional Product List Filter
$manu1="";
if (PRODUCT_LIST_FILTER > 0) {
  if (isset($HTTP_GET_VARS['manufacturers_id'])) {
	$filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' order by cd.categories_name";
  } else {
	$filterlist_sql= "select distinct m.manufacturers_id as id, m.manufacturers_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_MANUFACTURERS . " m where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by m.manufacturers_name";
  }
  $filterlist_query = tep_db_query($filterlist_sql);
  if (tep_db_num_rows($filterlist_query) > 1) {
	$manu1.= '<table width="100%" bgcolor="#ffffff" style="border-top:1px solid #969696;"><tr>			<td align="center" class="main">' . tep_draw_form('filter', FILENAME_DEFAULT, 'get') . TEXT_SHOW . ' ';
	if (isset($HTTP_GET_VARS['manufacturers_id'])) {
	  $manu1.= tep_draw_hidden_field('manufacturers_id', $HTTP_GET_VARS['manufacturers_id']);
	  $options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES));
	} else {
	  $manu1.= tep_draw_hidden_field('cPath', $cPath);
	  $options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS));
	}
	$manu1.= tep_draw_hidden_field('sort', $HTTP_GET_VARS['sort']);
	while ($filterlist = tep_db_fetch_array($filterlist_query)) {
	  $options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);
	}
	$manu1.= tep_draw_pull_down_menu('filter_id', $options, (isset($HTTP_GET_VARS['filter_id']) ? $HTTP_GET_VARS['filter_id'] : ''), 'onchange="this.form.submit()"');
	$manu1.= '</form></td></tr></table>' . "\n";
  }
}

// Get the right image for the top-right
$image = DIR_WS_IMAGES . 'table_background_list.gif';
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
  $image = tep_db_query("select manufacturers_image from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
  $image = tep_db_fetch_array($image);
  $image = $image['manufacturers_image'];
} elseif ($current_category_id) {
  $image = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
  $image = tep_db_fetch_array($image);
  $image = $image['categories_image'];
}
?>
<?php include(DIR_WS_MODULES . FILENAME_PRODUCT_LISTING); ?>
<?

} else {
?>
<?php include(DIR_WS_MODULES . FILENAME_NEW_PRODUCTS); ?>
<? } ?>


	  </td></tr>
	 </table>
	</td>
	<td style="background-color:#131516" valign="top" class="bg10"><?=tep_image(DIR_WS_IMAGES.'m23.gif')?></td></tr>
  </table>
 </td></tr>


<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

I just want to thankyou again for helping me and everyone else. I greatly appreciate it!

 

 

EDIT:

I would like to add that this is how I editted my application_top.php (following all the manual steps in the readme)

<?php
/*
 $Id: application_top.php,v 1.280 2003/07/12 09:38:07 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// start the timer for the page parse time log
 define('PAGE_PARSE_START_TIME', microtime());

// set the level of error reporting
 error_reporting(E_ALL & ~E_NOTICE);



// check if register_globals is enabled.
// since this is a temporary measure this message is hardcoded. The requirement will be removed before 2.2 is finalized.
 if (function_exists('ini_get')) {
ini_get('register_globals') or exit('FATAL ERROR: register_globals is disabled in php.ini, please enable it!');
 }

// Set the local configuration parameters - mainly for developers
 if (file_exists('includes/local/configure.php')) include('includes/local/configure.php');

// include server parameters
 require('includes/configure.php');

 if (strlen(DB_SERVER) < 1) {
if (is_dir('install')) {
  header('Location: install/index.php');
}
 }

// define the project version
 define('PROJECT_VERSION', 'osCommerce 2.2-MS2');

// set the type of request (secure or not)
 $request_type = (getenv('HTTPS') == 'on') ? 'SSL' : 'NONSSL';

// set php_self in the local scope
 if (!isset($PHP_SELF)) $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];

 if ($request_type == 'NONSSL') {
define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG);
 } else {
define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG);
 }

// include the list of project filenames
 require(DIR_WS_INCLUDES . 'filenames.php');

// include the list of project database tables
 require(DIR_WS_INCLUDES . 'database_tables.php');

// customization for the design layout
 define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125)

// include the database functions
 require(DIR_WS_FUNCTIONS . 'database.php');

// make a connection to the database... now
 tep_db_connect() or die('Unable to connect to database server!');

// set the application parameters
 $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);
 while ($configuration = tep_db_fetch_array($configuration_query)) {
define($configuration['cfgKey'], $configuration['cfgValue']);
 }

// if gzip_compression is enabled, start to buffer the output
 if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) && (PHP_VERSION >= '4') ) {
if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) {
  if (PHP_VERSION >= '4.0.4') {
	ob_start('ob_gzhandler');
  } else {
	include(DIR_WS_FUNCTIONS . 'gzip_compression.php');
	ob_start();
	ob_implicit_flush();
  }
} else {
  ini_set('zlib.output_compression_level', GZIP_LEVEL);
}
 }

// set the HTTP GET parameters manually if search_engine_friendly_urls is enabled
 if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {
if (strlen(getenv('PATH_INFO')) > 1) {
  $GET_array = array();
  $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF);
  $vars = explode('/', substr(getenv('PATH_INFO'), 1));
  for ($i=0, $n=sizeof($vars); $i<$n; $i++) {
	if (strpos($vars[$i], '[]')) {
	  $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1];
	} else {
	  $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1];
	}
	$i++;
  }

  if (sizeof($GET_array) > 0) {
	while (list($key, $value) = each($GET_array)) {
	  $HTTP_GET_VARS[$key] = $value;
	}
  }
}
 }

// define general functions used application-wide
 require(DIR_WS_FUNCTIONS . 'general.php');
 require(DIR_WS_FUNCTIONS . 'html_output.php');

// set the cookie domain
 $cookie_domain = (($request_type == 'NONSSL') ? HTTP_COOKIE_DOMAIN : HTTPS_COOKIE_DOMAIN);
 $cookie_path = (($request_type == 'NONSSL') ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH);

// include cache functions if enabled
 if (USE_CACHE == 'true') include(DIR_WS_FUNCTIONS . 'cache.php');

// include shopping cart class
 require(DIR_WS_CLASSES . 'shopping_cart.php');

// include navigation history class
 require(DIR_WS_CLASSES . 'navigation_history.php');

// some code to solve compatibility issues
 require(DIR_WS_FUNCTIONS . 'compatibility.php');

// check if sessions are supported, otherwise use the php3 compatible session class
 if (!function_exists('session_start')) {
define('PHP_SESSION_NAME', 'osCsid');
define('PHP_SESSION_PATH', $cookie_path);
define('PHP_SESSION_DOMAIN', $cookie_domain);
define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY);

include(DIR_WS_CLASSES . 'sessions.php');
 }

// define how the session functions will be used
 require(DIR_WS_FUNCTIONS . 'sessions.php');

// set the session name and save path
 tep_session_name('osCsid');
 tep_session_save_path(SESSION_WRITE_DIRECTORY);

// set the session cookie parameters
  if (function_exists('session_set_cookie_params')) {
session_set_cookie_params(0, $cookie_path, $cookie_domain);
 } elseif (function_exists('ini_set')) {
ini_set('session.cookie_lifetime', '0');
ini_set('session.cookie_path', $cookie_path);
ini_set('session.cookie_domain', $cookie_domain);
 }

// set the session ID if it exists
  if (isset($HTTP_POST_VARS[tep_session_name()])) {
 tep_session_id($HTTP_POST_VARS[tep_session_name()]);
  } elseif ( ($request_type == 'SSL') && isset($HTTP_GET_VARS[tep_session_name()]) ) {
 tep_session_id($HTTP_GET_VARS[tep_session_name()]);
  }

// start the session
 $session_started = false;
 if (SESSION_FORCE_COOKIE_USE == 'True') {
tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain);

if (isset($HTTP_COOKIE_VARS['cookie_test'])) {
  tep_session_start();
  $session_started = true;
}
 } elseif (SESSION_BLOCK_SPIDERS == 'True') {
$user_agent = strtolower(getenv('HTTP_USER_AGENT'));
$spider_flag = false;

if (tep_not_null($user_agent)) {
  $spiders = file(DIR_WS_INCLUDES . 'spiders.txt');

  for ($i=0, $n=sizeof($spiders); $i<$n; $i++) {
	if (tep_not_null($spiders[$i])) {
	  if (is_integer(strpos($user_agent, trim($spiders[$i])))) {
		$spider_flag = true;
		break;
	  }
	}
  }
}

if ($spider_flag == false) {
  tep_session_start();
  $session_started = true;
}
 } else {
tep_session_start();
$session_started = true;
 }

// set SID once, even if empty
 $SID = (defined('SID') ? SID : '');

// verify the ssl_session_id if the feature is enabled
 if ( ($request_type == 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'True') && (ENABLE_SSL == true) && ($session_started == true) ) {
$ssl_session_id = getenv('SSL_SESSION_ID');
if (!tep_session_is_registered('SSL_SESSION_ID')) {
  $SESSION_SSL_ID = $ssl_session_id;
  tep_session_register('SESSION_SSL_ID');
}

if ($SESSION_SSL_ID != $ssl_session_id) {
  tep_session_destroy();
  tep_redirect(tep_href_link(FILENAME_SSL_CHECK));
}
 }

// verify the browser user agent if the feature is enabled
 if (SESSION_CHECK_USER_AGENT == 'True') {
$http_user_agent = getenv('HTTP_USER_AGENT');
if (!tep_session_is_registered('SESSION_USER_AGENT')) {
  $SESSION_USER_AGENT = $http_user_agent;
  tep_session_register('SESSION_USER_AGENT');
}

if ($SESSION_USER_AGENT != $http_user_agent) {
  tep_session_destroy();
  tep_redirect(tep_href_link(FILENAME_LOGIN));
}
 }

// verify the IP address if the feature is enabled
 if (SESSION_CHECK_IP_ADDRESS == 'True') {
$ip_address = tep_get_ip_address();
if (!tep_session_is_registered('SESSION_IP_ADDRESS')) {
  $SESSION_IP_ADDRESS = $ip_address;
  tep_session_register('SESSION_IP_ADDRESS');
}

if ($SESSION_IP_ADDRESS != $ip_address) {
  tep_session_destroy();
  tep_redirect(tep_href_link(FILENAME_LOGIN));
}
 }

// create the shopping cart & fix the cart if necesary
 if (tep_session_is_registered('cart') && is_object($cart)) {
if (PHP_VERSION < 4) {
  $broken_cart = $cart;
  $cart = new shoppingCart;
  $cart->unserialize($broken_cart);
}
 } else {
tep_session_register('cart');
$cart = new shoppingCart;
 }

// include currencies class and create an instance
 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();

// include the mail classes
 require(DIR_WS_CLASSES . 'mime.php');
 require(DIR_WS_CLASSES . 'email.php');

// set the language
 if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) {
if (!tep_session_is_registered('language')) {
  tep_session_register('language');
  tep_session_register('languages_id');
}

include(DIR_WS_CLASSES . 'language.php');
$lng = new language();

if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) {
  $lng->set_language($HTTP_GET_VARS['language']);
} else {
  $lng->get_browser_language();
}

$language = $lng->language['directory'];
$languages_id = $lng->language['id'];
 }

// include the language translations

 require(DIR_WS_LANGUAGES . $language . '.php');

// currency
 if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) {
if (!tep_session_is_registered('currency')) tep_session_register('currency');

if (isset($HTTP_GET_VARS['currency'])) {
  if (!$currency = tep_currency_exists($HTTP_GET_VARS['currency'])) $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
} else {
  $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY;
}
 }

// navigation history
 if (tep_session_is_registered('navigation')) {
if (PHP_VERSION < 4) {
  $broken_navigation = $navigation;
  $navigation = new navigationHistory;
  $navigation->unserialize($broken_navigation);
}
 } else {
tep_session_register('navigation');
$navigation = new navigationHistory;
 }
 $navigation->add_current_page();

 // BOF Separate Pricing Per Customer v4.1, Hide products and categories from groups

 if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }


// Shopping cart actions
 if (isset($HTTP_GET_VARS['action'])) {
// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled
if ($session_started == false) {
  tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
}
  $hide_product = false;
 /* the shopping_cart page and some others sends an array 'products_id' or 'notify'. 
   That is dealt with separately. For the following code two new functions (tep_get_hide_status  
	 and tep_get_hide_status_single) should have been added to /includes/functions/general.php */
  if (isset($HTTP_POST_VARS['products_id']) && !is_array($HTTP_POST_VARS['products_id'])) {
	  $pid_for_hide = (int)$HTTP_POST_VARS['products_id'];
  } elseif (isset($HTTP_GET_VARS['products_id'])) {
	  $pid_for_hide = (int)$HTTP_GET_VARS['products_id'];
  } elseif (isset($HTTP_GET_VARS['pid'])) {
	  $pid_for_hide = (int)$HTTP_GET_VARS['pid'];
	  } elseif (isset($HTTP_GET_VARS['notify']) && !is_array($HTTP_GET_VARS['notify'])) {
	  $pid_for_hide = (int)$HTTP_GET_VARS['notify'];
		} elseif (isset($HTTP_POST_VARS['notify']) && !is_array($HTTP_POST_VARS['notify'])) {
			$pid_for_hide = (int)$HTTP_POST_VARS['notify'];
		}
if (tep_not_null($pid_for_hide)) {
		$hide_product = tep_get_hide_status_single($customer_group_id, $pid_for_hide);
} else {
		$hide_product = false;
	} // end if/else (tep_not_null($pid_for_hide))

	$temp_post_get_array = array();
	$hide_status_products = array();
if (is_array($HTTP_POST_VARS['products_id']) && tep_not_null($HTTP_POST_VARS['products_id']) && tep_not_null($HTTP_POST_VARS['products_id'][0])) {
		$temp_post_get_array = $HTTP_POST_VARS['products_id'];
		$hide_status_products = tep_get_hide_status($hide_status_products, $customer_group_id, $temp_post_get_array);
	} 
	  if (is_array($HTTP_GET_VARS['products_id']) && tep_not_null($HTTP_GET_VARS['products_id']) && tep_not_null($HTTP_GET_VARS['products_id'][0])) {
		$temp_post_get_array = $HTTP_GET_VARS['products_id'];
		$hide_status_products = tep_get_hide_status($hide_status_products, $customer_group_id, $temp_post_get_array);
	}
	if (is_array($HTTP_POST_VARS['notify']) && tep_not_null($HTTP_POST_VARS['notify']) && tep_not_null($HTTP_POST_VARS['notify'][0])) {
		$temp_post_get_array = $HTTP_POST_VARS['notify'];
		$hide_status_products = tep_get_hide_status($hide_status_products, $customer_group_id, $temp_post_get_array);
	} 
	if (is_array($HTTP_GET_VARS['notify']) && tep_not_null($HTTP_GET_VARS['notify']) && tep_not_null($HTTP_GET_VARS['notify'][0])) {
		$temp_post_get_array = $HTTP_GET_VARS['notify'];
		$hide_status_products = tep_get_hide_status($hide_status_products, $customer_group_id, $temp_post_get_array);
	} 		

if (!$hide_product) { // product does not need to be hidden from the customer group
// EOF Separate Pricing Per Customer v4.1, Hide products from groups mod

if (DISPLAY_CART == 'true') {
  $goto =  FILENAME_SHOPPING_CART;
  $parameters = array('action', 'cPath', 'products_id', 'pid');
} else {
  $goto = basename($PHP_SELF);
  if ($HTTP_GET_VARS['action'] == 'buy_now') {
	$parameters = array('action', 'pid', 'products_id');
  } else {
	$parameters = array('action', 'pid');
  }
}
switch ($HTTP_GET_VARS['action']) {
  // customer wants to update the product quantity in their shopping cart
  case 'update_product' : for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) {
							if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) {
							  $cart->remove($HTTP_POST_VARS['products_id'][$i]);
							} else {
							  if (PHP_VERSION < 4) {
								// if PHP3, make correction for lack of multidimensional array.
								reset($HTTP_POST_VARS);
								while (list($key, $value) = each($HTTP_POST_VARS)) {
								  if (is_array($value)) {
									while (list($key2, $value2) = each($value)) {
									  if (ereg ("(.*)\]\[(.*)", $key2, $var)) {
										$id2[$var[1]][$var[2]] = $value2;
									  }
									}
								  }
								}
								$attributes = ($id2[$HTTP_POST_VARS['products_id'][$i]]) ? $id2[$HTTP_POST_VARS['products_id'][$i]] : '';
							  } else {
								$attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : '';
							  }
							// BOF SPPC, Hide products and categories from groups
																foreach($hide_status_products as $key => $subarray) {
																  if ($subarray['products_id'] == tep_get_prid($HTTP_POST_VARS['products_id'][$i]) && $subarray['hidden'] == '0') {
							  $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false);
																	}
																} // end foreach($hide_status_products as $key => $subarray)
		// EOF SPPC, Hide products and categories from groups
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
  // customer adds a product from the products page
  case 'add_product' :	if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
							$cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
  // performed by the 'buy now' button in product listings and review page
  case 'buy_now' :		if (isset($HTTP_GET_VARS['products_id'])) {
							if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
							  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
							} else {
							  $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
  case 'notify' :		 if (tep_session_is_registered('customer_id')) {
							if (isset($HTTP_GET_VARS['products_id'])) {
							  $notify = $HTTP_GET_VARS['products_id'];
							} elseif (isset($HTTP_GET_VARS['notify'])) {
							  $notify = $HTTP_GET_VARS['notify'];
							} elseif (isset($HTTP_POST_VARS['notify'])) {
							  $notify = $HTTP_POST_VARS['notify'];
							} else {
							  tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
							}
							if (!is_array($notify)) $notify = array($notify);
							for ($i=0, $n=sizeof($notify); $i<$n; $i++) {
							  $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'");
							  $check = tep_db_fetch_array($check_query);
							  // BOF SPPC, Hide products and categories from groups
	if (is_array($hide_status_products) && tep_not_null($hide_status_products)) 
	{
		foreach($hide_status_products as $key => $subarray) {
		if ($subarray['products_id'] == tep_get_prid($notify[$i]) && $subarray['hidden'] == '0') 
		{
						if ($check['count'] < 1) 
						{
								tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");
							}
		} // end if ($subarray['products_id'] == tep_get_prid($notify[$i])...
	} // end foreach ($hide_status_products as $key => $subarray)
	else 
	{
		if ($check['count'] < 1) 
		{
						tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");
					}
	}
	// EOF SPPC, Hide products and categories from groups
							}
							tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));
						  } else {
							$navigation->set_snapshot();
							tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
						  }
						  break;
  case 'notify_remove' :  if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {
							$check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
							$check = tep_db_fetch_array($check_query);
							if ($check['count'] > 0) {
							  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");
							}
							tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));
						  } else {
							$navigation->set_snapshot();
							tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
						  }
						  break;
  case 'cust_order' :	 if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {
							if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {
							  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));
							} else {
							  $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
 } // end switch
// BOF Separate Pricing Per Customer v4.1, Hide products from groups mod
} else { // $hide_product is true
	tep_redirect(tep_href_link(FILENAME_DEFAULT));
}
// EOF Separate Pricing Per Customer v4.1, Hide products from groups mod
 } // if (isset($HTTP_GET_VARS['action']))

// include the who's online functions

 require(DIR_WS_FUNCTIONS . 'whos_online.php');
 tep_update_whos_online();

// include the password crypto functions
 require(DIR_WS_FUNCTIONS . 'password_funcs.php');

// include validation functions (right now only email address)
 require(DIR_WS_FUNCTIONS . 'validations.php');

// split-page-results
 require(DIR_WS_CLASSES . 'split_page_results.php');

// infobox
 require(DIR_WS_CLASSES . 'boxes.php');

// auto activate and expire banners
 require(DIR_WS_FUNCTIONS . 'banner.php');
 tep_activate_banners();
 tep_expire_banners();

// auto expire special products
 require(DIR_WS_FUNCTIONS . 'specials.php');
 tep_expire_specials();

// calculate category path
 if (isset($HTTP_GET_VARS['cPath'])) {
$cPath = $HTTP_GET_VARS['cPath'];
 } elseif (isset($HTTP_GET_VARS['products_id']) && !isset($HTTP_GET_VARS['manufacturers_id'])) {
$cPath = tep_get_product_path($HTTP_GET_VARS['products_id']);
 } else {
$cPath = '';
 }

 if (tep_not_null($cPath)) {
$cPath_array = tep_parse_category_path($cPath);
$cPath = implode('_', $cPath_array);
$current_category_id = $cPath_array[(sizeof($cPath_array)-1)];
 } else {
$current_category_id = 0;
 }

// include the breadcrumb class and start the breadcrumb trail
 require(DIR_WS_CLASSES . 'breadcrumb.php');
 $breadcrumb = new breadcrumb;

 //$breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER);
 //$breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT));

// add category names or the manufacturer name to the breadcrumb trail
// BOF Separate Pricing Per Customer
  if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
  } 

 if (isset($cPath_array)) {
for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) {   
  $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " cd left join " . TABLE_CATEGORIES . " c using(categories_id) where cd.categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0");
// EOF SPPC hide categories from groups
  if (tep_db_num_rows($categories_query) > 0) {
	$categories = tep_db_fetch_array($categories_query);
	$breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1)))));
  } else {
	break;
  }
}
 } elseif (isset($HTTP_GET_VARS['manufacturers_id'])) {
$manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
if (tep_db_num_rows($manufacturers_query)) {
  $manufacturers = tep_db_fetch_array($manufacturers_query);
  $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id']));
}
 }

// add the products model to the breadcrumb trail
 if (isset($HTTP_GET_VARS['products_id'])) {
// BOF SPPC hide categories from groups
$model_query = tep_db_query("select p.products_model from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c using(products_id) left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0");
// EOF SPPC hide categories from groups
if (tep_db_num_rows($model_query)) {
  $model = tep_db_fetch_array($model_query);
  $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id']));
}
 }

// initialize the message stack for output messages
 require(DIR_WS_CLASSES . 'message_stack.php');
 $messageStack = new messageStack;

// set which precautions should be checked
 define('WARN_INSTALL_EXISTENCE', 'true');
 define('WARN_CONFIG_WRITEABLE', 'true');
 define('WARN_SESSION_DIRECTORY_NOT_WRITEABLE', 'true');
 define('WARN_SESSION_AUTO_START', 'true');
 define('WARN_DOWNLOAD_DIRECTORY_NOT_READABLE', 'true');
?>

And I get this error:

Parse error: parse error, unexpected T_ELSE in c:\websites\sullivanmo315\mishudesigns.com\osc\includes\application_top.php on line 458

Edited by m0dhippy
Link to comment
Share on other sites

Does anyone know of a way to have different product descriptions depending upon the customer group?

 

For example, I have Retail and Wholesale customers, and for each product I want to have a different product description depending upon which group the customer belongs to.

 

Any ideas or direction would be greatly appreciated.

 

Thanks!

Randy

Link to comment
Share on other sites

Ok Jan, I fixed the application_top.php, I simply uploaded and overwrote yours with mine and it works fine, but the issue with Index.php still resides, so if you could just look at my code above and let me know where & what I have to modify, I would greatly appreciate it. Thanks in advance.

Link to comment
Share on other sites

Started upgrading: Clean RC1 installed, SPPC, Price Break for SPPC, Update for Price Break, Hide Products and Categories for SPPC, Happy Hour Specials Basic for SPPC, Country-State Selector, International Zones. So far, so good, all happy and working fine.

 

1) Hunted down "automatic customer group assign with drop-down" in this support thread - it works.

2) Hunted down "no free shipping for wholesale customers" in this support thread - it works.

 

No other mod's or customizations.

 

BUT...

Selecting customer group specific shipping for customer groups in admin does no longer work - my choice is still check-marked but the instruction is ignored - customer is presented with a choice of "flat rate" (which is desired for wholesale only) and "Zone Based" - intended for Regular Retail and others, if purchase doesn't qualify for free shipping.

 

Re. 1): I have set up four customer groups (id's 0-3) with the wholesale group set as id #3 (no automatic assign for them).

Re. 2): Because of "Re. 1)" I modified the "no free shipping" code:

 

checkout_shipping.php

CODE:

require(DIR_WS_CLASSES . 'shipping.php');

$shipping_modules = new shipping;

 

// BOF Separate Pricing Per Customer

if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '3') {

$customer_group_id = '0';

} else {

$customer_group_id = '1';

} // EOF Separate Pricing Per Customer

 

if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') && ($customer_group_id == '0') ) {

$pass = false;

END CODE

 

That all works fine and as intended.

 

Now I'm stuck - I don't know enough to know just where and HOW to modify/add code in order to restore the recognition of the choice of shipping for the customer groups in admin. (I'd like to keep the flexibility and not force the individual rates.).

 

PLEASE HELP :unsure:

I don't know how to come up with my own PHP, but am happy to cut-n-paste and modify existing code (I only know enough to be dangerous... o:) )

Thanks.

Cecilia

Link to comment
Share on other sites

Selecting customer group specific shipping for customer groups in admin does no longer work - my choice is still check-marked but the instruction is ignored - customer is presented with a choice of "flat rate" (which is desired for wholesale only) and "Zone Based" - intended for Regular Retail and others, if purchase doesn't qualify for free shipping.

Well, it looks like you force them to a customer_group_id they don't have with this piece of code in this particular file:

checkout_shipping.php

 require(DIR_WS_CLASSES . 'shipping.php');
 $shipping_modules = new shipping;

// BOF Separate Pricing Per Customer
if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '3') {
$customer_group_id = '0';
} else {
$customer_group_id = '1';
} // EOF Separate Pricing Per Customer

 if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') && ($customer_group_id == '0') ) {
$pass = false;

It looks like you meant to do this:

// BOF Separate Pricing Per Customer
if (isset($_SESSION['sppc_customer_group_id'])) {
$customer_group_id = $_SESSION['sppc_customer_group_id'];
} else {
$customer_group_id = '0';
} // EOF Separate Pricing Per Customer

 if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') && ($customer_group_id == '3') ) {
$pass = false;

Link to comment
Share on other sites

Has anyone tried with RC2 yet? I just made SPPC work with it, there is a few changes since instead of javascript they use mysql indexes. I have been checking it and using my calculator and everything seems to be working great. If anyone wants i can upload it and u can compare and see what i did. Maybe you can find any bugs so we can fix it and get a nice RC2 stable version.

Edited by BehrendsTech
Link to comment
Share on other sites

Jan, I'm still having this small problem with the prices.

If you look here: http://mishudesigns.com/osc/index.php?cPath=17

The price for "Black Ribbon Magnet Frame" is $0.00 (because I'm assigning the price from the product attribute versus the price from the catalog), but I want the price listen on the index page & the product_info page to show the same price as the one in the drop down box on this page: http://mishudesigns.com/osc/product_info.php?products_id=110

 

So it should display $14.00 instead of $0.00

Link to comment
Share on other sites

Well, it looks like you force them to a customer_group_id they don't have with this piece of code in this particular file:

checkout_shipping.php

 require(DIR_WS_CLASSES . 'shipping.php');
 $shipping_modules = new shipping;

// BOF Separate Pricing Per Customer
if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '3') {
$customer_group_id = '0';
} else {
$customer_group_id = '1';
} // EOF Separate Pricing Per Customer

 if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') && ($customer_group_id == '0') ) {
$pass = false;

It looks like you meant to do this:

// BOF Separate Pricing Per Customer
if (isset($_SESSION['sppc_customer_group_id'])) {
$customer_group_id = $_SESSION['sppc_customer_group_id'];
} else {
$customer_group_id = '0';
} // EOF Separate Pricing Per Customer

 if ( defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') && ($customer_group_id == '3') ) {
$pass = false;

 

That gives the free shipping to my wholesale group - but I did update my code, thanks! (In the modules/order_total/ot_shipping.php, too, setting the $customer_group_id to != '3' in the "if" statement in both.)

Problem still remains, though: shipping method assigned in admin gets ignored. For wholesale I want only flat rate, for all others I want only zone based - have set the groups accordingly in admin, yet ALL (including wholesale) get the choice of both flat rate and zone based.

The free shipping works just fine - wholesale doesn't get free shipping, all others do above a certain $amount - which is what I want in that respect.

Any further help would be much appreciated!

Thanks :unsure:

Link to comment
Share on other sites

Problem still remains, though: shipping method assigned in admin gets ignored.

Did you add the necessary changes to catalog/includes/classes/shipping.php? Someone reminded me not long ago that this file is missing from the package. The changes (there are not that many) are listed in the install.html though.

Link to comment
Share on other sites

Jan, I'm still having this small problem with the prices.

If you look here: http://mishudesigns.com/osc/index.php?cPath=17

The price for "Black Ribbon Magnet Frame" is $0.00 (because I'm assigning the price from the product attribute versus the price from the catalog), but I want the price listen on the index page & the product_info page to show the same price as the one in the drop down box on this page: http://mishudesigns.com/osc/product_info.php?products_id=110

 

So it should display $14.00 instead of $0.00

Then make the base price $14.00 and the attribute price $0.00. Using the Actual Attribute Pricing you will still see the correct total price in the drop-down, but the correct price also in the listings (there only the base price is shown).

Link to comment
Share on other sites

Does anyone know of a way to have different product descriptions depending upon the customer group?

 

For example, I have Retail and Wholesale customers, and for each product I want to have a different product description depending upon which group the customer belongs to.

That is a tough one. Making the products_description table depending on the customer_group_id sounds like a real pain to build.

 

Personally, I would see if I could place the customer group id dependent text outside of the description and "include" it depending on the customer group id. On product_info.php I would add code that would look in a subdirectory somewhere for a file with the products_id and customer group id in it. If it is there, include it for outputting. Otherwise show nothing.

Link to comment
Share on other sites

Hi Im implementing SPPC to my store it has been modified to use Quantity Price breaks per product. I have teh following code that I am unsure how to change to finalize the install.

 

Original code in OC from catalog product info.php around line 77

	if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
  $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
} else {
  $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
}

 

QPBPP had me change it to

	$pf->loadProduct((int)$HTTP_GET_VARS['products_id'], (int)$languages_id);
$products_price=$pf->getPriceString();

Portion of original code SPPC wants changed

 $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
} else {

 

SPPC states that it shoule be

// BOF Separate Pricing per Customer
  if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
	$scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
	if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
	  $product_info['products_price']= $scustomer_group_price['customers_group_price'];
	  }
  } // end if ($customer_group_id > 0)
// EOF Separate Pricing per Customer

  $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
} else {
// BOF Separate Pricing per Customer
  if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail
	$scustomer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id']. "' and customers_group_id =  '" . $customer_group_id . "'");
	if ($scustomer_group_price = tep_db_fetch_array($scustomer_group_price_query)) {
	$product_info['products_price']= $scustomer_group_price['customers_group_price'];
	}
} // end if ($customer_group_id > 0)
// EOF Separate Pricing per Customer

 

any idea how I can implement this portion and not loose the functionality of QPBPP. Sorry I am a PHP newbie.

Link to comment
Share on other sites

Hi Im implementing SPPC to my store it has been modified to use Quantity Price breaks per product.

You will need the QPBPP for SPPC version (it is in the contribution section, add manually, not updated to RC1 or RC2a). You can't use the original one in SPPC.

Link to comment
Share on other sites

You will need the QPBPP for SPPC version (it is in the contribution section, add manually, not updated to RC1 or RC2a). You can't use the original one in SPPC.

 

Thanks Jan didn't know there was one I will try and go back as I had the QPBPP mod first I will keep my fringers crossed. :)

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...