Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

I've got a problem in the admin with the customer and customer groups. No changes are being saved after trying to update any of the fields in either of these areas. This is the same problem I had before when I had Multi Shops installed (which is now gone). What files will I need to look at to see where I went wrong?

I'm not sure exactly what changes you cannot save but it sounds like a very strange problem unless you have a register_globals issue. Then the HTTP_GET_VARS and HTTP_POST_VARS might not be available (actually that is a different setting I think, something like long array names).

 

You could start with looking if everything is available in the $_POST array when you do an update. At the top of the page you could add and change a few things:

$action = (isset($H_GET['action']) ? $_GET['action'] : ''); // use superglobal $_GET instead of $HTTP_GET_VARS

 if (tep_not_null($action)) {
switch ($action) {
echo '<pre>';
print_r($_POST);
echo '</pre>';

Link to comment
Share on other sites

I'm having difficulty with a complicated discount i wrote on order.php page. I'm using SPPC which is part of the problem. I posted it in the payment section http://www.oscommerce.com/forums/index.php?showtopic=285394 because, it only occurs when a customer pays with PayPal. But if anyone here knows how to help please let me know.

Thanks.

Link to comment
Share on other sites

I'm having difficulty with a complicated discount i wrote on order.php page. I'm using SPPC which is part of the problem. I posted it in the payment section http://www.oscommerce.com/forums/index.php?showtopic=285394 because, it only occurs when a customer pays with PayPal. But if anyone here knows how to help please let me know.

I have no clue about PayPal but the code for checking the customer group id is strange (although it might still work fine). It says that if the session with sppc_customer_group_id is not set the customer should be considered wholesale (customer group id 1)?

Link to comment
Share on other sites

Jan,

 

I don't really understand what I'm supposed to do with the code :blink::( Register globals are turned on in my server and I don't have a clue as to what that really means to the programming.

 

Let me clarify the issue I'm having. If I go into my admin panel, select customers and choose a customer to edit, try to change ANY field at all, phone, address, customer group, then hit the update button - the changes that I just made appear there. However if i go back to customers, choose the same customer and edit, the changes were never saved.

 

It appears to only affect the customer settings. However, when I was checking other modules, I have a new issue with the products. (I don't usually update through the admin panel for the products but load directly into the database.)

 

When I changed a description for an item, hit update I got this error:

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where customers_group_id = '1' and products_id = '86'' at line 1

 

update products_groups , where customers_group_id = '1' and products_id = '86'

 

[TEP STOP]

 

 

Any help would be appreciated.

 

Thanks,

 

Joanne

 

I'm not sure exactly what changes you cannot save but it sounds like a very strange problem unless you have a register_globals issue. Then the HTTP_GET_VARS and HTTP_POST_VARS might not be available (actually that is a different setting I think, something like long array names).

 

You could start with looking if everything is available in the $_POST array when you do an update. At the top of the page you could add and change a few things:

$action = (isset($H_GET['action']) ? $_GET['action'] : ''); // use superglobal $_GET instead of $HTTP_GET_VARS

 if (tep_not_null($action)) {
switch ($action) {
echo '<pre>';
print_r($_POST);
echo '</pre>';

Link to comment
Share on other sites

I have no clue about PayPal but the code for checking the customer group id is strange (although it might still work fine). It says that if the session with sppc_customer_group_id is not set the customer should be considered wholesale (customer group id 1)?

I have it working now. As you can see, i just added another layer to the "if" to reverse it if the customer was using PayPal as the payment_method. I have no idea why this works, but it does. It's a little disturbing, but i suppose i should let sleeping gremlins lie.

//BOF CAB DISCOUNT Going back through the entire group of products and discount only the cabs.//
   for($j=0; $j < $index; $j++){
	//This sets the query that will check what the category_id is for the product (dtk)
	$product_category_query = tep_db_query("SELECT categories_id FROM products_to_categories WHERE products_id ='". $this->products[$j]['id'] ."'");
	// This, i believe, sets the category in an array, im just doing it because all the other querys here do it. Why do i feel like a monkey when i say that?(dtk)
	$product_category = tep_db_fetch_array($product_category_query);
	// Check if the product is a "designer cabochon"
	if($product_category['categories_id'] == 35){
		// This is checking to see if the customer is a wholesale customer. 
		// Retail=0,  Wholesale = 1 however for some reason that is reversed here. Since PayPal still functions with the normal properties, I placed and if to revers the check if the user is paying with PayPal. (I have no idea why this works, but it does.)
		 global $sppc_customer_group_id;
		   if($this->info['payment_method'] != 'PayPal'){
				if(!tep_session_is_registered('sppc_customer_group_id')) {
			 			$customer_group_id = '1';
			 		} else {
 			    		$customer_group_id = $sppc_customer_group_id;
					}		
		  }else{
		  		if(!tep_session_is_registered('sppc_customer_group_id')) {
			 			$customer_group_id = '0';
			 		} else {
 			    		$customer_group_id = $sppc_customer_group_id;
					}		
		  }
  		if ($customer_group_id != '0'){
  			if($this->info['subtotal'] < 51){
			  $this->info['subtotal'] -= $this->products[$j]['final_price'] * .25;
  			  $this->products[$j]['final_price'] = $this->products[$j]['final_price'] * .75;
  			}else if($this->pre_discount_total < 201){
			  $this->info['subtotal'] -= $this->products[$j]['final_price'] * .3;
			  $this->products[$j]['final_price'] = $this->products[$j]['final_price'] * .70;
			}else if($this->pre_discount_total < 500){
			  $this->info['subtotal'] -= $this->products[$j]['final_price'] * .35;
			  $this->products[$j]['final_price'] = $this->products[$j]['final_price'] * .65;
			}else if($this->pre_discount_total > 500){
			  $this->info['subtotal'] -= $this->products[$j]['final_price'] * .40;
			  $this->products[$j]['final_price'] = $this->products[$j]['final_price'] * .60;
			}
		}
	}

}
//EOF CAB DISCOUNT///*************************************/

Link to comment
Share on other sites

JWhen I changed a description for an item, hit update I got this error:

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where customers_group_id = '1' and products_id = '86'' at line 1

 

update products_groups , where customers_group_id = '1' and products_id = '86'

The line where this comes from should be around 257 (case update) and reads:

		tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = '" . $_POST['sppcprice'][$customers_group['customers_group_id']] . "' where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");

How is it possible that the whole set customers_group_price = '" . $_POST['sppcprice'][$customers_group['customers_group_id']] . "' is replaced by a comma?

Link to comment
Share on other sites

Jan,

 

I've got SPPC, Price Break for SPPC, Price Break for SPPC, and Hide Products for SPPC installed.

 

The code you have below is what is in the file for SPPC and the Hide Products. For the Price Break mod, it was changed to

 

tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " " . $sppc_update_query . " where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");

 

I've been using a file comparison program to make all the changes. Did I go wrong somewhere?

 

Joanne

 

 

The line where this comes from should be around 257 (case update) and reads:

		tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = '" . $_POST['sppcprice'][$customers_group['customers_group_id']] . "' where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");

How is it possible that the whole set customers_group_price = '" . $_POST['sppcprice'][$customers_group['customers_group_id']] . "' is replaced by a comma?

Link to comment
Share on other sites

I've got SPPC, Price Break for SPPC, Price Break for SPPC, and Hide Products for SPPC installed.

 

The code you have below is what is in the file for SPPC and the Hide Products. For the Price Break mod, it was changed to

 

tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " " . $sppc_update_query . " where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");

 

I've been using a file comparison program to make all the changes. Did I go wrong somewhere?

It looks something is missing just above it, that inserts the comma (this is the Price Break addition):

	} // now we need to get rid of the last comma in the query string...
   $sppc_update_query = rtrim($sppc_update_query);
   $query_string_length = strlen($sppc_update_query);
 if (substr($sppc_update_query, -1) == ",") {
	$sppc_update_query = substr($sppc_update_query, $query_string_length-1);
 } 

	tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " " . $sppc_update_query . " where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");

Link to comment
Share on other sites

Jan,

 

That code is there. I've checked it against SPPC, Price Break & Hide from Groups but still can't find the problem. The forum won't let me post the whole file so please let me know where else I should look to resolve this problem.

 

Thanks!

 

Joanne

 

 } // now we need to get rid of the last comma in the query string...
      $sppc_update_query = rtrim($sppc_update_query);
      $query_string_length = strlen($sppc_update_query);
    if (substr($sppc_update_query, -1) == ",") {
       $sppc_update_query = substr($sppc_update_query, $query_string_length-1);
    }

       tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " " . $sppc_update_query . " where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");

