Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

scendent

Seperate Pricing Per Customer v3.5

Recommended Posts

Hi guys, firstly I would like to say thank you for this excellent mod. It is extremely helpful and I can only imagine how much tedious work you had to put into this.

 

There are a few minor issues I am running into with this mod that I wanted to post on here to see if anyone else had the same issues or not. I tried searching unfortunatly I didn't find anything in response to my issues I will be posting.

 

The website this mod is used on is www.mishudesigns.com

 

Here are the problems step by step.

 

1. If you click on a category lets take the "4x6 Magnet Frames", and you click on details it comes back with " Product not found!"

If you click on add to cart from that same screen it just takes you to the cart instead of placing the item into your cart, and it displays " Your Shopping Cart is empty!"

 

2. Instead of clicking on the details button, you have to click on the image itself for it to take you to the details page on that product. If you click on the add to cart button from there it adds the product, however it seems to double the price per quantity.

 

I have researched a bit about this and I have come to the following conclusion. When I use the "Product Attribute" option in the admin cp & I use the default Products Price (Net): then they add together. Is there anyway to fix the collision between the 2?

In other words It updates fine depending on wholesale & customer group (you can test by logging in using test@test.com and testing is the password), however there are some minor collisions. If someone could help me out with this I would be very great full.

 

Thanks in advance and continue to do the great job with this community!

Share this post


Link to post
Share on other sites
1. If you click on a category lets take the "4x6 Magnet Frames", and you click on details it comes back with " Product not found!"

If you click on add to cart from that same screen it just takes you to the cart instead of placing the item into your cart, and it displays " Your Shopping Cart is empty!"

That is not so strange because the products_id's are missing on a number of links:

<tr><td><a href="http://mishudesigns.com/osc/product_info.php?products_id="><img src="includes/languages/english/images/buttons/button_details.gif" border="0" alt="" width="61" height="18"></a>  <a href="http://mishudesigns.com/osc/products_new.php?action=buy_now&products_id="><img src="includes/languages/english/images/buttons/button_add_to_cart.gif" border="0" alt="" width="78" height="18"></a></td></tr>

 

2. Instead of clicking on the details button, you have to click on the image itself for it to take you to the details page on that product. If you click on the add to cart button from there it adds the product, however it seems to double the price per quantity.

True, because the base price is $10 (e.g.) and the attribute price is also $10. So they add up. If you want to show the actual price in the drop-down for the attribute you need to use a contribution (Actual attribute price I think it is called).

Share this post


Link to post
Share on other sites

As mentioned so often in this thread. Add (e.g. in the footer, inside PHP tags):

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

You might have to do a "view source" in your browser to see it.

 

I put this code and here is what it shows:

Array

(

[cart] => shoppingcart Object

(

[contents] => Array

(

)

 

[total] => 0

[weight] => 0

[cartID] =>

[content_type] =>

)

 

[language] => polish

[languages_id] => 4

[currency] => PLN

[navigation] => navigationhistory Object

(

[path] => Array

(

[0] => Array

(

[mode] => NONSSL

[get] => Array

(

[language] => PL

)

 

=> Array

(

)

 

)

 

)

 

[snapshot] => Array

(

)

 

)

 

)

Edited by bohemica-plants

Share this post


Link to post
Share on other sites

here is the code:

 

Array

(

[cart] => shoppingcart Object

(

[contents] => Array

(

[69] => Array

(

[qty] => 1

)

 

[56] => Array

(

[qty] => 1

)

 

)

 

[total] => 0

[weight] => 0

[cartID] =>

[content_type] =>

[cg_id] => 0

)

 

[language] => polish

[languages_id] => 4

[currency] => EUR

[navigation] => navigationhistory Object

(

[path] => Array

(

[0] => Array

(

[mode] => NONSSL

[get] => Array

(

[language] => en

)

 

=> Array

(

)

 

)

 

[1] => Array

(

[mode] => NONSSL

[get] => Array

(

[language] => PL

)

 

=> Array

(

)

 

)

 

)

 

[snapshot] => Array

(

)

 

)

 

[customer_id] => 5

[customer_default_address_id] => 5

[customer_first_name] => Łukasz

[customer_country_id] => 170

[customer_zone_id] => 2639

)


=> news.php

Share this post


Link to post
Share on other sites
here is the code:

