Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Hi Tracy, thanks for your reply.

 

We want all customers to have access to see order status and history, so everyone needs an account. We basically want two groups - members and non-members, (members will be able to purchase items at a reduced price). We also wish to charge overseas customers more for postage, but i think this is already possible with the standard OSC (no contrib required).

 

Ok - yes SPPC will allow you to do this. We used a combination of Table Rate and USPS shipping depending on what Country the customer was in - so yes you can setup your postage to be different for different Countries. The hard part is remembering that you create your shipping zones in Admin -> Locations/Taxes -> Tax Zones :blush:

 

There is another complication which i think i will just have to learn to program... when customers create an account the default group should be non-member. Anyone joining by post (ie by cheque), we will add their details manually and set their group to be member.

 

This is how SPPC works by default - you have to manually go in and change a members status to a different group. :thumbsup:

 

Also, if someone creates an account online and buys membership (a product), their group should be changed to member. (we may also want to have overseas members as another group). Also, if someone adds a membership product to their cart, is it possible to then change the pricing of any of the other products in the cart to the prices for the members group?

 

This will require some extra programming (I think) and JanZ would be the best one to respond to these particular questions :blush:

 

Infact, would there be a way to restrict buying of a product according to location of customer based on country?

 

Thanks for helping!

James

 

You could create separate Customer Groups for different Countries. Then you could add the Hide Products and Categories for SPPC contribution which would allow you to choose to hide a product or an entire category from specific Customer Groups so they can't purchase that item :thumbsup:

~Tracy
 

Link to comment
Share on other sites

Might be the easiest to just use tep_get_products_special_price as a template and add a new one to includes/functions/general.php:

function tep_get_products_special_retail_price($product_id) {
	$product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status and customers_group_id = '0'");
$product = tep_db_fetch_array($product_query);

return $product['specials_new_products_price'];
 }

Call that to get the special price (if there is any) for retail.

 

Never looked at that but classes/order_total.php seems to follow the exact same pattern as the classes shipping and payment in respect to loading the modules so I don't see why that shouldn't be possible.

Quite impossible. You can do a search in the topic itself, but I don't remember this question ever been asked before so it wouldn't have helped I suppose.

 

I was able to add the ability to assign Order Total Modules to Customer Groups. When I have some time, I'll go back through my notes and see if I can put together a guide on how to achieve that in case anyone else needs this type of functionality.

 

But for now, all I need to do is show the list price (the price that is in the TABLE_PRODUCTS and NOT any specials price) in the product_listing.php module (as found in catalog/modules) along with the groups price. Currently it only shows the group price but I'd like the wholesalers to see what the list price is also.

 

Sort of how it appears on the products_info.php page where it shows both list and wholesale. As it is now, they have to actually go into a product_info.php page to see what the list price is.

 

I've fiddled around with the product_listing.php module and I've managed to add the line above wholesale pricing (which is products_price):

