Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Only product A prices. It should be possible to group products together into a discount group and use their total number to calculate the discount. Say a combination of A and B that is more than 3 (4 x A, 3 x A + 1 x B, 2 x A + 2 x B, etcetera) will give a discount on both product.

 

However, that is not written yet :)

 

Excellent! It does exactly what I need it too! :thumbsup:

 

I'll be installing that one next (most likely after we go live) :D

~Tracy
 

Link to comment
Share on other sites

This has already been coded, but never released or written up as instructions on how to add to your site (just the changed files). It is parked somewhere on the internet that I like to keep Google etc. out of, so I will PM you the url of where you can download those files.

 

 

Is it possible to get this information on how to do this ?

 

I am selling to businesses that are reselling the product and would like them to be PST Exempt.

 

Thanks

_________________________________________________________________________

 

David G Aschenbrener

Tranquil | Sense - Your Stop for Tranquility.

Link to comment
Share on other sites

Allright, so I can edit all the things that I need to, however the Customer Group Numbers under Customers -> Customers for both my Test group and Retail are 1, which I think is connected to the reason why my special prices are not showing up for the test user I created for the Test group. What can I do to fix this?

Link to comment
Share on other sites

Ok, correction, the number thing, ignore that... I figured out what it meant. Either way, the pricing does not show. I've gone all the way through to the end and "purchased" through the site and still nothing on the products. Why is this? No visible errors either by the way.

Link to comment
Share on other sites

Either way, the pricing does not show. I've gone all the way through to the end and "purchased" through the site and still nothing on the products. Why is this? No visible errors either by the way.

Hard to say. First thing to check is what customer group you are "surfing under". You could add to the bottom of the file:

<?php
echo '<pre>';
print_r($_SESSION);
?>

and check if sppc_customer_group_id is set and what the number is (retail is zero, all others 1 and higher).

Link to comment
Share on other sites

I could use some help figuring out where this error is coming from when I try to add anything to the cart without being logged in:

 

1052 - Column 'products_id' in where clause is ambiguous

 

select products_status, options_id, options_values_id, attributes_hide_from_groups, '0' as hide_attr_status from products left join products_attributes using(products_id) where products_id = '86'

That's a mysql4 error :)

 

Better make a few small changes as mentioned in this post.

 

I'm also unable to add any attribute products to the cart - I get this error message on the page:

 

Error Please select your desired option from the available choices.

??? New one for me. Let's see if it still there after you fixed the above error.
Link to comment
Share on other sites

Sorry guys in case this was asked before (I searched and searched):

 

I have trouble getting the special admin login to work. The email address is entered in login.php.

Once I login with the subscriber I get the new "Choose a customer group" window (https://mystore.com/dev_shop/login.php/action/process).

 

When I click continue the url changes to: https://mystore.com/dev_shop/login.php/acti...ocess/skip/true and I see the same "Choose a customer group" window again.

 

I compared the login.php files but can't find the problem

Any idea?

Link to comment
Share on other sites


Hard to say. First thing to check is what customer group you are "surfing under". You could add to the bottom of the file:

<?php
echo '<pre>';
print_r($_SESSION);
?>

and check if sppc_customer_group_id is set and what the number is (retail is zero, all others 1 and higher).

 

 

I've added the code to my index.php file in the main store directory and it gave me this output.

 

Array
(
[cart] => shoppingcart Object
	(
		[contents] => Array
			(
			)

		[total] => 0
		[weight] => 0
		[cartID] => 
		[content_type] => 
	)

[language] => english
[languages_id] => 1
[currency] => USD
[navigation] => navigationhistory Object
	(
		[path] => Array
			(
				[0] => Array
					(
						

 => index.php
						[mode] => NONSSL
						[get] => Array
							(
							)

						[post] => Array
							(
							)

					)

			)

		[snapshot] => Array
			(
			)

	)

[customer_id] => 2
[customer_default_address_id] => 2
[customer_first_name] => Chris
[customer_country_id] => 223
[customer_zone_id] => 23
)

 

Being that SPPC is not being called at all, I assume that's why it's not showing up. I have all the files in the correct places, was I supposed to activate a module?

Link to comment
Share on other sites

I've added the code to my index.php file in the main store directory and it gave me this output.

 

Being that SPPC is not being called at all, I assume that's why it's not showing up. I have all the files in the correct places, was I supposed to activate a module?

None of the additional session values used by SPPC have been added. This is the task of login.php. Can you double check that file?

Link to comment
Share on other sites

When I click continue the url changes to: https://mystore.com/dev_shop/login.php/acti...ocess/skip/true and I see the same "Choose a customer group" window again.

 

I compared the login.php files but can't find the problem

The SEO contribution you use cannot handle the additional get parameter that is added to the url. See e.g. this post to circumvent that problem.
Link to comment
Share on other sites

None of the additional session values used by SPPC have been added. This is the task of login.php. Can you double check that file?

 

Hmm, well it works now. I reuploaded login.php, which I had uploaded the same file at least 3 times today, this time it worked. Whatever it was it worked, thanks a ton!

Link to comment
Share on other sites

Hi

does any one have a success to combine QTPro 4.3 and SPPC attributes mod rev. 1.

I have tried and faced the following issue:

everything went smoothly except one thing on product_info.php I need to change the blocks of code.

The first suggested change is within file product_info.php

 

**REPLACE**

$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "'");