Link to comment
Share on other sites

That code is there. I've checked it against SPPC, Price Break & Hide from Groups but still can't find the problem. The forum won't let me post the whole file so please let me know where else I should look to resolve this problem.

Most likely is in categories.php in the part in the top that starts with case 'update':

 

So posting the top part of categories.php should perhaps suffice to find out what is wrong. Personally I'm afraid I won't be able to look at it the first few days.

Link to comment
Share on other sites

Whenever you get a chance to look at it would be great.

I think something goes wrong with the braces. The end of the code that goes over the group prices is ended much to soon. It starts around line 804 in your file:

<!-- EOF Price Break 1.11.3 Retail -->
<!-- BOF Separate Pricing Per Customer -->
<?php
$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id != '0' order by customers_group_id");
$header = false;
while ($customers_group = tep_db_fetch_array($customers_group_query)) {

The while has to go over all the product prices but stops around 50 lines further whereas it should be about 250 lines, just before the part where the products description starts:

<?php
	} // end while ($customers_group = tep_db_fetch_array($customers_group_query))
?>
	  <tr>
		<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
	  </tr>
<!-- EOF Separate Pricing Per Customer -->
<?php
for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
?>

That might cause the problem.

Link to comment
Share on other sites

Hello,

 

I uploaded a contribution for SPPC, Quick Group Discount Module, (http://addons.oscommerce.com/info/5569/v,22). It allows from admin panel to give complete groups percentage discounts. Example, say you had a group called dealers and currently the discount from retail is 40%, but you wanted to change the entire group to 50%, just go to this panel and set the dealers to 50%, entire group will now reflect 50% off of retail. First contribution, and hope it saves you time.

 

Thanks JR

 

 

Hello,

 

i had a problem with that contribution. after input a discount of 10% for one group it output an error:

 

1136 - Column count doesn't match value count at row 1

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

 

what can i do to fix that?

 

i am running on php 4.4.7

 

marco

Link to comment
Share on other sites

// BOF customer_sort_admin_v1 adapted for Separate Pricing Per Customer ?>

// BOF customer_sort_admin_v1 adapted for Separate Pricing Per Customer ?>

// BOF customer_sort_admin_v1 adapted for Separate Pricing Per Customer ?>

 

I just installed SPPC and I get these three lines at the top of the page catalog/admin/customers.php (there are currently 3 customer records). Can anyone help?

Edited by Jan Zonjee
Link to comment
Share on other sites

I have a query about the installation instructions....They are really comprehensive and, although lengthy, very easy to follow.

 

But on the instructions for includes/classes/shipping.php there is a text block that isn't formatted correctly (all the rest are). It looks like this:

 

**REPLACE**

 

$this->modules = explode(';', MODULE_SHIPPING_INSTALLED);

 

**WITH**

 

// BOF Separate Pricing Per Customer, next line original code // $this->modules = explode(';', MODULE_SHIPPING_INSTALLED); global $customer_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'; } $customer_shipment_query = tep_db_query("select IF(c.customers_shipment_allowed <> '', c.customers_shipment_allowed, cg.group_shipment_allowed) as shipment_allowed from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_GROUPS . " cg where c.customers_id = '" . $customer_id . "' and cg.customers_group_id = '" . $customer_group_id . "'"); if ($customer_shipment = tep_db_fetch_array($customer_shipment_query) ) { if (tep_not_null($customer_shipment['shipment_allowed']) ) { $temp_shipment_array = explode(';', $customer_shipment['shipment_allowed']); $installed_modules = explode(';', MODULE_SHIPPING_INSTALLED); for ($n = 0; $n < sizeof($installed_modules) ; $n++) { // check to see if a shipping module is not de-installed if ( in_array($installed_modules[$n], $temp_shipment_array ) ) { $shipment_array[] = $installed_modules[$n]; } } // end for loop $this->modules = $shipment_array; } else { $this->modules = explode(';', MODULE_SHIPPING_INSTALLED); } } else { // default $this->modules = explode(';', MODULE_SHIPPING_INSTALLED); } // EOF Separate Pricing Per Customer

 

How should it really be?

 

Many thanks, and this is a fantastic contribution!!!

Link to comment
Share on other sites

But on the instructions for includes/classes/shipping.php there is a text block that isn't formatted correctly (all the rest are). It looks like this:

How should it really be?

Strange... This is how it should look (check the included class shipping in the package, should be the same):

// BOF Separate Pricing Per Customer, next line original code
 //   $this->modules = explode(';', MODULE_SHIPPING_INSTALLED);
 global $customer_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';
 }
  $customer_shipment_query = tep_db_query("select IF(c.customers_shipment_allowed <> '', c.customers_shipment_allowed, cg.group_shipment_allowed) as shipment_allowed from " . TABLE_CUSTOMERS . " c, " . TABLE_CUSTOMERS_GROUPS . " cg where c.customers_id = '" . $customer_id . "' and cg.customers_group_id =  '" . $customer_group_id . "'");
  if ($customer_shipment = tep_db_fetch_array($customer_shipment_query)  ) {
   if (tep_not_null($customer_shipment['shipment_allowed']) ) {
  $temp_shipment_array = explode(';', $customer_shipment['shipment_allowed']);
  $installed_modules = explode(';', MODULE_SHIPPING_INSTALLED);
  for ($n = 0; $n < sizeof($installed_modules); $n++) {
	  // check to see if a shipping module is not de-installed
	  if ( in_array($installed_modules[$n], $temp_shipment_array ) ) {
		  $shipment_array[] = $installed_modules[$n];
	  }
  } // end for loop
  $this->modules = $shipment_array;
  } else {
   $this->modules = explode(';', MODULE_SHIPPING_INSTALLED);
  }
  } else { // default
   $this->modules = explode(';', MODULE_SHIPPING_INSTALLED);
  }