case 'PRODUCT_LIST_PRICE':
		$lc_align = 'right';

		if (tep_not_null($listing[$x]['specials_new_products_price'])) {
		  $lc_text = ' <s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span> ';
		} else {
		  $lc_text = ' ' . $currencies->display_price($listing[$x]['list_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . ' <br>' .
		  $lc_text = ' ' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . ' ';
		}

 

...but so far I haven't been able to get the list_price to show up. Any help on how to get that list price would be very much appreciated. Thanks in advance.

Link to comment
Share on other sites

Allright, I can't find anything in this *LONG* thread by searching, so I'm going to go ahead and post. Forgive if it's been asked. I've done the basic install instructions, no other contribs are installed, and I can't find any errors.... although that may not be the case if I could access the menu for this contrib. It doesn't show up at all in my admin menu... any reason why that might be?

Link to comment
Share on other sites

First of all, great contribution, very useful. I've installed SPPC and Hide products into a pretty heavily modified store and the only problem I had, besides my modifications to the contrib, was in order to get the Payment and Shipping options in "customers_groups.php" to write to the database I had to make the following changes in the $action switch;

 

Comment out the while loops in the 'update' and 'newconfirm' cases for 'payment_allowed" and "shipment_allowed"

/*		  while(list($key, $val) = each($HTTP_POST_VARS['payment_allowed'])) {
		if ($val == true) { 
		$group_payment_allowed .= tep_db_prepare_input($val).';'; 
		}
	  } // end while */
/*		  while(list($key, $val) = each($HTTP_POST_VARS['shipping_allowed'])) {
		if ($val == true) { 
		$group_shipment_allowed .= tep_db_prepare_input($val).';'; 
		}
	  } // end while */

 

and replace with;

 

		foreach ($HTTP_POST_VARS['payment_allowed'] as $val){
	if ($val == true) { 
	$group_payment_allowed .= tep_db_prepare_input($val).';'; 
	}	  
  }
	foreach ($HTTP_POST_VARS['shipping_allowed'] as $val){
	if ($val == true) { 
	$group_shipment_allowed .= tep_db_prepare_input($val).';'; 
	}	  
  }

 

For some reason my $_POST variables would not make it through the while loop. Works fine now with the foreach().

Matt Mika

Installed Contributions: Multi-Stores, QTPro, CCGV(trad), Batch Print, EasyPopulate, Simple Manual Order Entry, Encrypting Credit Card Via Mcrypt, UPSXML, Down for Maintenance, On The Fly GD Thumbs, SPPC, SPPC Hide, and various personal tweaks

Link to comment
Share on other sites

I would use something like WinMerge to compare your Admin/categories.php file with the one included in SPPC v4.1.5

 

It sounds to me like something was missed in that file when you were editing it for the SPPC install :blush:

 

Yeah thats the only real conclusion i can come to myself - When I did it I used Compare & Merge like it said in recommended in the instructions, but I will have a go restoring the backup of admin/categories.php and then re-editing that file with WinMerge like you suggest.

 

Thanks for your reply.

+Coby+

Link to comment
Share on other sites

Hrmm... I went through it with a fine tooth comb as per changes instructions, but still would do the exact same problem.

 

then i decided i'd download one of the older versions of the admin/categories.php file, so i downloaded the 4.1.1 package and made the changes to admin/categories.php as per the older version - uploaded it and it seems to have fixed the problem straight away.

 

not sure exactly how this happened - but i made the original changes *exactly* as per the instructions and using winmerge. The current version instructions may include (or leave out) something that isnt 100% correct, or i simply may be a little less competent than i previously thought lol :blush: , but whatever it is, the older version of the changes to the file seems to have solved my problem.

 

hope this helps someone else in the future.

Edited by cobyone
Link to comment
Share on other sites

...but so far I haven't been able to get the list_price to show up. Any help on how to get that list price would be very much appreciated. Thanks in advance.

 

Well, it looks like I was able to figure out how to add the retail list price to the product_listing.php module.

 

**Edit**

 

Darn, I thought it was working but I still have some issues. False alarm...

Edited by 1Putts
Link to comment
Share on other sites

But for now, all I need to do is show the list price (the price that is in the TABLE_PRODUCTS and NOT any specials price) in the product_listing.php module (as found in catalog/modules) along with the groups price. Currently it only shows the group price but I'd like the wholesalers to see what the list price is also.

 

Sort of how it appears on the products_info.php page where it shows both list and wholesale. As it is now, they have to actually go into a product_info.php page to see what the list price is.

The retail price is the one you get from the query. For customer groups this is replaced by the group price, so you have to add that in between getting the results from the query and the code where it is replaced by the group prices. Sort of like this? (starts around line 88 in includes/modules/product_listing.php):

	while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
}

// add list price (retail price) to the array
 for ($x = 0; $x < $no_of_listings; $x++) {
$listing[$x]['list_price'] = $listing[$x]['products_price'];
 }

Link to comment
Share on other sites

All my products are showing as Out of Stock in the product listing, not on the product_info page with the individual item. The individual items are fine. I've check the product_info.php page and the include/functions/general.php page but can't figure out where the problem may be.

In the regular product_listing.php module the only mention of stock is with:

		  case 'PRODUCT_LIST_QUANTITY':
		$lc_align = 'right';
		$lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
		break;

You are sure you didn't forget the [$x]? SPPC does nothing with stock/products quantity (well apart from the Price Break contribution).

Link to comment
Share on other sites

Allright, I can't find anything in this *LONG* thread by searching, so I'm going to go ahead and post. Forgive if it's been asked. I've done the basic install instructions, no other contribs are installed, and I can't find any errors.... although that may not be the case if I could access the menu for this contrib. It doesn't show up at all in my admin menu... any reason why that might be?

Change of price is added to the "regular" admin/categories.php so nothing "SPPC like" to see in the menu there.

For administering the customer groups there should now be a link in the menu now under the "Customers". Of course you can go straight to it, by changing the url in the address bar of your browser to go to /adminfoldername/customers_groups.php

Link to comment
Share on other sites

Not sure if or how this can be done.

 

I want to take the the customers_group_id = '5' from products_groups and insert those values into the products table in the products_cost column.

 

Can anyone tell me how to do this

 

any help is appreciated

 

Thanks

Link to comment
Share on other sites

Quick Questions - Does the Quantity Price Break for SPPC take the discount off for that product only?

 

ie.... Customer buys 3 of product A and 2 of product B. Product A gets a 5% discount if you purchase 3 or more.

Is that 5% going to be taken off of only the product A prices - or is it going to be taken off the subtotal of the entire order?

 

Thanks :thumbsup:

~Tracy
 

Link to comment
Share on other sites

Yes, you should. Did you in the section:

//Master Products
  } elseif ($action == 'new_master_preview') {
if (tep_not_null($HTTP_POST_VARS)) {

Also make the change for the hide post variables (which are an array...):

/* Re-Post all POST'ed variables */
  reset($HTTP_POST_VARS);
  while (list($key, $value) = each($HTTP_POST_VARS)) {
//		if (!is_array($HTTP_POST_VARS[$key])) {
// BOF Separate Pricing per Customer
if (is_array($value)) {
 while (list($k, $v) = each($value)) {
 echo tep_draw_hidden_field($key . '[' . $k . ']', htmlspecialchars(stripslashes($v)));
 }
} else {
// EOF Separate Pricing per Customer

 

Hmmmm - well, I've been looking through to see if I can figure out exactly where to work that in to the action == new_master_preview but I don't see it in action == new_product_preview. I did a search on the install instructions for "Re-Post" and it had nothing, so I searched for "reset" and again it found nothing :huh: So I cannot seem to locate the code you recommend above anywhere in my admin/categories.php or in the installation instrutions :huh:

 

Would you mind letting me know where in the action == new_master_preview I should place the above code, and should it be in the action == new_product_preview as well? Even better, if you happen to have a copy of an admin/categories.php file with SPPC, Master Products and Hide Products / Categories for SPPC on it (even if it has other stuff that's fine) could you email or PM it over to me? I can do a comparison to what I've got here and maybe even find what it is I've done on that dang file that causes the page to not want to do anything other than timeout when I add a new product / category or update a product / category - LOL :thumbsup:

~Tracy
 

Link to comment
Share on other sites

Does the Quantity Price Break for SPPC take the discount off for that product only?

 

ie.... Customer buys 3 of product A and 2 of product B. Product A gets a 5% discount if you purchase 3 or more.

Is that 5% going to be taken off of only the product A prices - or is it going to be taken off the subtotal of the entire order?

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 :)

Link to comment
Share on other sites

The retail price is the one you get from the query. For customer groups this is replaced by the group price, so you have to add that in between getting the results from the query and the code where it is replaced by the group prices. Sort of like this? (starts around line 88 in includes/modules/product_listing.php):

	while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
}

// add list price (retail price) to the array
 for ($x = 0; $x < $no_of_listings; $x++) {
$listing[$x]['list_price'] = $listing[$x]['products_price'];
 }

 

Thanks. That's pretty close to what I had only I had it in the wrong loop and it was spitting out all the wrong numbers. But that fixed it up perfectly.

 

I'm just finishing up installing the "Hide Products and Categories from Customer Groups" add-on and it all seems to be working except for one thing. I converted my Categories menu to a drop down and the code for the catalog/includes/boxes/categories.php doesn't quite work.

 

Here's what i have and I'm guessing I'm just missing one small thing...you can see my $categories_query and then the code which is commented out is what I'm using as a reference.

 

<?php

 function tep_get_paths($categories_array = '', $parent_id = '0', $indent = '', $path='') {
global $languages_id;

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

$categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name");
// BOF SPPC hide categories from groups
  //$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name");
// EOF SPPC hide categories from groups

while ($categories = tep_db_fetch_array($categories_query)) {
  if ($parent_id=='0'){
$categories_array[] = array('id' => $categories['categories_id'],
								  'text' => $indent . $categories['categories_name']);
  }
  else{
$categories_array[] = array('id' => $path . $parent_id . '_' .$categories['categories_id'],
								  'text' => $indent . $categories['categories_name']);
  }

  if ($categories['categories_id'] != $parent_id) {
$this_path=$path;
if ($parent_id != '0')
  $this_path = $path . $parent_id . '_';
	$categories_array = tep_get_paths($categories_array, $categories['categories_id'], $indent . '  ', $this_path);
  }
}

return $categories_array;
 }

 $info_box_contents = array();
 $info_box_contents[] = array('align' => 'left',
 //							 'text'  => BOX_HEADING_CATEGORIES
						  );
 new infoBoxHeading($info_box_contents, true, false);

 $info_box_contents = array();
 $info_box_contents[] = array('form' => '<form action="' . tep_href_link(FILENAME_DEFAULT) . '" method="get">' . tep_hide_session_id(),
						   'align' => 'left',
						   'text'  => tep_draw_pull_down_menu('cPath', tep_get_paths(array(array('id' => '', 'text' => PULL_DOWN_DEFAULT))), $cPath, 'onchange="this.form.submit();"style="width: 100%"')
						  );
 new infoBox($info_box_contents);
?>

Link to comment
Share on other sites

Not sure if or how this can be done.

 

I want to take the the customers_group_id = '5' from products_groups and insert those values into the products table in the products_cost column.

Tricky one.... took a number of tries but this seemed to do the trick (backup, backup, backup!):

update products p, products_groups pg SET p.products_cost = pg.customers_group_price where customers_group_id = '5' and p.products_id = pg.products_id;

Link to comment
Share on other sites

The retail price is the one you get from the query. For customer groups this is replaced by the group price, so you have to add that in between getting the results from the query and the code where it is replaced by the group prices. Sort of like this? (starts around line 88 in includes/modules/product_listing.php):

	while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
}

// add list price (retail price) to the array
 for ($x = 0; $x < $no_of_listings; $x++) {
$listing[$x]['list_price'] = $listing[$x]['products_price'];
 }

 

Thanks. That's pretty close to what I had only I had it in the wrong loop and it was spitting out all the wrong numbers. But that fixed it up perfectly.

 

I'm just finishing up installing the "Hide Products and Categories from Customer Groups" add-on and it all seems to be working except for one thing. I converted my Categories menu to a drop down and the code for the catalog/includes/boxes/categories.php doesn't quite work.

 

Here's what i have and I'm guessing I'm just missing one small thing...you can see my $categories_query and then the code which is commented out is what I'm using as a reference.

 

<?php

 function tep_get_paths($categories_array = '', $parent_id = '0', $indent = '', $path='') {
global $languages_id;

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

$categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name");
// BOF SPPC hide categories from groups
  //$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and find_in_set('" . $customer_group_id . "', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name");
// EOF SPPC hide categories from groups

while ($categories = tep_db_fetch_array($categories_query)) {
  if ($parent_id=='0'){
$categories_array[] = array('id' => $categories['categories_id'],
								  'text' => $indent . $categories['categories_name']);
  }
  else{
$categories_array[] = array('id' => $path . $parent_id . '_' .$categories['categories_id'],
								  'text' => $indent . $categories['categories_name']);
  }

  if ($categories['categories_id'] != $parent_id) {
$this_path=$path;
if ($parent_id != '0')
  $this_path = $path . $parent_id . '_';
	$categories_array = tep_get_paths($categories_array, $categories['categories_id'], $indent . '  ', $this_path);
  }
}

return $categories_array;
 }

 $info_box_contents = array();
 $info_box_contents[] = array('align' => 'left',
 //							 'text'  => BOX_HEADING_CATEGORIES
						  );
 new infoBoxHeading($info_box_contents, true, false);

 $info_box_contents = array();
 $info_box_contents[] = array('form' => '<form action="' . tep_href_link(FILENAME_DEFAULT) . '" method="get">' . tep_hide_session_id(),
						   'align' => 'left',
						   'text'  => tep_draw_pull_down_menu('cPath', tep_get_paths(array(array('id' => '', 'text' => PULL_DOWN_DEFAULT))), $cPath, 'onchange="this.form.submit();"style="width: 100%"')
						  );
 new infoBox($info_box_contents);
?>

Link to comment
Share on other sites

I converted my Categories menu to a drop down and the code for the catalog/includes/boxes/categories.php doesn't quite work.
You are just a bit vague here ;)
Here's what i have and I'm guessing I'm just missing one small thing...you can see my $categories_query and then the code which is commented out is what I'm using as a reference.
Seems nothing wrong with that, but are you sure $customer_group_id is "known" inside that function. You don't even use global customer_group_id;.
Link to comment
Share on other sites

You are just a bit vague here ;)

Seems nothing wrong with that, but are you sure $customer_group_id is "known" inside that function. You don't even use global customer_group_id;.

 

Sorry, what I meant was I have changed my Categories box to a dropdown menu, similar to that of Manufacturers.

 

Good point on the $customer_group_id but, according to the documentation, that is taken care of in the includes/application_top.php. So I threw in an echo statement and, sure enough, it does have the correct ID.

 

PS. I mentioned in an earlier post that I had successfully added the ability to apply Order Total modules to Customer Groups. Do you think I should post it all as a separate contribution or do you think it would be better to send you the files and you can roll it into your next update. Either way, it's the same to me. Thanks again for all your help.

Link to comment
Share on other sites

Tricky one.... took a number of tries but this seemed to do the trick (backup, backup, backup!):

update products p, products_groups pg SET p.products_cost = pg.customers_group_price where customers_group_id = '5' and p.products_id = pg.products_id;

 

 

Thanks it worked like a charm.

 

I am new to php and would have never figured that out.

 

Mike

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