Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Hmm I seem to be doing ok on the product listing, everything seems to work as it should. My only problem now is wot the heck do I do with this little beauty

Still, not much to change. This part is the relevant part that needs to be replaced.

if (tep_not_null($listing[$x]['specials_new_products_price'])) {
$lc_text .= '<br><span class="stockStatus">Regular Price?' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '<br><font color="#ff0000"><b>Special Offer Price?<span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span>?</b></font>?<br>';
} else {
$lc_text .= '<br><span class="stockStatus">Our Price?' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '?</b></span>?<br>';
}

That needs to be replaced by (beware of the dot in your case): $pf->parse($listing[$x]);

$lc_text .= $pf->getPriceStringShort();

 

Normally, a price break in product_listing.php is displayed as $ 3.33 - $ 4.45 (lowest price dash highest price).

 

I would suggest copying the function getPriceStringShort() and rename it to something else, say getPriceStringMCShort. Make it display the way you want your prices to be shown and then call the new function with $pf->getPriceStringMCShort();.

 

That way you will be safe in case this function is called somewhere else and needs to stay this way.

Link to comment
Share on other sites

Elisa,

You must have made a mistake when merging these two files. I was rather sceptical about this contribution at first, but the default file worked like a charm. That encouraged me to merged the customer add file with the customers.php from sppc myself and it does not really work flawlessly (when inserting a new customer the shipping and payment options cannot be set) but I don't get that kind of errors at all. Everything gets inserted fine in the database.

 

 

Hello JanZ,

 

Thanks for the reply!

 

I already tried to start from zero 3 times.... do you think you can help me? If I send you my original customers file?

 

Thanks a lot,

Elisa

Link to comment
Share on other sites

No... I haven't altered the code at all. Actualy, I wouldn't know what to change. My coding skills are very limited but I follow instuctions very well. I've searched in this thread for some ideas but I didn't find anything. Could you point me in the right direction? I'll keep searching the rest of the forum for clues.

 

Any help is greatly appriciated.

 

Thanks!

Shayne

Hi There!

I've got exactly the same problem with SPPC and autologon myself.

It' been a month since your call for help, have you found a way to make it work?

If not, at least you know you're not alone...

// Micke

Link to comment
Share on other sites

i just added 4.1 to myu so hacked os.. ms2.2.. but from a teplate... as seen on ftacatalog.com

 

as you see.. the specials is showing nothing and i PUSHED the fiel directly from the package.. all other works..

 

 

so #1 .. anyone special show nada...

 

#2 admin shows on special...

 

is it missing the if is set thingy ?

Link to comment
Share on other sites

i just added 4.1 to myu so hacked os.. ms2.2.. but from a teplate... as seen on ftacatalog.com

 

as you see.. the specials is showing nothing and i PUSHED the fiel directly from the package.. all other works..

so #1 .. anyone special show nada...

 

#2 admin shows on special...

 

is it missing the if is set thingy ?

 

ok i found out...

 

I i login as wholesale.. i wont see special...

 

if i login as retail ill see ...

 

now.. aint i suppoed to see anyhow ?

Link to comment
Share on other sites

ok i found out...

 

I i login as wholesale.. i wont see special...

 

if i login as retail ill see ...

 

now.. aint i suppoed to see anyhow ?

 

Frank,

 

When you are on the admin Panel, check your special, you have to set the special for each group, you have surely just make a special for one group, check this out... :thumbsup:

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

Frank,

 

When you are on the admin Panel, check your special, you have to set the special for each group, you have surely just make a special for one group, check this out... :thumbsup:

 

you are so right.. is it from a vanilla ms2 your contribs ? or a home made site ?

 

whats url im curious.

 

 

im at ftacatalog.com

Link to comment
Share on other sites

you are so right.. is it from a vanilla ms2 your contribs ? or a home made site ?

 

whats url im curious.

im at ftacatalog.com

 

My web site is for just baby 3 years old and less. :blush:

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

Regarding the following:

 

Group 1 are to get 5% discount shown to them

Group 2 also get 5% but are sourced by a different criteria

Group 3 are memberes of both grp 1&2, therfore get a combined discount of 10%

 