// EOF Separate Pricing Per Customer

Link to comment
Share on other sites

Hi!

 

I dont know, if this is the right section for my problem, but I have a problem with SPPC.

 

My english is not so good -please excuse me-, however I try to explain my problem.

 

I installed a special version of SPPC (with base prices), the contrib "Hide products from cutstomer groups for SPPC" and "Quantity Price Breaks for SPPC".

 

The aim is, that a normal customer can buy one piece of a product, but the retailer (if the product is visible for him) has to buy at least five pieces.

 

At the Page "product_info" the amount is 5 for retailer and everything is okay.

 

The problem is at the pages that use the module "product_listing". Here the cart is filled only with one item, when I press the "buy now"-button - but it should be five, too!

 

Here is the code from product_listing:

        case 'PRODUCT_LIST_BUY_NOW':
       If (($listing[$x]['products_quantity']<>0) and ($listing[$x]['products_price'] > 0)){
           $lc_align = 'center';
           $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';
    }else{
       		$lc_align = 'center';
			$lc_text = tep_image_button('out_stock.gif', IMAGE_BUTTON_OUT_STOCK) . ' ';
       }
       break;

 

here is the code of product_info:

                <td class="main" align="right"><?php
               If (($product_info['products_quantity']<>0) and ($product_info['products_price']>0)) {
echo TEXT_ENTER_QUANTITY . ":" . tep_draw_input_field('cart_quantity', $pf->adjustQty(1), 'size="3"') . tep_draw_separator('pixel_trans.gif', '5', '1');
echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART, 'align=absmiddle');
               }else{
                  echo tep_image(DIR_WS_LANGUAGES . $language . '/images/buttons/button_out_stock.gif', IMAGE_BUTTON_OUT_STOCK);
               }?></td>

 