The SPPC specific session variables are missing. These are set in login.php (around line 109) so there must be the mistake:

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

Share this post


Link to post
Share on other sites
That is not so strange because the products_id's are missing on a number of links:

<tr><td><a href="http://mishudesigns.com/osc/product_info.php?products_id="><img src="includes/languages/english/images/buttons/button_details.gif" border="0" alt="" width="61" height="18"></a>  <a href="http://mishudesigns.com/osc/products_new.php?action=buy_now&products_id="><img src="includes/languages/english/images/buttons/button_add_to_cart.gif" border="0" alt="" width="78" height="18"></a></td></tr>

True, because the base price is $10 (e.g.) and the attribute price is also $10. So they add up. If you want to show the actual price in the drop-down for the attribute you need to use a contribution (Actual attribute price I think it is called).

 

Thankyou for your reply. I clearly see what you are talking about, but I don't know why it is like that. It is apparant that the problem resides in product_info.php. Here is the file from the site

 

<?php
/*
 $Id: product_info.php,v 1.97 2003/07/01 14:34:54 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 [url=http://www.oscommerce.com]http://www.oscommerce.com[/url]

 Copyright © 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);

//// BOF Actual Price Pull Down v1.2.3a
$new_price ? $original_price = $new_price : $original_price = $product_info['products_price']; //// check if set special price

	$option_price = $products_options['options_values_price'];
	if ($products_options['price_prefix'] == "-") // in case price lowers, don't add values, subtract.
	$show_price = 0.0 + $original_price - $option_price; // force float (in case) using the 0.0;
else if ($products_options['price_prefix'] == "+")
		$show_price = 0.0 + $original_price + $option_price; // force float (in case) using the 0.0;
else
		$show_price = $original_price; // force float (in case) using the 0.0;
//if ($products_options['options_values_price'] != '0')
{
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $currencies->display_price(($products_options[$n]['options_values_price'] + $product_info['products_price']), tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
}
//// EOF Actual Price Pull Down v1.2.3a



 $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
 $product_check = tep_db_fetch_array($product_check_query);
// BOF Separate Pricing per Customer
 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';
 }
// EOF Separate Pricing per Customer
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res
izable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,le
ft=150')
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->

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

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product')); ?>

<?php
 if ($product_check['total'] < 1) {
?>
				<td class="bg15" width="100%" height="30">	   <span class="tx4"><?= TEXT_PRODUCT_NOT_FOUND; ?></span></td>
				<td><?=tep_image(DIR_WS_IMAGES.'m31.gif')?></td></tr>
			<tr><td height="16" colspan="3"></td></tr>
		   </table>
		   <table border="0" cellspacing="0" cellpadding="0" width="100%">
			<tr><td width="100%">

<table cellpadding="0" cellspacing="0" border="0" width="100%">
 <tr>
	<td><table border="0" width="100%" cellspacing="1" cellpadding="2">
	  <tr>
		<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
		  <tr>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
			<td align="right"><?php echo '<a href="' . tep_href_link(FILENAME_DEFAULT) . '">' . tep_image_button('button_continue.gif', IMAGE_BUTTON_CONTINUE) . '</a>'; ?></td>
			<td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
		  </tr>
		</table></td>
	  </tr>
	</table></td>
  </tr>
<?php
 } else {
$product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
$product_info = tep_db_fetch_array($product_info_query);

tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

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

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

if (tep_not_null($product_info['products_model'])) {
  $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
} else {
  $products_name = $product_info['products_name'];
}
?>
				<td class="bg15" width="100%" height="30">	   <span class="tx4"><?php echo $products_name; ?></span></td>
				<td><?=tep_image(DIR_WS_IMAGES.'m31.gif')?></td></tr>
			<tr><td height="16" colspan="3"></td></tr>
		   </table>
		   <table border="0" cellspacing="0" cellpadding="0" width="100%">
			<tr><td width="100%">

		   <table border="0" cellspacing="0" cellpadding="0" width="100%">
			<tr><td width="100%">
				 <table border="0" cellspacing="0" cellpadding="0" width="100%">
				  <tr><td width="20"><?php echo tep_draw_separator('spacer.gif', '20', '1'); ?></td>
					  <td align="center" valign="top">
<div id="pic"><a class="p1" href="#" onClick="java script:return false"><?php echo('<img src=' . DIR_WS_IMAGES . $product_info['products_image'] . ' width="' . SMALL_IMAGE_WIDTH . '" height="' . SMALL_IMAGE_HEIGHT . '">'); ?><?php echo('<img src=' . DIR_WS_IMAGES . $product_info['products_image'] . ' width="" height="" class="large">'); ?></a></div>
					  </td>
					  <td width="28"><?php echo tep_draw_separator('spacer.gif', '28', '1'); ?></td>
					  <td width="100%" valign="top">
						 <table width="100%" border="0" cellspacing="0" cellpadding="0">
						  <tr><td><?php echo stripslashes($product_info['products_description']); ?></td></tr>
						  <tr><td height="6"></td></tr>
						  <tr><td class="tx5"><?=$products_price?></td></tr>
						  <tr><td height="15"></td></tr>
						  <tr><td><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()) . '">' . tep_image_button('button_reviews.gif', IMAGE_BUTTON_REVIEWS) . '</a>'; ?>  <?php echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_add_to_cart.gif', IMAGE_BUTTON_IN_CART); ?></td></tr>
						 </table>
					   </td>
					   <td width="36"><?php echo tep_draw_separator('spacer.gif', '36', '1'); ?></td></tr>
				 </table>
				 <table border="0" cellspacing="0" cellpadding="0" width="100%">
				  <tr><td height="14"></td></tr>
				  <tr><td height="1" width="100%" bgcolor="#A9CD6B"></td></tr>
				  <tr><td height="14"></td></tr>
				 </table>
				</td>
				<td width="21"><?php echo tep_draw_separator('spacer.gif', '21', '1'); ?></td></tr>
		   </table>



<table cellpadding="0" cellspacing="0" border="0" width="100%">
  <tr>
	<td class="main">
<?php
// BOF SPPC Hide attributes from customer groups
$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 ");
$products_attributes = tep_db_fetch_array($products_attributes_query);
if ($products_attributes['total'] > 0) {
?>
	  <table border="0" cellspacing="0" cellpadding="2">
		<tr>
		  <td class="main" colspan="2"><?php echo TEXT_PRODUCT_OPTIONS; ?></td>
		</tr>
<?php
  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
 while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
	$products_options_array = array();
		 $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
	$list_of_prdcts_attributes_id = '';
	$products_options = array(); // makes sure this array is empty again
	while ($_products_options = tep_db_fetch_array($products_options_query)) {
	$products_options[] = $_products_options;
	$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
}

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

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

  for ($n = 0; $n < count($products_options); $n++) {
	  $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
	  if ($products_options[$n]['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}
// EOF SPPC attributes mod


	if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {
	  $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
	} else {
	  $selected_attribute = false;
	}
?>
		<tr>
		  <td class="main"><?php echo $products_options_name['products_options_name'] . ':'; ?></td>
		  <td class="main"><?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?></td>
		</tr>
<?php
  }
?>
	  </table>
<?php
}
?>
	</td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
$reviews_query = tep_db_query("select count(*) as count from " . TABLE_REVIEWS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'");
$reviews = tep_db_fetch_array($reviews_query);
if ($reviews['count'] > 0) {
?>
  <tr>
	<td class="main"><?php echo TEXT_CURRENT_REVIEWS . ' ' . $reviews['count']; ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
}

if (tep_not_null($product_info['products_url'])) {
?>
  <tr>
	<td class="main"><?php echo sprintf(TEXT_MORE_INFORMATION, tep_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product_info['products_url']), 'NONSSL', true, false)); ?></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
}

if ($product_info['products_date_available'] > date('Y-m-d H:i:s')) {
?>
  <tr>
	<td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_AVAILABLE, tep_date_long($product_info['products_date_available'])); ?></td>
  </tr>
<?php
} else {
?>
  <tr>
	<td align="center" class="smallText"><?php echo sprintf(TEXT_DATE_ADDED, tep_date_long($product_info['products_date_added'])); ?></td>
  </tr>
<?php
}
}
?>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
</table></form>
<!-- body_eof //-->

				</td>
				<td width="21"><?php echo tep_draw_separator('spacer.gif', '21', '1'); ?></td></tr>
		   </table>
	  </td></tr>
	 </table>
	</td>
	<td style="background-color:#131516" valign="top" class="bg10"><?=tep_image(DIR_WS_IMAGES.'m23.gif')?></td></tr>
  </table>
 </td></tr>


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

</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

I also added that that add-on mod for the actual price like you mentioned. I am hoping it's this one: http://www.oscommerce.com/community/contri...attribute+price

 

I added it into product_info in the header between the php tags, however it seems that there is more to it because it still adds the 2 prices together for me. If someone can please help me out I would appreciate it. Thanks again for the reply.

Edited by m0dhippy

Share this post


Link to post
Share on other sites
Thankyou for your reply. I clearly see what you are talking about, but I don't know why it is like that. It is apparant that the problem resides in product_info.php. Here is the file from the site

Actually, that is residing in includes/modules/product_listing.php

I also added that that add-on mod for the actual price like you mentioned. I am hoping it's this one: http://www.oscommerce.com/community/contri...attribute+price

 

I added it into product_info in the header between the php tags, however it seems that there is more to it because it still adds the 2 prices together for me. If someone can please help me out I would appreciate it. Thanks again for the reply.

That looks like the one. Will look at it later (have to start on my dinner now :) )

Share this post


Link to post
Share on other sites

I added product attributes option type feature but when I push the button group prices there is an error:

 

Not Found

 

The requested URL /admin/FILENAME_ATTRIBUTES_GROUPS was not found on this server.

 

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Share this post


Link to post
Share on other sites
The requested URL /admin/FILENAME_ATTRIBUTES_GROUPS was not found on this server.

Classical error of not adding that define to admin/includes/filenames.php:

// BOF Separate Pricing Per Customer
 define('FILENAME_ATTRIBUTES_GROUPS', 'attributes_groups.php');
// EOF Separate Pricing Per Customer

Regarding option type feature. I have looked at that once and after cleaning up the awful mess that were the instructions for the class shopping_cart.php (might have improved a bit in the later versions) I never tried to finish it (I think only product_info.php was left). No fun.

Share this post


Link to post
Share on other sites
I also added that that add-on mod for the actual price like you mentioned. I am hoping it's this one: http://www.oscommerce.com/community/contri...attribute+price

 

I added it into product_info in the header between the php tags

Well, that place where you put it will do little. It has to be added much lower, that is for certain.

Share this post


Link to post
Share on other sites

actually almost everything is done, but if using group prices , all prices are round to 1 ,so if I put 1,45 wholesale has 1, if I put 1,79 ,wholesale has round 2. Is it possible to show exact price and not round it ?

Share this post


Link to post
Share on other sites
actually almost everything is done, but if using group prices , all prices are round to 1 ,so if I put 1,45 wholesale has 1, if I put 1,79 ,wholesale has round 2. Is it possible to show exact price and not round it ?

SPPC does nothing special in that respect so I suspect you will have the same problem with regular prices.

Share this post


Link to post
Share on other sites
Well, that place where you put it will do little. It has to be added much lower, that is for certain.

Do you know where, I tried putting it above this: Line 202

   for ($n = 0; $n < count($products_options); $n++) {
	  $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
	  if ($products_options[$n]['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
	}

 

and here is my product_listing.php file. Thank you so much for your time with my help and everyone elses. I really appreciate it Jan.

<?php
/*
 $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2003 osCommerce
 Released under the GNU General Public License
*/
$new_products=array();
$new_p_id=array();
?>
<script language="javascript"><!--
function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res
izable=yes,copyhistory=no,width=290,height=290,screenX=290,screenY=290,top=150,le
ft=150');
}
//--></script>
		   <table border="0" cellspacing="0" cellpadding="0" width="100%">
			<tr><td><?=tep_image(DIR_WS_IMAGES.'m30.gif')?></td>
				<td class="bg15" width="100%" height="30">       <span class="tx4"><?=$breadcrumb->trail(' » ')?></span></td>
				<td><?=tep_image(DIR_WS_IMAGES.'m31.gif')?></td></tr>
			<tr><td height="16" colspan="3"></td></tr>
		   </table>
		   <table border="0" cellspacing="0" cellpadding="0" width="100%">
			<tr><td width="100%">