In relation to your post a few pages back running this mysql patch will fix this??

--------------------------------------------------------------------------------------------------------------

insert into products_groups select '1' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p;

 

insert into products_groups select '2' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p;

 

insert into products_groups select '3' as customers_group_id, (0.9 * p.products_price) as customers_group_price, p.products_id from products p;

 

I would like to set this up but have a couple of questions. Will it show a % savings at order checkout? and what exactly do i need to edit? i have 3 price groups set up (SPPC) and they are all filled with pricing. I do not want to loose any existing data. and if there is achance of that (besides the obvious chance) please let me know.

 

Greatly appreciate any help Site going live this week end.

What would you do if you knew you could not fail?

Link to comment
Share on other sites

Shayne. I have both autologin and SPPC insalled on one of my stores (www.blackwidowsecurity.com/store/) with no problems (that I know of). To me, after reading what you said it sounds that this is being caused by a page be cached, but I could be wrong. Do you happen to have a page cache contribution installed? If so, try to turn it off and then repeat the steps which were giving you problems before.

 

Good Luck,

 

Nate

Regarding SPPC and Autologon

Obviously we have to make the same SPPC changes in the autologon routine as the ones we did in the login.php.

Here' the changes I made in "includes/modules/autologon.php",

Cut and paste, Shayne. It work like a charm!:

 

<?php

/*

$Id: autologon.php,v 1.11 2003/01/18 20:00:00 Exp $

Adapted for Separate Pricing per Customer 2006/03/03 11:05:00 by Micke

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

Copyright © 2003 HMCservices

Released under the GNU General Public License

*/

$cookie_url_array = parse_url((ENABLE_SSL == true ? HTTPS_SERVER : HTTP_SERVER) . substr(DIR_WS_CATALOG, 0, -1));

$cookie_path = $cookie_url_array['path'];

 

if (($email_address != "") && ($password != "")) {

// BOF Separate Pricing per Customer

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

$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

if (tep_db_num_rows($check_customer_query)) {

$check_customer = tep_db_fetch_array($check_customer_query);

if (tep_validate_password($password, $check_customer['customers_password'])) {

if (SESSION_RECREATE == 'True') {

tep_session_recreate();

}

$check_country_query = tep_db_query("select entry_country_id, entry_zone_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . $check_customer['customers_id'] . "' and address_book_id = '" . (int)$check_customer['customers_default_address_id'] . "'");

$check_country = tep_db_fetch_array($check_country_query);

 

$customer_id = $check_customer['customers_id'];

$customer_default_address_id = $check_customer['customers_default_address_id'];

$customer_first_name = $check_customer['customers_firstname'];

// 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'] . "'");

} else {

$sppc_customer_group_id = $check_customer['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)$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'];

// EOF Separate Pricing per Customer

$customer_country_id = $check_country['entry_country_id'];

$customer_zone_id = $check_country['entry_zone_id'];

if(!tep_session_is_registered('customer_id'))

tep_session_register('customer_id');

if(!tep_session_is_registered('customer_default_address_id'))

tep_session_register('customer_default_address_id');

if(!tep_session_is_registered('customer_first_name'))

tep_session_register('customer_first_name');

// BOF Separate Pricing per Customer

if(!tep_session_is_registered('sppc_customer_group_id'))

tep_session_register('sppc_customer_group_id');

if(!tep_session_is_registered('sppc_customer_group_show_tax'))

tep_session_register('sppc_customer_group_show_tax');

if(!tep_session_is_registered('sppc_customer_group_tax_exempt'))

tep_session_register('sppc_customer_group_tax_exempt');

// EOF Separate Pricing per Customer

if(!tep_session_is_registered('customer_country_id'))

tep_session_register('customer_country_id');

if(!tep_session_is_registered('customer_zone_id'))

tep_session_register('customer_zone_id');

 

setcookie('email_address', $email_address, time()+ (365 * 24 * 3600), $cookie_path, '', ((getenv('HTTPS') == 'on') ? 1 : 0));

setcookie('password', $check_customer['customers_password'], time()+ (365 * 24 * 3600), $cookie_path, '', ((getenv('HTTPS') == 'on') ? 1 : 0));

$date_now = date('Y-m-d');

$qr = "update " . TABLE_CUSTOMERS_INFO . " set customers_info_date_of_last_logon = now(), customers_info_number_of_logons = customers_info_number_of_logons+1 where customers_info_id = '" . $customer_id . "'";

tep_db_query($qr);

$cart->restore_contents(); // restore cart contents

}

}

} else {

if($autologon_executed != 'true'){

$autologon_page = '<html><head><meta http-equiv="Refresh" content="0;URL=' . tep_href_link(FILENAME_LOGOFF, '', 'SSL') . '"></head><body></body></html>';

$autologon_link = ((getenv('HTTPS') == 'on') ? 'https://' : 'http://') . $SERVER_NAME . $REQUEST_URI . (strpos($REQUEST_URI, "?") ? '&' : '?') . SID;

$autologon_executed = 'true';

if(!tep_session_is_registered('autologon_link'))

tep_session_register('autologon_link');

if(!tep_session_is_registered('autologon_executed'))

tep_session_register('autologon_executed');

tep_session_close();

exit($autologon_page);

}

}

if (tep_session_is_registered('autologon_link')) {

$x = $autologon_link;

tep_session_unregister('autologon_link');

tep_redirect($x);

}

?>

Link to comment
Share on other sites

Hi Jan,

 

I eventually got the price breaks to work correctly :D

 

I did away with showing the price breaks in the product listing and put them in the product info instead. Thanks

 

I am now on with changing the default_specials contrib to work with sppc and I am using the new_products module as a guide. The module works fine and throws no errors, it just does not seem to recognise the groups and it displays the trade special price for the retail group.

 

Any chance of double checking the code for me please?

 

if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
// BOF Separate Pricing per Customer
$default_specials_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' order by s.specials_date_added DESC limit " . MAX_DISPLAY_SPECIAL_PRODUCTS);
 } else {
$default_specials_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' order by s.specials_date_added DESC limit ". MAX_DISPLAY_SPECIAL_PRODUCTS);
 }