The best solution would be, that customers and also retailers could enter the amount directly on all pages. For retailers the amount box has to be prefilled with the minimum order quantitiy (5).

 

I hope you can understand and help me.

 

Greetings from Germany and thank you.

Link to comment
Share on other sites

My english is not so good -please excuse me-, however I try to explain my problem.

Your English is fine.

 

The problem is at the pages that use the module "product_listing". Here the cart is filled only with one item, when I press the "buy now"-button - but it should be five, too!

It certainly should because that is handled by the function add_cart in includes/classes/shopping_cart.php:

	function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
  // BOF Separate Pricing Per Customer, Price Break 1.11.3 modification
  // changed because of osC 2.2 MS2 November 13, 2005 update
  global $new_products_id_in_cart, $customer_id, $languages_id;

 $products_id_string = tep_get_uprid($products_id, $attributes);
 $products_id = tep_get_prid($products_id_string);

if (is_numeric($products_id) && is_numeric($qty)) {
$check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
$check_product = tep_db_fetch_array($check_product_query);

if (($check_product !== false) && ($check_product['products_status'] == '1')) {
  $pf = new PriceFormatter;
  $pf->loadProduct($products_id, $languages_id);
  $qty = $pf->adjustQty($qty);

As you can see in the last line, when a product is added to the cart the quantity is adjusted. So if the quantity block for the retailer is set to 5 (which looks like it because it works on product_info.php) then the quantity should be adjusted to 5 with the buy_now button too once the product ends up in the cart.

Link to comment
Share on other sites

i had a problem with that contribution. after input a discount of 10% for one group it output an error:

 

1136 - Column count doesn't match value count at row 1

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

 

what can i do to fix that?

There should be no problem because there are only three columns in the table products_groups and those are set:

 

1 for the customers_group_id

( 0.9 * p.products_price) as customers_group_price

products_id

 

There could be a problem if you added Quantity Price Breaks for SPPC. Then there would be a lot more columns in products_groups and then I would expect it to return such an error.

Link to comment
Share on other sites

By the way I have found an other problem: A retailer should see only a part of the products. But when he looks at the page "New products", he can see everything.

 

I thinks, that the file "product_listing.php" is resposible for the listing of new products and the files "products_new.php" and "\boxes\whats_new.php" are formatting the output. But I can't find the mistake in "product_listing.php", so here it is:

On the contrary, products_new.php does its own formatting so you really need to look there. There are definitely changes to be made in products_new.php to exclude the hidden products.

Link to comment
Share on other sites

There should be no problem because there are only three columns in the table products_groups and those are set:

 

1 for the customers_group_id

( 0.9 * p.products_price) as customers_group_price

products_id

 

There could be a problem if you added Quantity Price Breaks for SPPC. Then there would be a lot more columns in products_groups and then I would expect it to return such an error.

 

thank´s for the answer.. ti think thats the problem.. i added the quantity price breaks.. so i must expand the query.. i will try it later and post my results

 

bye

marco

Link to comment
Share on other sites

Hey Jan,

 

I am trying another one of your great contributions, Quantity Discounts 1.2. Having a little issue. I have altered the database with the sql, and changed the product_listing.php and application_top.php. As I change files I like to refresh the site to make sure no errors before getting to deep. I notice after updating the two above files, product listings page breaks (I loose the right column)? I viewed other pages to be modified, but did not notice any that would effect this page?

 

So This:

 

break; // EOF Separate Pricing per Customer

case 'PRODUCT_LIST_BUY_NOW':

$lc_align = 'center';

$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

break;

}

 

 

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

 

to this:

 

// BOF Separate Pricing per Customer, Price Break 1.11.3 modification

$no_of_listings = tep_db_num_rows($listing_query);

// 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;

}

 