<?
 $listing_split = new splitPageResults($listing_sql, /*MAX_DISPLAY_SEARCH_RESULTS*/100, 'p.products_id');
 if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }
 $list_box_contents = array();
 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
switch ($column_list[$col]) {
  case 'PRODUCT_LIST_MODEL':
	$lc_text = TABLE_HEADING_MODEL;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_NAME':
	$lc_text = TABLE_HEADING_PRODUCTS;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_MANUFACTURER':
	$lc_text = TABLE_HEADING_MANUFACTURER;
	$lc_align = '';
	break;
  case 'PRODUCT_LIST_PRICE':
	$lc_text = TABLE_HEADING_PRICE;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_QUANTITY':
	$lc_text = TABLE_HEADING_QUANTITY;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_WEIGHT':
	$lc_text = TABLE_HEADING_WEIGHT;
	$lc_align = 'right';
	break;
  case 'PRODUCT_LIST_IMAGE':
	$lc_text = TABLE_HEADING_IMAGE;
	$lc_align = 'center';
	break;
  case 'PRODUCT_LIST_BUY_NOW':
	$lc_text = TABLE_HEADING_BUY_NOW;
	$lc_align = 'center';
	break;
}
if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
}
$list_box_contents[0][] = array('align' => $lc_align,
								'params' => 'class="productListing-heading"',
								'text' => ' ' . $lc_text . ' ');
 }