**WITH**

// BOF SPPC Hide attributes from customer groups
$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 ");

 

But the second and third chandes are within file pad_base.php, basically the suggested changes can be made, they are not changed (significantly) by QTPro but when I just change them nothing works. No errors in standard view.

If I just replace my product_info.php with supplied in archive everything starts to work, except QTPro :( .

 

Does any one solved this?

 

Alexander

Link to comment
Share on other sites

Here is addition to my previous post:

 

in pad_base.php the function where the second and third changes (as per instructions) should be made looks the following way:

 

	function _build_attributes_array($build_stocked, $build_nonstocked) {
  global $languages_id;
  global $currencies;
  global $cart;

  if (!($build_stocked | $build_nonstocked)) return null;

  if ($build_stocked && $build_nonstocked) {
	$stocked_where='';
  }
  elseif ($build_stocked) {
	$stocked_where="and popt.products_options_track_stock = '1'";
  }
  elseif ($build_nonstocked) {
	$stocked_where="and popt.products_options_track_stock = '0'";
  }

  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' " . $stocked_where . " order by popt.products_options_name");
  $attributes=array();
  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
	$products_options_array = array();
	$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$this->products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "'");
	while ($products_options = tep_db_fetch_array($products_options_query)) {
	  $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
	  if ($products_options['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($this->products_tax_class_id)) .')';
	  }
	}
	if (isset($cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']]))
	  $selected = $cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']];
	else 
	  $selected = 0;
	$attributes[]=array('oid'=>$products_options_name['products_options_id'],
						'oname'=>$products_options_name['products_options_name'],
						'ovals'=>$products_options_array,
						'default'=>$selected);
  }
  return $attributes;
}

 

i changed it to the following:

 

	function _build_attributes_array($build_stocked, $build_nonstocked) {
  global $languages_id;
  global $currencies;
  global $cart;

  if (!($build_stocked | $build_nonstocked)) return null;

  if ($build_stocked && $build_nonstocked) {
	$stocked_where='';
  }
  elseif ($build_stocked) {
	$stocked_where="and popt.products_options_track_stock = '1'";
  }
  elseif ($build_nonstocked) {
	$stocked_where="and popt.products_options_track_stock = '0'";
  }


  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' " . $stocked_where . " and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
  $attributes=array();
  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
	$products_options_array = array();
	$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$this->products_id . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
	$list_of_prdcts_attributes_id = '';
	$products_options = array(); // makes sure this array is empty again
	while ($_products_options = tep_db_fetch_array($products_options_query)) {
	$products_options[] = $_products_options;
	$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
}

  if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') { 
	 $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
 $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
 while ($pag_array = tep_db_fetch_array($pag_query)) {
	 $cg_attr_prices[] = $pag_array;
 }

 // substitute options_values_price and prefix for those for the customer group (if available)
 if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
	for ($n = 0; $n < count($products_options); $n++) {
	 for ($i = 0; $i < count($cg_attr_prices); $i++) {
		 if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
			$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
			$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
		 }
	 } // end for ($i = 0; $i < count($cg_att_prices); $i++)
	}
	} // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
  } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')

  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 ($products_options[$n]['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}
// EOF SPPC attributes mod
	if (isset($cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']]))
	  $selected = $cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']];
	else 
	  $selected = 0;
	$attributes[]=array('oid'=>$products_options_name['products_options_id'],
						'oname'=>$products_options_name['products_options_name'],
						'ovals'=>$products_options_array,
						'default'=>$selected);
  }
  return $attributes;
}

 

Can any one help?

 

Alex

Link to comment
Share on other sites

The SEO contribution you use cannot handle the additional get parameter that is added to the url. See e.g. this post to circumvent that problem.

 

Thanks a lot. Login works now but unfortunately the prices do not change (the group selected for the user in the admin screen is used instead). Any idea where to look?

 

Thanks

Link to comment
Share on other sites

Here is addition to my previous post:

 

in pad_base.php the function where the second and third changes (as per instructions) should be made looks the following way:

 

	function _build_attributes_array($build_stocked, $build_nonstocked) {

Everything looks fine, but what is missing inside the function is the $customer_group_id.

 

What happens if you add this after your declaration of the globals inside the function:

// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
 $customer_group_id = $_SESSION['sppc_customer_group_id'];
 } else {
  $customer_group_id = '0';
 }

Link to comment
Share on other sites

Thanks a lot. Login works now but unfortunately the prices do not change (the group selected for the user in the admin screen is used instead). Any idea where to look?
Next are the complete instructions for login.php. Pehaps the stuff after line 81 is missing?

catalog/login.php _GET skip changed to _POST skip


Line 4

**AFTER**
 $Id: login.php,v 1.80 2003/06/05 23:28:24 hpdl Exp $

**ADD**
 adapted for Separate Price Per Customer v4.2 2006/06/25





Line 29

**REPLACE**
$check_customer_query = tep_db_query("select customers_id, customers_firstname, customers_password, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");





**WITH**
// BOF Separate Pricing per Customer
$check_customer_query = tep_db_query("select customers_id, customers_firstname, customers_group_id, customers_password, customers_email_address, customers_default_address_id from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");
// EOF Separate Pricing Per Customer






Line 44

**AFTER**
if (SESSION_RECREATE == 'True') {
	  tep_session_recreate();
	}





**ADD**
// BOF Separate Pricing Per Customer: choice for logging in under any customer_group_id
// note that tax rates depend on your registered address!
if ($_POST['skip'] != 'true' && $_POST['email_address'] == SPPC_TOGGLE_LOGIN_PASSWORD ) {
  $existing_customers_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id ");
echo '<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">';
print ("\n<html ");
echo HTML_PARAMS;
print (">\n<head>\n<title>Choose a Customer Group</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
echo CHARSET;
print ("\"\n<base href=\"");
echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG;
print ("\">\n<link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\">\n");
echo '<body bgcolor="#ffffff" style="margin:0">';
print ("\n<table border=\"0\" width=\"100%\" height=\"100%\">\n<tr>\n<td style=\"vertical-align: middle\" align=\"middle\">\n");
echo tep_draw_form('login', tep_href_link(FILENAME_LOGIN, 'action=process', 'SSL'));
print ("\n<table border=\"0\" bgcolor=\"#f1f9fe\" cellspacing=\"10\" style=\"border: 1px solid #7b9ebd;\">\n<tr>\n<td class=\"main\">\n");
 $index = 0;
 while ($existing_customers =  tep_db_fetch_array($existing_customers_query)) {
$existing_customers_array[] = array("id" => $existing_customers['customers_group_id'], "text" => " ".$existing_customers['customers_group_name']." ");
++$index;
 }
print ("<h1>Choose a Customer Group</h1>\n</td>\n</tr>\n<tr>\n<td align=\"center\">\n");
echo tep_draw_pull_down_menu('new_customers_group_id', $existing_customers_array, $check_customer['customers_group_id']);
print ("\n<tr>\n<td class=\"main\"> <br />\n ");
print ("<input type=\"hidden\" name=\"email_address\" value=\"".$_POST['email_address']."\">");
print ("<input type=\"hidden\" name=\"skip\" value=\"true\">");
print ("<input type=\"hidden\" name=\"password\" value=\"".$_POST['password']."\">\n</td>\n</tr>\n<tr>\n<td align=\"right\">\n");
echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE);
print ("</td>\n</tr>\n</table>\n</form>\n</td>\n</tr>\n</table>\n</body>\n</html>\n");
exit;
}
// EOF Separate Pricing Per Customer: choice for logging in under any customer_group_id



Line 81

**AFTER**
$customer_first_name = $check_customer['customers_firstname'];


**ADD**
// BOF Separate Pricing Per Customer
if ($_POST['skip'] == 'true' && $_POST['email_address'] == SPPC_TOGGLE_LOGIN_PASSWORD && isset($_POST['new_customers_group_id']))  {
  $sppc_customer_group_id = $_POST['new_customers_group_id'];
  $check_customer_group_tax = tep_db_query("select customers_group_show_tax, customers_group_tax_exempt, group_specific_taxes_exempt from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" .(int)$_POST['new_customers_group_id'] . "'");
} else {
  $sppc_customer_group_id = $check_customer['customers_group_id'];
  $customers_specific_taxes_exempt = $check_customer['customers_specific_taxes_exempt'];
  $check_customer_group_tax = tep_db_query("select customers_group_show_tax, customers_group_tax_exempt, group_specific_taxes_exempt from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" .(int)$check_customer['customers_group_id'] . "'");
}
$customer_group_tax = tep_db_fetch_array($check_customer_group_tax);
$sppc_customer_group_show_tax = (int)$customer_group_tax['customers_group_show_tax'];
$sppc_customer_group_tax_exempt = (int)$customer_group_tax['customers_group_tax_exempt'];
	$sppc_customer_group_tax_exempt = (int)$customer_group_tax['customers_group_tax_exempt'];
$group_specific_taxes_exempt = $customer_group_tax['group_specific_taxes_exempt'];
if (tep_not_null($customers_specific_taxes_exempt)) {
	$sppc_customer_specific_taxes_exempt = $customers_specific_taxes_exempt;
} elseif (tep_not_null($group_specific_taxes_exempt)) {
	$sppc_customer_specific_taxes_exempt = $group_specific_taxes_exempt;
} else {
	$sppc_customer_specific_taxes_exempt = '';
}
// EOF Separate Pricing Per Customer



Line 106-107

**AFTER**
tep_session_register('customer_default_address_id');
	tep_session_register('customer_first_name');


**ADD**
// BOF Separate Pricing per Customer
tep_session_register('sppc_customer_group_id');
tep_session_register('sppc_customer_group_show_tax');
tep_session_register('sppc_customer_group_tax_exempt');
if (tep_not_null($sppc_customer_specific_taxes_exempt)) {
	tep_session_register('sppc_customer_specific_taxes_exempt');
}
// EOF Separate Pricing per Customer

Link to comment
Share on other sites

Thanks a lot. Login works now but unfortunately the prices do not change (the group selected for the user in the admin screen is used instead). Any idea where to look?

Ignore the previous post, it contains bits and pieces that are not in this version yet. I was editing when I got a message I couldn't edit it anymore....

 

The intended answer was:

 

A little further on there was also a part where a $_GET was used that need to be changed to a $_POST (first line of this bit):

	// BOF Separate Pricing per Customer
if ($_GET['skip'] == 'true' && $_POST['email_address'] == SPPC_TOGGLE_LOGIN_PASSWORD && isset($_POST['new_customers_group_id']))  {
$sppc_customer_group_id = $_POST['new_customers_group_id'];
$check_customer_group_tax = tep_db_query("select customers_group_show_tax, customers_group_tax_exempt from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '" .(int)$_POST['new_customers_group_id'] . "'");

Link to comment
Share on other sites

Everything looks fine, but what is missing inside the function is the $customer_group_id.

 

What happens if you add this after your declaration of the globals inside the function:

// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

  if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
  $customer_group_id = $_SESSION['sppc_customer_group_id'];
  } else {
$customer_group_id = '0';
  }

 

Yes it worked, I really forgot to call $customer_group_id

 

Thanks a lot

 

Alex

Link to comment
Share on other sites

Ignore the previous post, it contains bits and pieces that are not in this version yet. I was editing when I got a message I couldn't edit it anymore....

 

The intended answer was:

 

A little further on there was also a part where a $_GET was used that need to be changed to a $_POST (first line of this bit):

 

Thanks a million for your great support !! It works now :lol: !!

Link to comment
Share on other sites

I have installed version 4.1.5 with SPPC attribute mod

Everything runs well.

But when I selected a category as a customer in the "index.php" page, I got an error.

It said that " Table 'osc_test_c.specials_retail_prices' doesn't exist ".

Could anyone help me?

Many many thanks

Everyone is changing the world.

Everyone is a world.

For everyone needs my help, PM or email if I amn't online.

Link to comment
Share on other sites

Well - I'm confused. My "New Products" page seems to want show the products in duplicate or triplicate even :huh:

 

I did change the query for Master Products (products_master_status = 1) which is working correctly in the sense that only the master products are coming up - but they are coming up multiple times (same product_id number) and I have no idea why? It doesn't seem to be all of the products either - some are listed once, some twice, some three times! I can't seem to find any reason for it :blink:

 

Anybody have any thoughts?

 

You can see it here:

http://mmherbs.dreamhosters.com/products_new.php

 

This is the section of code that affects the listing:

<?php
 $products_new_array = array();
//Products_master AND Separate Price Per Customer, hide products and categories from groups BOF
if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }

 $products_new_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_master, p.products_master_status, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c using(products_id) left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_master_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_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 order by p.products_date_added DESC, pd.products_name";
//Products_master and Separate Price Per Customer, hide products and categories from groups EOF
 $products_new_split = new splitPageResults($products_new_query_raw, MAX_DISPLAY_PRODUCTS_NEW);

 if (($products_new_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="smallText"><?php echo $products_new_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS_NEW); ?></td>
		<td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $products_new_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 }
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
 if ($products_new_split->number_of_rows > 0) {
// BOF Separate Price Per Customer
//  global variable (session): $sppc_customers_group_id -> local variable $customer_group_id

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

$products_new_query = tep_db_query($products_new_split->sql_query);
$no_of_products_new = tep_db_num_rows($products_new_query);
while ($_products_new = tep_db_fetch_array($products_new_query)) {
  $products_new[] = $_products_new;
$list_of_prdct_ids[] = $_products_new['products_id'];  
}

 $select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
  if ($no_of_products_new > 1) {
  for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";   
  }
  }

// get all customers_group_prices for products with the particular customer_group_id
// however not necessary for customer_group_id
if ($customer_group_id != '0') {
 $pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."'");
while ($pg_array = tep_db_fetch_array($pg_query)) {
$new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '');
}

  for ($x = 0; $x < $no_of_products_new; $x++) {
// replace products prices with those from customers_group table
// originally they would be obtained with an extra query for every new product:
//   if ($new_price = tep_get_products_special_price($products_new['products_id'])) {

	if(!empty($new_prices)) {
	for ($i = 0; $i < count($new_prices); $i++) {
		if( $products_new[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
		$products_new[$x]['products_price'] = $new_prices[$i]['products_price'];
		}
	}
} // end if(!empty($new_prices)
  } // end for ($x = 0; $x < $no_of_products_new; $x++)
} // end if ($customer_group_id != '0')