$default_settings = array('products_price1' => '0.0000', 'products_price2' => '0.0000', 'products_price3' => '0.0000',

'products_price4' => '0.0000', 'products_price5' => '0.0000', 'products_price6' => '0.0000', 'products_price7' => '0.0000', 'products_price8' => '0.0000', 'products_price1_qty' => '0', 'products_price2_qty' => '0', 'products_price3_qty' => '0', 'products_price4_qty' => '0', 'products_price5_qty' => '0', 'products_price6_qty' => '0', 'products_price7_qty' => '0', 'products_price8_qty' => '0', 'products_qty_blocks' => '1');

 

while ($_listing = tep_db_fetch_array($listing_query)) {

// let's start with default settings, you never know

$_new_listing = array_merge($_listing , $default_settings);

$listing[] = $_new_listing;

$list_of_prdct_ids[] = $_listing['products_id'];

}

// next part is a debug feature, when uncommented it will print the info that this module receives

 

/* echo '<pre>';

print_r($listing);

echo '</pre>'; */

 

$select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";

if ($no_of_listings > 1) {

for ($n = 1 ; $n < count($list_of_prdct_ids) ; $n++) {

$select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' ";

}

}

// to avoid messing with index.php, which is complicated of itself already

// we add another query here to get the price break variables for retail customers