if ($listing_split->number_of_rows > 0) {

$rows = 0;
$listing_query = tep_db_query($listing_split->sql_query);
// BOF Separate Pricing per Customer
$no_of_listings = tep_db_num_rows($listing_query);
// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

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

while ($_listing = tep_db_fetch_array($listing_query)) {
$listing[] = $_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>';
*/

// 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 from " . TABLE_PRODUCTS_GROUPS . " pg where products_id in (" . implode(',', $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']);
}
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'];
		  }
	  }
	} // 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 products_id in (" . implode(',', $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';

		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'])) . ' ';
		}
		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> '; // EOF Separate Pricing per Customer

		break;
	}
	$list_box_contents[$cur_row][] = array('align' => $lc_align,'params' => 'class="productListing-data"','text'  => $lc_text);
	$product_contents[] = $lc_text;
  }
  $product_query = tep_db_query("select products_description, products_id from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$listing['products_id'] . "' and language_id = '" . (int)$languages_id . "'");
  $product = tep_db_fetch_array($product_query);

  array_push($new_products,$product['products_description']);
  array_push($new_p_id,$product['products_id']);
}
?>



<?
$col=0;
$row=0;
for ($i=1;$i<count($list_box_contents);$i++) {
	$j=$list_box_contents[$i];
if ($row!=0) echo '
				 <table border="0" cellspacing="0" cellpadding="0" width="100%">
				  <tr><td height="14"></td></tr>
				  <tr><td height="1" width="100%" bgcolor="#A9CD6B"></td></tr>
				  <tr><td height="14"></td></tr>
				 </table>';
?>
				 <table border="0" cellspacing="0" cellpadding="0" width="100%">
				  <tr><td width="20"><?php echo tep_draw_separator('spacer.gif', '20', '1'); ?></td>
					  <td align="center" valign="top"><?=$j[0][text]?></td>
					  <td width="28"><?php echo tep_draw_separator('spacer.gif', '28', '1'); ?></td>
					  <td width="100%" valign="top">
						 <table width="100%" border="0" cellspacing="0" cellpadding="0">
						  <tr><td><?=$j[1][text]?></td></tr>
						  <tr><td height="11"></td></tr>
						  <tr><td><?=preg_replace('/\s\S*$/i', '', substr($new_products[$i-1], 0, 160))?>...</td></tr>
						  <tr><td height="6"></td></tr>
						  <tr><td class="tx5"><?=$j[2][text]?></td></tr>
						  <tr><td height="17"></td></tr>
						  <tr><td><a href="<?=tep_href_link('product_info.php?products_id='.$new_p_id[$i-1])?>"><?=tep_image_button("button_details.gif");?></a>  <a href="<?= tep_href_link("products_new.php","action=buy_now&products_id=".$new_p_id[$i-1])?>"><?=tep_image_button("button_add_to_cart.gif");?></a></td></tr>
						 </table>
					   </td>
					   <td width="36"><?php echo tep_draw_separator('spacer.gif', '36', '1'); ?></td></tr>
				 </table>
<?
$row++;
}
/*	new productListingBox($list_box_contents);  */
 } else {
$list_box_contents = array();
$list_box_contents[0] = array('params' => 'class="productListing-odd"');
$list_box_contents[0][] = array('params' => 'class="productListing-data"');
//	new productListingBox($list_box_contents);
 }
 if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