// an extra query is needed for all the specials

$specials_query = tep_db_query("select s.products_id, specials_new_products_price from " . TABLE_SPECIALS . " s  where (".$select_list_of_prdct_ids.") and status = '1' and s.customers_group_id = '" .$customer_group_id. "'");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price']);
}

// replace specials_new_products_price with those those for the customers_group_id
for ($x = 0; $x < $no_of_products_new; $x++) {

	if(!empty($new_prices)) {
	for ($i = 0; $i < count($new_prices); $i++) {
		if( $products_new[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
		$products_new[$x]['specials_new_products_price'] = $new_prices[$i]['specials_new_products_price'];
		}
	   }
   } // end if(!empty($new_prices)
//	} // end for ($x = 0; $x < $no_of_products_new; $x++)

if (tep_not_null($products_new[$x]['specials_new_products_price'])) {
		$products_price = '<s>' . $currencies->display_price($products_new[$x]['products_price'], tep_get_tax_rate($products_new[$x]['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($products_new[$x]['specials_new_products_price'], tep_get_tax_rate($products_new[$x]['products_tax_class_id'])) . '</span>';
} else {
	$products_price = $currencies->display_price($products_new[$x]['products_price'], tep_get_tax_rate($products_new[$x]['products_tax_class_id']));
}
?>
	  <tr>
		<td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $products_new[$x]['products_image'], $products_new[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>
		<td valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products_new[$x]['products_id']) . '"><b><u>' . $products_new[$x]['products_name'] . '</u></b></a><br>' . TEXT_DATE_ADDED . ' ' . tep_date_long($products_new[$x]['products_date_added']); ?></td>
		<!--Master Products //-->		   
<?php if ($products_new['products_master'] != '0') {
?>
		<td align="right" valign="middle" class="main"> </td>
<?php
}
?>			
<!--Master Products EOF //--> 
	  </tr>
	  <tr>
		<td colspan="3"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
	  </tr>
<?php // EOF Separate Pricing Per Customer
  } // end for ($x = 0; $x < $products_new_split->number_of_rows; $x++)
}  else { 
?>
	  <tr>
		<td class="main"><?php echo TEXT_NO_NEW_PRODUCTS; ?></td>

 

Any thoughts?

~Tracy
 

Link to comment
Share on other sites

Well - I'm confused. My "New Products" page seems to want show the products in duplicate or triplicate even
Perhaps those products are in more than one category?

 

Try:

  $products_new_query_raw = "select distinct p.products_id, pd.products_name, p.products_image, p.products_price, p.products_master, p.products_master_status, etcetera

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