// for other groups we change the $pg_query from the one in SPPC4

 

if ($customer_group_id == '0') {

$retail_price_break_query = tep_db_query("select p.products_id, p.products_price1, p.products_price2, p.products_price3, p.products_price4, p.products_price5, p.products_price6, p.products_price7, p.products_price8, p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, p.products_price5_qty, p.products_price6_qty, p.products_price7_qty, p.products_price8_qty, p.products_qty_blocks from " . TABLE_PRODUCTS . " p where " . $select_list_of_prdct_ids . "");

while ($rp_break = tep_db_fetch_array($retail_price_break_query)) {

for ($u = 0; $u < $no_of_listings; $u++) {

if ($rp_break['products_id'] == $listing[$u]['products_id']) {

$listing[$u]['products_price1'] = $rp_break['products_price1'];

$listing[$u]['products_price2'] = $rp_break['products_price2'];

$listing[$u]['products_price3'] = $rp_break['products_price3'];

$listing[$u]['products_price4'] = $rp_break['products_price4'];

$listing[$u]['products_price5'] = $rp_break['products_price5'];

$listing[$u]['products_price6'] = $rp_break['products_price6'];

$listing[$u]['products_price7'] = $rp_break['products_price7'];

$listing[$u]['products_price8'] = $rp_break['products_price8'];

$listing[$u]['products_price1_qty'] = $rp_break['products_price1_qty'];

$listing[$u]['products_price2_qty'] = $rp_break['products_price2_qty'];

$listing[$u]['products_price3_qty'] = $rp_break['products_price3_qty'];

$listing[$u]['products_price4_qty'] = $rp_break['products_price4_qty'];

$listing[$u]['products_price5_qty'] = $rp_break['products_price5_qty'];

$listing[$u]['products_price6_qty'] = $rp_break['products_price6_qty'];

$listing[$u]['products_price7_qty'] = $rp_break['products_price7_qty'];

$listing[$u]['products_price8_qty'] = $rp_break['products_price8_qty'];

$listing[$u]['products_qty_blocks'] = $rp_break['products_qty_blocks'];

} // end if ($rp_break['products_id'] == $listing[$u]['products_id'])

} // end for ($u = 0; $u < $no_of_listings; $u++)

} // end while ($rp_break = tep_db_fetch_array($retail_price_break_query)

} // end if ($customer_group_id == '0')

 

// get all product 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, pg.products_price1, pg.products_price2, pg.products_price3, pg.products_price4, pg.products_price5, pg.products_price6, pg.products_price7, pg.products_price8, pg.products_price1_qty, pg.products_price2_qty, pg.products_price3_qty, pg.products_price4_qty, pg.products_price5_qty, pg.products_price6_qty, pg.products_price7_qty, pg.products_price8_qty, pg.products_qty_blocks from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."' ");

// $no_of_pg_products = tep_db_num_rows($pg_query) ;

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' => '', 'final_price' => $pg_array['price'], 'products_price1' => $pg_array['products_price1'], 'products_price2' => $pg_array['products_price2'], 'products_price3' => $pg_array['products_price3'], 'products_price4' => $pg_array['products_price4'], 'products_price5' => $pg_array['products_price5'], 'products_price6' => $pg_array['products_price6'], 'products_price7' => $pg_array['products_price7'], 'products_price8' => $pg_array['products_price8'], 'products_price1_qty' => $pg_array['products_price1_qty'], 'products_price2_qty' => $pg_array['products_price2_qty'], 'products_price3_qty' => $pg_array['products_price3_qty'], 'products_price4_qty' => $pg_array['products_price4_qty'], 'products_price5_qty' => $pg_array['products_price5_qty'], 'products_price6_qty' => $pg_array['products_price6_qty'], 'products_price7_qty' => $pg_array['products_price7_qty'], 'products_price8_qty' => $pg_array['products_price8_qty'], 'products_qty_blocks' => $pg_array['products_qty_blocks']);

}