<td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }
?>

				</td>
				<td width="21"><?php echo tep_draw_separator('spacer.gif', '21', '1'); ?></td></tr>
		   </table>

Share this post


Link to post
Share on other sites

Hello Jan,

 

I am trying to solve an Easy Populate issue, and trying to understand the database layout between SPPC and SPPC with Quantity Price Breaks. I hope I explain my issue well enough for you to understand.

 

Site with just SPPC installed, customers_groups are as of follow,

0=Retail

1=Dealer

2=Distributor

 

And in products_groups table I see products_id associated with

group1 ($12.00)

group2 ($10.00)

 

and I am assuming the retail price is associated with product_price in table Products which is $20.00....

 

Where I am a little confused and I think where the issue is with Easy Populate association. This site is identical but has SPPC and Quantity Price Breaks and as of follow,

0=Retail

1=Dealer

2=Distributor

 

But, here the association in products_groups I do not understand. It is showing,

group0 ($0.00)

group1 ($12.00)

group2 ($10.00)

 

Where is it getting $0.00 for customers_group_price? In the top example, there is no group0 in products_groups?

 

Thanks JR

Share this post


Link to post
Share on other sites

Hello,

I ais managed to create tables, only now on the shop I ais this error message:

1054 - Champ 'customers_group_id' unknow in where clause

 