// global variable (session) $sppc_customer_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;
 }

 if (($no_of_new_products = tep_db_num_rows($default_specials_query)) > 0) {
  while ($_new_products = tep_db_fetch_array($default_specials_query)) {
$default_specials[] = $_new_products;
$list_of_prdct_ids[] = $_new_products['products_id'];
}
}
$select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_new_products > 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 = 0
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)) {
$default_specials[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '');
}

  for ($x = 0; $x < $no_of_new_products; $x++) {
// replace products prices with those from customers_group table
	if(!empty($default_specials)) {
	for ($i = 0; $i < count($default_specials); $i++) {
		if( $default_specials[$x]['products_id'] == $default_specials[$i]['products_id'] ) {
		$default_specials[$x]['products_price'] = $default_specials[$i]['products_price'];
		}
	}
} // end if(!empty($default_specials)
  } // 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 products_id, specials_new_products_price from specials where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "' ");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
}

// replace products_price with the correct specials_new_products_price
if(!empty($new_s_prices)) {
for ($x = 0; $x < $no_of_new_products; $x++) {
	for ($i = 0; $i < count($new_s_prices); $i++) {
		if( $default_specials[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
		$default_specials[$x]['products_price'] = $new_s_prices[$i]['specials_new_products_price'];
		}
	   }
   }
} // // end if(!empty($new_s_prices)



//		$info_box_contents = array();
	$row = 0;
	$nextrow = 1;
	$nextnextrow = 2;
	$col = 0;
	$num = 0;


//  while ($default_specials = tep_db_fetch_array($default_specials_query)) {
for ($x = 0; $x < $no_of_new_products; $x++) {
$default_specials[$x]['products_name'] = tep_get_products_name($default_specials[$x]['products_id']);

		$num ++;
		if ($num == 1) { new contentBoxStoreHeaderM($info_box_contents); }

 

Thanks Again

 

Mark

Lifes a bitch, then you marry one, then you die!

Link to comment
Share on other sites

Sorry I missed a couple of bits out of the query.

 

It should read

 

  $default_specials_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit " . MAX_DISPLAY_SPECIAL_PRODUCTS);
 } else {
$default_specials_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit ". MAX_DISPLAY_SPECIAL_PRODUCTS);
 }

 

All the rest is unchanged and still shows trade special price in the retail group.

 

Mark

Lifes a bitch, then you marry one, then you die!

Link to comment
Share on other sites

Will it show a % savings at order checkout? and what exactly do i need to edit? i have 3 price groups set up (SPPC) and they are all filled with pricing. I do not want to loose any existing data. and if there is achance of that (besides the obvious chance) please let me know.
No, it won't show a % savings at order checkout. What you are referring to are instructions to fill the table products_groups in a small number of sql queries when you have a fixed discount rate. Nothing else. So if you already filled your prices, this is no use to you.
Link to comment
Share on other sites

Stew,

I have made a big mistake in the Best Sellers Content Box for SPPC with Hide Products (http://www.oscommerce.com/community/contributions,3687).

 

When viewing the best sellers box when a wholesale customer is logged in, the correct products are displayed but with the wrong prices.

This appears to work OK. I kind of added stuff in the whole file, so here is it is in total:

<?php
/*
 Id: best_sellers.php,v 1.0 2002/11/22

 Written by Tony Alanis [email protected]
 modified for hide products from groups for SPPC 
 (modification of a contribution in order to work  with a modifiication for a contribution)- by djmonkey1 2006/03/03

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

 Copyright (c) 2002 osCommerce

 Released under the GNU General Public License
*/
?>
<!-- best_sellers //-->
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('align' => 'left', 'text' => sprintf(TABLE_HEADING_BEST_SELLERS, strftime('%B')));
 new contentBoxHeading($info_box_contents);

// BOF Hide products from groups

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

 if (isset($current_category_id) && ($current_category_id > 0)) {
$best_sellers_query = tep_db_query("select distinct p.products_id, pd.products_name, p.products_image, pd.products_description, p.products_tax_class_id, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd using(products_id) left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c using(products_id), " . TABLE_CATEGORIES . " c where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = c.categories_id and '" . (int)$current_category_id . "' in (c.categories_id, c.parent_id) and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS); 
 } else {
$best_sellers_query = tep_db_query("select distinct p.products_id, pd.products_name, p.products_image, pd.products_description, p.products_tax_class_id, p.products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd using(products_id) where p.products_status = '1' and p.products_ordered > 0 and pd.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
 }
// EOF Hide products from groups

 while ($_best_sellers = tep_db_fetch_array($best_sellers_query)) {
  $best_sellers[] = $_best_sellers; // store information about the products in the array $best_sellers
$list_of_prdct_ids[] = $_best_sellers['products_id'];
} 
$no_of_best_sellers = count($best_sellers);

$select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_best_sellers > 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 = 0
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_best_sellers; $x++) {
// replace products prices with those from customers_group table
	if(!empty($new_prices)) {
	for ($i = 0; $i < count($new_prices); $i++) {
		if( $best_sellers[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
		$best_sellers[$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 products_id, specials_new_products_price from specials where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "' ");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
}

// replace products_price with the correct specials_new_products_price
if(!empty($new_s_prices)) {
for ($x = 0; $x < $no_of_best_sellers; $x++) {
	for ($i = 0; $i < count($new_s_prices); $i++) {
		if( $best_sellers[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
		$best_sellers[$x]['products_price'] = $new_s_prices[$i]['specials_new_products_price'];
		}
	   }
   }
} // // end if(!empty($new_s_prices)

$info_box_contents = array();
 $row = 0;
 $col = 0;
//  while ($best_sellers = tep_db_fetch_array($best_sellers_query)) {
for ($x = 0; $x < $no_of_best_sellers; $x++) {
$best_sellers['products_name'] = tep_get_products_name($best_sellers['products_id']);
$info_box_contents[$row][$col] = array('align' => 'center',
									   'params' => 'class="smallText" width="33%" valign="top"',
									   'text' => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $best_sellers[$x]['products_image'], $best_sellers[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers[$x]['products_id']) . '">' . $best_sellers[$x]['products_name'] . '</a><br>' . $currencies->display_price($best_sellers[$x]['products_price'], tep_get_tax_rate($best_sellers[$x]['products_tax_class_id'])));
$col ++;
if ($col > 2) {
  $col = 0;
  $row ++;
}
 }
 new contentBox($info_box_contents);
?>
<!-- best_sellers_eof //-->

Link to comment
Share on other sites

Mark,

Sorry I missed a couple of bits out of the query.
I haven't tested this code, but this is the general idea IMHO:

// global variable (session) $sppc_customer_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;
}

// since you are specifically looking for specials, customer groups should be accounted for in the queries here
// weak point: no mention of languages_id, will give problems in a multi-language store
$default_specials_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' and s.customers_group_id = '" . $customer_group_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit " . MAX_DISPLAY_SPECIAL_PRODUCTS);
} else {
$default_specials_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and s.customers_group_id = '" . $customer_group_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit ". MAX_DISPLAY_SPECIAL_PRODUCTS);
}

$no_of_default_specials = tep_db_num_rows($default_specials_query;

if ($no_of_default_specials > 0) {
while ($_default_specials = tep_db_fetch_array($default_specials_query)) {
$default_specials[] = $_default_specials;
$list_of_prdct_ids[] = $_default_specials['products_id'];
}
}
$select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
if ($no_of_default_specials > 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 = 0
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']);
}

for ($x = 0; $x < $no_of_default_specials; $x++) {
// replace products prices with those from customers_group table
if(!empty($new_prices)) {
for ($i = 0; $i < count($new_prices); $i++) {
if( $default_specials[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
$default_specials[$x]['products_price'] = $new_prices[$i]['products_price'];
}
}
} // end if(!empty($new_prices)
} // end for ($x = 0; $x < $no_of_default_specials; $x++)
} // end if ($customer_group_id != '0')

// no extra query is needed for all the specials

// $info_box_contents = array();
$row = 0;
$nextrow = 1;
$nextnextrow = 2;
$col = 0;
$num = 0;


// while ($default_specials = tep_db_fetch_array($default_specials_query)) {
for ($x = 0; $x < $no_of_default_specials; $x++) {
// no need for this, products_name is picked up in the query
// $default_specials[$x]['products_name'] = tep_get_products_name($default_specials[$x]['products_id']);

$num ++;
if ($num == 1) { new contentBoxStoreHeaderM($info_box_contents); }

Link to comment
Share on other sites

No, it won't show a % savings at order checkout. What you are referring to are instructions to fill the table products_groups in a small number of sql queries when you have a fixed discount rate. Nothing else. So if you already filled your prices, this is no use to you.

 

Does anyone know if Easypopulate will works if you are using SPPC, Hide prices.., Price breaks.., Show price list, and specials by category installed? I have many other mods as well but the SPPC mods have some heavy hacking involved that I don't want to break.

 

I guess I am finding out that the order in which you add you mods will become extremely important as you add more and more. I should have added EP before adding all the incredibly useful SPPC suite mods!!!

 

Any help would be greatly appreciated!

Link to comment
Share on other sites

Hi Jan,

 

Thankyou for having a go at it.

 

I had to add this back in front of the query

 

 if (isset($current_category_id) && ($current_category_id > 0)) {

 

Is this correct?

 

Also it throws up this error:

 

1109 - Unknown table 's' in where clause

 

select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from products p, products_to_categories p2c, categories c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '0' and p.products_status = '1' and s.customers_group_id = '0' and find_in_set('0', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit 6

 

[TEP STOP]

 

Any ideas?

 

$default_specials_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' and s.customers_group_id = '" . $customer_group_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit " . MAX_DISPLAY_SPECIAL_PRODUCTS);
} else {
$default_specials_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price as products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and s.customers_group_id = '" . $customer_group_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit ". MAX_DISPLAY_SPECIAL_PRODUCTS);
}

 

Thanks

 

Mark

Lifes a bitch, then you marry one, then you die!

Link to comment
Share on other sites

 if (isset($current_category_id) && ($current_category_id > 0)) {

 

Is this correct?

Think so yes. Don't forget the closing brace "}"

 

Try this:

$default_specials_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' and s.customers_group_id = '" . $customer_group_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit " . MAX_DISPLAY_SPECIAL_PRODUCTS);
} else {
$default_specials_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price, s.specials_new_products_price from " . TABLE_PRODUCTS . " p left join  " . TABLE_SPECIALS . " s using(products_id) , " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and s.customers_group_id = '" . $customer_group_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit ". MAX_DISPLAY_SPECIAL_PRODUCTS);
}

Link to comment
Share on other sites

Hi Jan,

 

Sorry to be a PITA!

 

There are no errors now but the product name does not show and also it is displaying products that have been disabled (red dot) as well as enabled (green dot).

 

Thanks

 

Mark

Lifes a bitch, then you marry one, then you die!

Link to comment
Share on other sites

There are no errors now but the product name does not show and also it is displaying products that have been disabled (red dot) as well as enabled (green dot).
Well, at least there is progress :)

 

What about this (additionally rewrote the second query to be one big left join):

$default_specials_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd using(products_id), " . TABLE_SPECIALS . " s where p.products_status = '1' and s.products_id = p.products_id and pd.language_id = '" . $languages_id . "' and s.status = '1' and s.customers_group_id = '" . $customer_group_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit " . MAX_DISPLAY_SPECIAL_PRODUCTS);
} else {
$default_specials_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name, s.specials_new_products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s using(products_id) left join " . TABLE_PRODUCTS_DESCRIPTION . " pd using(products_id) left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c using(products_id) left join " . TABLE_CATEGORIES . " c using(categories_id) where  c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and s.status = '1' and s.customers_group_id = '" . $customer_group_id . "' and pd.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', products_hide_from_groups) = 0 order by s.specials_date_added DESC limit ". MAX_DISPLAY_SPECIAL_PRODUCTS);
}

Link to comment
Share on other sites

Hi Jan,

 

Thanks that did the trick! I am now going to try and apply the same to the featured products contribution.

 

I have just noticed that my buy now button does not work correctly when logged in as a group id 1 customer, it is the code from the qty price breaks for sppc. It wont add to cart single or multiple qty's.

 

	} elseif ($_SESSION['sppc_customer_group_id'] == '0' || !isset($_SESSION['sppc_customer_group_id'])) {

?>
	<form name="cart_quantity" method="post" action="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL'); ?>">
		<td align="left" class="main"><input type="hidden" name="products_id" value="<?php echo $product_info_values['products_id']; ?>"><?php echo tep_image_submita('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

<?php } elseif ($_SESSION['sppc_customer_group_id'] == '1' || !isset($_SESSION['sppc_customer_group_id'])) { ?>

			 <td class="main" align="left">
			  <table border="0" align="left">
				<tr><td align="center" class="main">
				  <?php echo TEXT_ENTER_QUANTITY . ":" . tep_draw_input_field('cart_quantity', $pf->adjustQty(1), 'size="3"'); ?>
				</td></tr>
				<tr><td align="center">
				  <?php echo tep_draw_hidden_field('products_id', $product_info_values['products_id']) . tep_image_submita('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?>
				</td></tr>
			  </table>
			</td> <!-- EOF price-break-1.11.3 -->
<?php
}

?>
	  </tr>

 

And also I use the contrib that allows me to select free shipping on individual products and what I need is theis code modding so that it only shows for retail (group 0) customers.

 

<?php
if ($product_info_values['products_free_shipping'] && FREE_SHIPPING_TO_ALL_COUNTRIES == "true") {
 echo ('<tr><td align="left" class="smallText"><b>'.FREE_SHIPPING_FOR_THIS_PRODUCT.'</b></td></tr>');
}
if ($product_info_values['products_free_shipping'] && FREE_SHIPPING_TO_ALL_COUNTRIES == "false") {
 echo ('<tr><td align="left" class="smallText"><b>'.FREE_SHIPPING_FOR_THIS_PRODUCT_FOR_SHOP_COUNTRY.'</b></td></tr>');
}
?>

 

I know I keep monopolising your time but my store is so heavily modded its unbelievable.

 

Any ideas?

 

Thanks

 

Mark

Lifes a bitch, then you marry one, then you die!

Link to comment
Share on other sites

Stew,

This appears to work OK. I kind of added stuff in the whole file, so here is it is in total:

 

That's awesome! Thanks Jan!

Do, or do not. There is no try.

 

Order Editor 5.0.6 "Ultra Violet" is now available!

For support or to post comments, suggestions, etc, please visit the Order Editor support thread.

Link to comment
Share on other sites

Hello,

I installed sppc to get the following: When a customer registers from Germany, he should be automatic member of the sppc_group "german" - equall with England, France ...

 

I tried the last few days different coding, but whatever i do, a new customer appears first in the Retail Group.

Has anybody any idea, how to modify the create_account file?

 

Thx Thomas

Link to comment
Share on other sites

Mark,

I have just noticed that my buy now button does not work correctly when logged in as a group id 1 customer, it is the code from the qty price breaks for sppc. It wont add to cart single or multiple qty's.
That is purely a HTML matter: you don't have the form tag etc. when the customer is not retail. You just need to add that:

 

	} elseif ($_SESSION['sppc_customer_group_id'] == '0' || !isset($_SESSION['sppc_customer_group_id'])) {

?>
	<form name="cart_quantity" method="post" action="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL'); ?>">
		<td align="left" class="main"><input type="hidden" name="products_id" value="<?php echo $product_info_values['products_id']; ?>"><?php echo tep_image_submita('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></td>

<?php } elseif ($_SESSION['sppc_customer_group_id'] == '1' || !isset($_SESSION['sppc_customer_group_id'])) { ?>

	<form name="cart_quantity" method="post" action="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL'); ?>">
			 <td class="main" align="left">
			  <table border="0" align="left">
				<tr><td align="center" class="main">
				  <?php echo TEXT_ENTER_QUANTITY . ":" . tep_draw_input_field('cart_quantity', $pf->adjustQty(1), 'size="3"'); ?>
				</td></tr>
				<tr><td align="center">
				  <?php echo tep_draw_hidden_field('products_id', $product_info_values['products_id']) . tep_image_submita('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?>
				</td></tr>
			  </table>
			</td> <!-- EOF price-break-1.11.3 -->
<?php
}

?>
	  </tr>

 

And also I use the contrib that allows me to select free shipping on individual products and what I need is theis code modding so that it only shows for retail (group 0) customers.

Provided there is the if else customer_group_id = $sppc_customers_group id above that (likely, seen the context) just add another && with that condition:

<?php
if ($product_info_values['products_free_shipping'] && FREE_SHIPPING_TO_ALL_COUNTRIES == "true" && customer_group_id == '0' ) {
 echo ('<tr><td align="left" class="smallText"><b>'.FREE_SHIPPING_FOR_THIS_PRODUCT.'</b></td></tr>');
}
if ($product_info_values['products_free_shipping'] && FREE_SHIPPING_TO_ALL_COUNTRIES == "false" && customer_group_id == '0' ) {
 echo ('<tr><td align="left" class="smallText"><b>'.FREE_SHIPPING_FOR_THIS_PRODUCT_FOR_SHOP_COUNTRY.'</b></td></tr>');
}
?>

Link to comment
Share on other sites

Thomas,

I installed sppc to get the following: When a customer registers from Germany, he should be automatic member of the sppc_group "german" - equall with England, France ...

 

I tried the last few days different coding, but whatever i do, a new customer appears first in the Retail Group.

Has anybody any idea, how to modify the create_account file?

Actually, this has been discussed and code generally laid out in this topic (months and months ago though). The customer_group_id is not set in the create_account_file, the "0" for retail is the default value in the database.

 

So the only thing you need to do is add customer_group_id to the sql array that is inserted in the database (with all the other fields) after you have decided what it should be depending on what they choose (in a drop-down menu for example) or their IP-address or whatever you choose.

 

The building of the sql_data_array is done in the first 222 lines or so of that page. You can see the sppc specific ones because they are marked with BOF and EOF.

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