for ($x = 0; $x < $no_of_listings; $x++) {

// replace products prices with those from customers_group table

if(!empty($new_prices)) {

for ($i = 0; $i < count($new_prices); $i++) {

if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {

$listing[$x]['products_price'] = $new_prices[$i]['products_price'];

$listing[$x]['final_price'] = $new_prices[$i]['final_price'];

$listing[$x]['products_price1'] = $new_prices[$i]['products_price1'];

$listing[$x]['products_price2'] = $new_prices[$i]['products_price2'];

$listing[$x]['products_price3'] = $new_prices[$i]['products_price3'];

$listing[$x]['products_price4'] = $new_prices[$i]['products_price4'];

$listing[$x]['products_price5'] = $new_prices[$i]['products_price5'];

$listing[$x]['products_price6'] = $new_prices[$i]['products_price6'];

$listing[$x]['products_price7'] = $new_prices[$i]['products_price7'];

$listing[$x]['products_price8'] = $new_prices[$i]['products_price8'];

$listing[$x]['products_price1_qty'] = $new_prices[$i]['products_price1_qty'];

$listing[$x]['products_price2_qty'] = $new_prices[$i]['products_price2_qty'];

$listing[$x]['products_price3_qty'] = $new_prices[$i]['products_price3_qty'];

$listing[$x]['products_price4_qty'] = $new_prices[$i]['products_price4_qty'];

$listing[$x]['products_price5_qty'] = $new_prices[$i]['products_price5_qty'];

$listing[$x]['products_price6_qty'] = $new_prices[$i]['products_price6_qty'];

$listing[$x]['products_price7_qty'] = $new_prices[$i]['products_price7_qty'];

$listing[$x]['products_price8_qty'] = $new_prices[$i]['products_price8_qty'];

$listing[$x]['products_qty_blocks'] = $new_prices[$i]['products_qty_blocks'];

}

}

} // end if(!empty($new_prices)

$listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group

$listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price

} // end for ($x = 0; $x < $no_of_listings; $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 " . TABLE_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'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price'] , 'final_price' => $specials_array['specials_new_products_price']);

}

 

// add the correct specials_new_products_price and replace final_price

for ($x = 0; $x < $no_of_listings; $x++) {

 

if(!empty($new_s_prices)) {

for ($i = 0; $i < count($new_s_prices); $i++) {

if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {

$listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];

$listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];

}

}

} // end if(!empty($new_s_prices)

} // end for ($x = 0; $x < $no_of_listings; $x++)

 

// while ($listing = tep_db_fetch_array($listing_query)) { (was original code)

for ($x = 0; $x < $no_of_listings; $x++) {

 

$rows++;

 

if (($rows/2) == floor($rows/2)) {

$list_box_contents[] = array('params' => 'class="productListing-even"');

} else {

$list_box_contents[] = array('params' => 'class="productListing-odd"');

}

 

$cur_row = sizeof($list_box_contents) - 1;

 

for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {

$lc_align = '';

 

switch ($column_list[$col]) {

case 'PRODUCT_LIST_MODEL':

$lc_align = '';

$lc_text = ' ' . $listing[$x]['products_model'] . ' ';

break;

case 'PRODUCT_LIST_NAME':

$lc_align = '';

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';

} else {

$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> ';

}

break;

case 'PRODUCT_LIST_MANUFACTURER':

$lc_align = '';

$lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a> ';

break;

case 'PRODUCT_LIST_PRICE':

$lc_align = 'right';

 

/* removed for price break modification

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]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . ' ';

} end removed for price break modification, see next two lines for replacement code */

 

$pf->parse($listing[$x]);

$lc_text = $pf->getPriceStringShort();

break;

case 'PRODUCT_LIST_QUANTITY':

$lc_align = 'right';

$lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';

break;

case 'PRODUCT_LIST_WEIGHT':

$lc_align = 'right';

$lc_text = ' ' . $listing[$x]['products_weight'] . ' ';

break;

case 'PRODUCT_LIST_IMAGE':

$lc_align = 'center';

if (isset($HTTP_GET_VARS['manufacturers_id'])) {

$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';

} else {

$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';

}

break;

case 'PRODUCT_LIST_BUY_NOW':

$lc_align = 'center';

$lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> ';

break;

}

// EOF Separate Pricing per Customer, Price Break 1.11.3 modification

 

 

Thanks JR

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