select products_id, specials_new_products_price from specials where (products_id = '1' or products_id = '2' ) and status = '1' and customers_group_id = '0'

and in the admin:

1146 - the table 'casierbois.table_customers_groups' do not exist

 

select customers_group_name from TABLE_CUSTOMERS_GROUPS where customers_group_id = '0'

How I can adjust it that makes several days for which I look

 

Thanks

Share this post


Link to post
Share on other sites

I'm setting up my osCommerce and in the final step I have run in to a problem regarding SPPC combined with PWA.

 

In my settings for SPPC i have two Customer groups:

"Not trusted" and "Trusted"

 

Where the group "Trusted" are able to pay after delivery

While the Group "Not Trusted" are only able to pay by Credit Card or in advance

 

This works just fine setting the payment modules for the different group.

 

 

But NOW to my problem.

The customers going the PWA way are not effected by this and these customers are able to chose any payment method they like... I would like this customers to be treated like the registered customers of default group "Not trusted"

I have been trying to understand the SPPC part of the file "payment.php" as i think this is where the problem is...

 

PLEASE are someone able to help me. I have been reading like 100 different messages regarding SPPC and PWA but none with information regarding this.

 

I WOULD REALLY APPRECIATE SOME HELPE HERE!

Share this post


Link to post
Share on other sites
and here is my product_listing.php file.

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

  array_push($new_products,$product['products_description']);
  array_push($new_p_id,$product['products_id']);
}

You go wrong in this part above. There is no $listing['products_id'] there. Actually, the smart thing would be to add that query above, say after the query for specials and use the list of products_id to query the table products_description for all products only once (instead of doing it for every single product) and add those to the array $listing in the same manner as group prices and special prices.

Share this post


Link to post
Share on other sites

JR,

But, here the association in products_groups I do not understand. It is showing,

group0 ($0.00)

group1 ($12.00)

group2 ($10.00)

 

Where is it getting $0.00 for customers_group_price? In the top example, there is no group0 in products_groups?

That is right, there is no place for retail price in the table products_groups. I have no experience with EP though, so I don't know what is wrong with the code.

Share this post


Link to post
Share on other sites
Hello,

I ais managed to create tables, only now on the shop I ais this error message:

Strange, because in the file sppc_v42_install.sql the column customers_group_id is added as one of the first things:

ALTER TABLE `specials`
ADD customers_group_id smallint UNSIGNED NOT NULL default '0';

 

and in the admin:

 

select customers_group_name from TABLE_CUSTOMERS_GROUPS where customers_group_id = '0'

You didn't add the define for the table customers_groups to the file admin/includes/database_tables.php

Share this post


Link to post
Share on other sites
In my settings for SPPC i have two Customer groups:

"Not trusted" and "Trusted"

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×