Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

hi all - relatively new to the forum, and to oscommerce in general. working on a new site with a template installed, so trying to get through the manual SPPC install (which, surprisingly, has been much easier than i anticipated - thanks JanZ!). however, due to the template, there are two files that are modified so heavily that i can't readily incorporate the contribution.

 

catalog\includes\modules\new_products.php

catalog\includes\modules\product_listing.php

 

if anyone would be willing to offer some advice, it would be much appreciated. please advise if i should post the content of these files, as they are quite large. i can email or PM if more appropriate. would love to get this up and running, as most of my vendors have minimum advertised pricing for retail customers, and SPPC is definitely going to be required for a successful shop.

 

thanks in advance.

Link to comment
Share on other sites

Oh - this now brings me back to a SPPC feature I need to have with the shipping.

 

In the Order Total section in Admin there is a Shipping option where you choose to show the shipping and whether or not to offer free shipping based on the order total. We need to be able to offer free shipping within one zone for retail orders equal to or more than $150 and on wholesale orders equal to or more than $200.

 

How would you set that up?

I wouldn't know really. The standard osC one is in admin->modules->order-total->shipping where you can set an amount and either have that for orders national, international or both. I guess it wouldn't be hard to set it up using the constant MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER and tag the customer group id on it (so MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER0 and MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER1). Look at how that was done for minimum order amount (mentioned in the thread not long ago). However, that does not take into account any zones (apart from national versus international).

 

Check the contributions. Perhaps you can adapt something like Free Shipping w/ Minimum Amount (there might be other modules too) to your needs.

Link to comment
Share on other sites

hi all - relatively new to the forum, and to oscommerce in general. working on a new site with a template installed, so trying to get through the manual SPPC install (which, surprisingly, has been much easier than i anticipated - thanks JanZ!)
That was Marvin's work really!
however, due to the template, there are two files that are modified so heavily that i can't readily incorporate the contribution.

 

catalog\includes\modules\new_products.php

catalog\includes\modules\product_listing.php

From the few I have seen so far the basics still apply. A query is done and then in while loop each product is displayed. For example in product_listing.php:

while ($listing = tep_db_fetch_array($listing_query))

In SPPC the while is still done, but it stores the results in an array and adds all the product id's to a list. Once all the product id's are fetched, the customer group and special prices for the group are queried and then using a double loop after both customer group and special prices have been obtained the prices in the array stored during the while loop are exchanged.

Then instead of using the while ($listing = tep_db_fetch_array($listing_query)) a foreach is used to step through the array. It only takes minor modifications mostly to use the templated ones. Change $listing['database_field'] to $listing[$x]['database_field'] and that usually does it.

Link to comment
Share on other sites

Hi All!

 

I think I need help from someone who knows his/her way around SPPC and SQL...

Here's why:

I have just created my sixth customer group (ID6) and it will (to 98%) be the same as customer group 1 (ID1).

 

First: There must be some smart SQL command to run from phpMyAdmin that copies whatever is in the price field for customer group 1 to the price field for customer group 6. How do you do that?

 

Second: Would it be possible to design some smart command that would check the products_hide_from_groups field and if that contains a '1' add a ',6' to the end of the string?

 

//Micke

Link to comment
Share on other sites

First: There must be some smart SQL command to run from phpMyAdmin that copies whatever is in the price field for customer group 1 to the price field for customer group 6. How do you do that?
First you backup the database, or just the table products_groups and then try:

insert into products_group select '6' as customers_group_id, customers_group_price, products_id from products_groups where customers_group_id = '1';

If it not right, use the backup :)

Better yet, try it on your local server.

Link to comment
Share on other sites

Second: Would it be possible to design some smart command that would check the products_hide_from_groups field and if that contains a '1' add a ',6' to the end of the string?
I think I would solve that by first finding out what the different strings are that have '1' in it. Something along the line select distinct products_hide_from_groups like products_hide_from_groups '%,1%' from products;. Then make a list of all of those and then update them one by one by adding ,6 to the end of the string.

 

So say a string is @,1,3,5:

update products set products_hide_from_groups = '@,1,3,5,6' where products_hide_from_groups = '@,1,3,5';

Link to comment
Share on other sites

First you backup the database, or just the table products_groups and then try:

insert into products_group select '6' as customers_group_id, customers_group_price, products_id from products_groups where customers_group_id = '1';

If it not right, use the backup :)

Better yet, try it on your local server.

Thanks JanZ!

Worked like a charm!

(I had to add an 's' to 'products_group', that's all...)

The 'hide stunt' will have to wait until tomorrow... (if I can wait...)

Thanks again!

//Micke

Link to comment
Share on other sites

Would someone be willing to help me to learn how to create custom code to do this? :blush:

 

I have one product (product ID 46) that is $3.00 unless the customer purchases any or all of the following product ID's - 44, 47, 58, 53, 42, 121, 79 or 105 - then product ID 46 is Free.

 

Any idea how to implement that? :huh: This is for both customer groups.

~Tracy
 

Link to comment
Share on other sites

That was Marvin's work really!

From the few I have seen so far the basics still apply. A query is done and then in while loop each product is displayed. For example in product_listing.php:

while ($listing = tep_db_fetch_array($listing_query))

In SPPC the while is still done, but it stores the results in an array and adds all the product id's to a list. Once all the product id's are fetched, the customer group and special prices for the group are queried and then using a double loop after both customer group and special prices have been obtained the prices in the array stored during the while loop are exchanged.

Then instead of using the while ($listing = tep_db_fetch_array($listing_query)) a foreach is used to step through the array. It only takes minor modifications mostly to use the templated ones. Change $listing['database_field'] to $listing[$x]['database_field'] and that usually does it.

thanks for the reply, JanZ - but you make it sound so easy! unfortunately, i'm no where near as good a programmer. i've tried customizing the code, but to no avail. i can get the pricing to work, but it changes the format and ruins the page layout.

 

i've posted the two problem files in un-altered form to our current site. (you can see why we need to update!! :blush: ) if anyone has some time, please help me out. at this point, i'm desperate. willing to pay an hourly rate, if necessary.

 

new_products.php

product_listing.php

 

thanks again.

Link to comment
Share on other sites

at this point, i'm desperate
I looked (and shivered) at the new_products.php one but it could be fixed exactly as I described. Since that code is terribly inefficient because for each product it does two additional queries for the products name and a separate one for the products description >_< I show the code here:

<?php
/*
 edited - 2005/07/01 13:50

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

 $Id: new_products.php,v 1.34 2003/06/09 22:49:58 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 //-->
<?php

 if ( (!isset($new_products_category_id)) || ($new_products_category_id == '0') ) {
// BOF Separate Pricing Per Customer
$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name, LEFT(pd.products_description, 26) as products_description from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where products_status = '1' and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
 } else {
$new_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, p.products_price, pd.products_name, LEFT(pd.products_description, 26) as products_description from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c using(products_id) left join " . TABLE_CATEGORIES . " c using(categories_id) where p.products_id = pd.products_id and c.parent_id = '" . (int)$new_products_category_id . "' and p.products_status = '1' and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added desc limit ". MAX_DISPLAY_NEW_PRODUCTS);
 }

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

 if (($no_of_new_products = tep_db_num_rows($new_products_query)) > 0) {
  while ($_new_products = tep_db_fetch_array($new_products_query)) {
$new_products[] = $_new_products;
$list_of_prdct_ids[] = $_new_products['products_id'];
}

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

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

// an extra query is needed for all the specials
$specials_query = tep_db_query("select products_id, specials_new_products_price from " . 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'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
}

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

 $row = 0;
 $col = 0;

// why these template makers can't be bothered to put quotes around the attributes like cellspacing="0" amazes me
 echo '

<table cellspacing="0" cellpadding="0" width="437" align="center">
 <tr><td background="images/m22.gif" width="437" height="29" valign="top">
	 <table cellspacing=0 cellpadding=0>
	  <tr><td height=8></td></tr>
	  <tr><td width=25></td><td class=ch6>featured products</td></tr>
	 </table>
	</td></tr>
  <tr><td valign=top class=ch7>

	   <table cellspacing=0 cellpadding=0 width=417 border=0 align=center>
		 <tr><td height=13></td></tr>
		 <tr>


   ';


//  while ($new_products = tep_db_fetch_array($new_products_query)) {
for ($x = 0; $x < $no_of_new_products; $x++) {
// getting products_name and the first 25 characters of the products_description added to 
// the $new_products_query above so we can skip these two queries for each product
/*   $new_products['products_name'] = tep_get_products_name($new_products['products_id']);
  $product_query = tep_db_query("select products_description  from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$new_products['products_id'] . "' and language_id = '" . (int)1 . "'");
  $product = tep_db_fetch_array($product_query);
  $new_products['products_description'] = $product['products_description']; */
  echo '

		 <td width=208 valign=top align=center>
		   <table cellspacing=0 cellpadding=0 width=200 align=center>
			<tr><td width=90 align=center valign=top><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $new_products[$x]['products_image'], $new_products[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'vspace=0') . '</a></td>
			<td valign=top>
			  <table cellspacing=0 cellpadding=0>
			   <tr><td><a height=35 valign=middle   class=ch9 href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products[$x]['products_id']) . '">' . $new_products[$x]['products_name'] . '</a></td></tr>

			   <tr><td class=ch10 height=35 valign=middle>'.preg_replace('/\s\S*$/i', '', substr($new_products[$x]['products_description'], 0, 25)).' ...</td></tr>
			   <tr><td height=0></td></tr>
			   <tr><td><span class=ch11>price:</span> <span class=ch8>'.$currencies->display_price($new_products[$x]['products_price'], tep_get_tax_rate($new_products[$x]['products_tax_class_id'])).'</span> </td></tr>
			  </table>
			 </td>
			</tr>
			<tr><td height=20></td></tr>
			<tr><td colspan=2 align=right><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products[$x]['products_id']) . '">' . tep_image_button('small_view.gif') . '</a><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $new_products[$x]['products_id']) . '">' . tep_image_button('button_in_cart.gif') . '</a>   </td></tr>
		  </table>
		 </td>


	';

$col ++;
if ($col > 1) {
  $col = 0;
  $row ++;
  echo '

		 </tr>
		 <tr><td height=5></td></tr>
		  <tr><td colspan=3 valign=top>
		   <table cellspacing=0 cellpadding=0>
			<tr><td width=200 height=1 background=images/m29.gif></td><td width=14></td> <td width=200 height=1 background=images/m29.gif></td></tr>
		   </table>
		  </td></tr>
		  <tr><td height=5></td></tr>
		  <tr>


	   ';
} else echo '<td background=images/m09.gif width=1></td>';
 } // end for ($x = 0; $x < $no_of_new_products; $x++)


 echo '

					 </tr>
					</table> 

	 </td></tr>
	<tr><td><img src=images/m30.gif width=438 height=7></td></tr>
   </table>

   ';


?>
<!-- new_products_eof //-->

Link to comment
Share on other sites

product_listing.php
That shouldn't even be less of a problem. You can almost exactly use the instructions. Almost.

Since you can avoid making a query for each product again since we already know what the products_id's are on that listing you could try changing the

   $listing_query = tep_db_query($listing_split->sql_query);
while ($listing = tep_db_fetch_array($listing_query)) {
  $product_contents = array();
  $rows++;

and all the code after that to:

	$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(!tep_session_is_registered('sppc_customer_group_id')) {
 $customer_group_id = '0';
 } else {
  $customer_group_id = $sppc_customer_group_id;
 }

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>';
*/
 $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]."' ";
  }
}

$product_description_query = tep_db_query("select products_id, products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where (".$select_list_of_prdct_ids.") and language_id = '1'");

while ($p_description = tep_db_fetch_array($product_description_query)) {
 for ($x = 0; $x < $no_of_listings; $x++) {
// add product_description
		if( $listing[$x]['products_id'] == $p_description['products_id'] ) {
	$listing[$x]['products_description'] = $p_description['products_description'];
	}
 } // end for ($x = 0; $x < $no_of_listings; $x++)
} // end while ($p_description =  etc.

// 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 (".$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']);
}
  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 (".$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++) {
  $product_contents = array();
  $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 class=ch9 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 class=ch9 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 = '<span class=ch8 style="color:#7F7F7F;font-size:11px"><s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s></span><br>         <span class=ch8>' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span>';
		} else {
		  $lc_text = '<span class=ch8>' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span>';
		}	   
		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;
	}

	$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  from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$listing['products_id'] . "' and language_id = '" . (int)1 . "'");
  $product = tep_db_fetch_array($product_query);
  $new_products['products_description'] = $product['products_description']; */

  echo '

		 <td width=208 valign=top align=center>
		   <table cellspacing=0 cellpadding=0 width=200 align=center>
			<tr><td width=90 align=center valign=top>'.$product_contents[0].'</td>
			<td valign=top>
			  <table cellspacing=0 border=0  cellpadding=0>
			   <tr><td height=55 valign=middle>'.$product_contents[1].'</td></tr>

			   <tr><td height=30 valign=middle  class=ch10>'.preg_replace('/\s\S*$/i', '', substr($listing[$x]['products_description'], 0, 25)).' ...</td></tr>
			   <tr><td height=0></td></tr>
			   <tr><td height=35 valign=middle><span  class=ch11>price:</span> <span class=ch8>'.$product_contents[2].'</span> </td></tr>
			  </table>
			 </td>
			</tr>
			<tr><td height=2></td></tr>
			<tr><td colspan=2 align=right><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('small_view.gif') . '</a><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_in_cart.gif') . '</a>   </td></tr>
		  </table>
		 </td>



  ';
  $column ++;
  if ($column >= 2) {
	$rows ++;
	$column = 0;
	echo '

		 </tr>
		 <tr><td height=5></td></tr>
		  <tr><td colspan=3 valign=top>
		   <table cellspacing=0 cellpadding=0>
			<tr><td width=200 height=1 background=images/m29.gif></td><td width=14></td> <td width=200 height=1 background=images/m29.gif></td></tr>
		   </table>
		  </td></tr>
		  <tr><td height=5></td></tr>
		  <tr>


		 ';
  } else echo '<td background=images/m09.gif width=1></td>';



}

echo '

				 </tr>					
		  </table>
	 </td></tr>
	<tr><td><img src=images/m30.gif width=438 height=7></td></tr>
   </table>


	 ';

//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"',
							   'text' => TEXT_NO_PRODUCTS);

echo '<div class=PageHeading>Categories</div>';
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 height=20></td></tr>
 <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
 }
?>

Link to comment
Share on other sites

omg - thank you so much JanZ! you're a genius...and a life-saver!! and thanks for fixing the redundant code. guess the template-makers know that the purchasers are pretty much newbies and really won't know any better, so it's easy for them to abuse.

 

really, can't thank you enough for the support. thanks again.

Link to comment
Share on other sites

I have one product (product ID 46) that is $3.00 unless the customer purchases any or all of the following product ID's - 44, 47, 58, 53, 42, 121, 79 or 105 - then product ID 46 is Free.

 

Any idea how to implement that? :huh: This is for both customer groups.

I don't think anybody has written a contribution for this yet. I think you need to at least add code to the functions calculate and get_products in includes/classes/shopping_cart.php. You could put those products ID's in an array and then in the beginning of these functions see if $this->contents and that array of product ID's have one in common. If so set a variable you already declared to be zero to 1 and then when the price is queried check the product id first, if it is 46 then product_price is zero.

 

Hopefully, that will be enough to cover everything.

Link to comment
Share on other sites

I wouldn't know really. The standard osC one is in admin->modules->order-total->shipping where you can set an amount and either have that for orders national, international or both. I guess it wouldn't be hard to set it up using the constant MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER and tag the customer group id on it (so MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER0 and MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER1). Look at how that was done for minimum order amount (mentioned in the thread not long ago). However, that does not take into account any zones (apart from national versus international).

 

Check the contributions. Perhaps you can adapt something like Free Shipping w/ Minimum Amount (there might be other modules too) to your needs.

 

Ugh - I've been trying to figure this one out all morning and I'm just not getting anywhere >_<

 

The code for the Free Shipping with Minimum Amount is thankfully only one file that would need adjusting to allow for two customer groups each with their own Minimum Amount.

 

Right now I'm just trying to get it so that it only works for one customer group just to see where in this darn thing I need to be editing the code. But so far it either doesn't work for either group - or it works for both groups - no matter where I put the $customer_group_id == '1' &&

 

This is the code:

class freeamount {
var $code, $title, $description, $icon, $enabled;

// class constructor
function freeamount() {
  global $order, $customer;

  $this->code = 'freeamount';
  $this->title = MODULE_SHIPPING_FREEAMOUNT_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_FREEAMOUNT_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_SHIPPING_FREEAMOUNT_SORT_ORDER;
  $this->icon ='';
  $this->enabled = ((MODULE_SHIPPING_FREEAMOUNT_STATUS == 'True') ? true : false);

  if ( ($this->enabled == true) && ((int)MODULE_SHIPPING_FREEAMOUNT_ZONE > 0) ) {

	$check_flag = false;
	$check_query = tep_db_query("select zone_id, zone_country_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_SHIPPING_FREEAMOUNT_ZONE . "' and zone_country_id = '" . $order->delivery['country']['id'] . "' order by zone_id");
	$order_shipping_country = $order->delivery['country']['id'];

	while ($check = tep_db_fetch_array($check_query)) {

	  if ($check['zone_id'] < 1) {
		$check_flag = true;
		break;
//		  } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
	  } elseif ($check['zone_country_id'] == $order->delivery['country']['id']) {
		$check_flag = true;
		break;
	  }
	}
	if ($check_flag == false) {
	  $this->enabled = false;
	}
 }
}

// class methods
function quote($method = '') {
  global $order, $cart, $shipping_weight;

  $dest_country = $order->delivery['country']['id'];
  $currency = $order->info['currency'];
  $get_total = false;
  $get_weight = false;
  $cart_total = $cart->show_total();

	if (MODULE_SHIPPING_FREEAMOUNT_HIDE_SPECIALS == 'True') {
	  // 28-9-2005 Check for articles on special which should not get free shipment
	  // Adjust the cart total price for this
	  $total_specials = 0;
	  if ($cart->count_contents() > 0) {
		 $products = $cart->get_products();
		 for ($i=0, $n=sizeof($products); $i<$n; $i++) {
			if ($special_price = tep_get_products_special_price($products[$i]['id'])) {
			   $products_price = $special_price;
			   $total_specials += $products_price;
			}
		 }
	  }

	  $cart_total = $cart_total - $total_specials;
	}

  if ($cart_total < MODULE_SHIPPING_FREEAMOUNT_AMOUNT)
  {
	if (MODULE_SHIPPING_FREEAMOUNT_DISPLAY == 'True')
	   {
		$this->quotes['error'] = MODULE_SHIPPING_FREEAMOUNT_TEXT_ERROR;
	   }
	$get_total = false;
   } else {
	$get_total = true;
   }

  if ($shipping_weight > MODULE_SHIPPING_FREEAMOUNT_WEIGHT_MAX)
	  {
		if (MODULE_SHIPPING_FREEAMOUNT_DISPLAY == 'True')
		   {
			  $this->quotes['error'] = MODULE_SHIPPING_FREEAMOUNT_TEXT_TO_HEIGHT;
		   }
		$get_weight = false;
  } else {
   $get_weight = true;
  }

if (($get_total == true && $get_weight == true))
{
	$this->quotes = array('id' => $this->code,
							'module' => MODULE_SHIPPING_FREEAMOUNT_TEXT_TITLE,
							'methods' => array(array('id' => $this->code,
							'title' => MODULE_SHIPPING_FREEAMOUNT_TEXT_WAY,
							'cost' => MODULE_SHIPPING_FREEAMOUNT_COST)));
}


  if (tep_not_null($this->icon)) $this->quotes['icon'] = tep_image($this->icon, $this->title);

  return $this->quotes;

}

function check() {
  if (!isset($this->_check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FREEAMOUNT_STATUS'");
	$this->_check = tep_db_num_rows($check_query);
  }
  return $this->_check;
}

function install() {
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Free Shipping with Minimum Purchase', 'MODULE_SHIPPING_FREEAMOUNT_STATUS', 'True', 'Do you want to offer minimum order free shipping?', '6', '7', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id,  sort_order, date_added) values ('Maximum Weight', 'MODULE_SHIPPING_FREEAMOUNT_WEIGHT_MAX', '10', 'What is the maximum weight you will ship?', '6', '8', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Display', 'MODULE_SHIPPING_FREEAMOUNT_DISPLAY', 'True', 'Do you want to display text way if the minimum amount is not reached?', '6', '7', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id,  sort_order, date_added) values ('Minimum Cost', 'MODULE_SHIPPING_FREEAMOUNT_AMOUNT', '50.00', 'Minimum order amount purchased before shipping is free?', '6', '8', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id,  sort_order, set_function, date_added) values ('Disable for Specials', 'MODULE_SHIPPING_FREEAMOUNT_HIDE_SPECIALS', 'True', 'Do you want to disable free shipping for products on special?', '6', '7', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_SHIPPING_FREEAMOUNT_SORT_ORDER', '0', 'Sort order of display.', '6', '0', now())");
  tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Shipping Zone', 'MODULE_SHIPPING_FREEAMOUNT_ZONE', '0', 'If a zone is selected, only enable this shipping method for that zone.', '6', '0', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
  }

function remove() {
  tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}

  function keys() {
 $keys = array(
	   'MODULE_SHIPPING_FREEAMOUNT_STATUS',
	   'MODULE_SHIPPING_FREEAMOUNT_WEIGHT_MAX',
	   'MODULE_SHIPPING_FREEAMOUNT_SORT_ORDER',
	   'MODULE_SHIPPING_FREEAMOUNT_DISPLAY',
	   'MODULE_SHIPPING_FREEAMOUNT_HIDE_SPECIALS',
	   'MODULE_SHIPPING_FREEAMOUNT_AMOUNT',
	   'MODULE_SHIPPING_FREEAMOUNT_ZONE'
	   );
 return $keys;
  }
}

 

I added this:

// BOF Separate Price per Customer
if(!tep_session_is_registered('sppc_customer_group_id')) {
$customer_group_id = '0';
} else {
$customer_group_id = $sppc_customer_group_id;
}
// EOF Separate Price per Customer

in the class constructor just above the very first "if" statement.

 

I then tried the $customer_group_id == '1' && line of code to the "if" and "elseif" statements here:

if ($check['zone_id'] < 1) {
		$check_flag = true;
		break;
//		  } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
	  } elseif ($check['zone_country_id'] == $order->delivery['country']['id']) {
		$check_flag = true;
		break;

 

and I also tried it separately in the "if" statement here:

if (($get_total == true && $get_weight == true))

 

I'm obviously missing something - but for the life of me this morning I just can't seem to see what. Any ideas?

~Tracy
 

Link to comment
Share on other sites

Ugh - I've been trying to figure this one out all morning and I'm just not getting anywhere >_<

 

The code for the Free Shipping with Minimum Amount is thankfully only one file that would need adjusting to allow for two customer groups each with their own Minimum Amount.

 

Right now I'm just trying to get it so that it only works for one customer group just to see where in this darn thing I need to be editing the code. But so far it either doesn't work for either group - or it works for both groups - no matter where I put the $customer_group_id == '1' &&

 

I then tried the $customer_group_id == '1' && line of code to the "if" and "elseif" statements here:

if ($check['zone_id'] < 1) {
		$check_flag = true;
		break;
//		  } elseif ($check['zone_id'] == $order->delivery['zone_id']) {
	  } elseif ($check['zone_country_id'] == $order->delivery['country']['id']) {
		$check_flag = true;
		break;

 

and I also tried it separately in the "if" statement here:

if (($get_total == true && $get_weight == true))

 

I'm obviously missing something - but for the life of me this morning I just can't seem to see what. Any ideas?

 

PS - I also tried in the first "if" statement as well.

~Tracy
 

Link to comment
Share on other sites

PS - I also tried in the first "if" statement as well.

 

OMG! Just a heads up to anyone using the Free Shipping with Minimum Amount module - if you remove it and then re-install it the module does NOT remove itself from the database :blink:

 

You need to manually go into your configuration table and look for all MODULE_SHIPPING_FREEAMOUNT* listings and delete them from the table. I just found 3 pages worth in there when trying to find why I couldn't install or remove the module through admin - yet it seemed to be maintaining my old settings :o

~Tracy
 

Link to comment
Share on other sites

OMG! Just a heads up to anyone using the Free Shipping with Minimum Amount module - if you remove it and then re-install it the module does NOT remove itself from the database :blink:

 

You need to manually go into your configuration table and look for all MODULE_SHIPPING_FREEAMOUNT* listings and delete them from the table. I just found 3 pages worth in there when trying to find why I couldn't install or remove the module through admin - yet it seemed to be maintaining my old settings :o

 

Oops :blush: Must've been from something I edited as I just installed it and removed it and this time it did remove from the database. Apparently we don't want the $customer_group_id == '1' && in the

function check() {
  if (!isset($this->_check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FREEAMOUNT_STATUS'");
	$this->_check = tep_db_num_rows($check_query);
  }
  return $this->_check;
}

if statement :blush:

~Tracy
 

Link to comment
Share on other sites

PS - I also tried in the first "if" statement as well.

 

Ok - I just added

$customer_group_id != '1' &&

to every "if" and "elseif" statement in the whole php file except for these two bits of code:

function check() {
  if (!isset($this->_check)) {
	$check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_SHIPPING_FREEAMOUNT_STATUS'");
	$this->_check = tep_db_num_rows($check_query);
  }
  return $this->_check;
}

and

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

 

And it still shows the free shipping info for both customer groups :blink:

~Tracy
 

Link to comment
Share on other sites

And it still shows the free shipping info for both customer groups
My guess is that $sppc_customer_group_id is not recognized as a global inside the class.

 

Why don't you circumvent that and make $customer_group_id a class variable ($this->cg_id). Then it will be available inside all the functions too. Less headaches :)

// class constructor
function freeamount() {
  global $order, $customer;

 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
 $this->ccg_id = $_SESSION['sppc_customer_group_id'];
 } else {
  $this->cg_id = '0';
 }

Link to comment
Share on other sites

My guess is that $sppc_customer_group_id is not recognized as a global inside the class.

 

Why don't you circumvent that and make $customer_group_id a class variable ($this->cg_id). Then it will be available inside all the functions too. Less headaches :)

// class constructor
function freeamount() {
  global $order, $customer;

 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
 $this->ccg_id = $_SESSION['sppc_customer_group_id'];
 } else {
  $this->cg_id = '0';
 }

 

Thank you very much for your reply! I am sure this is due to my lack of PHP understanding - but here is what I did - I changed the very beginning of the document to:

 

// class constructor
function freeamount() {
  global $order, $customer;
  if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
  $this->ccg_id = $_SESSION['sppc_customer_group_id'];
  } else {
 $this->cg_id = '0';
 }
  $this->code = 'freeamount';
  $this->title = MODULE_SHIPPING_FREEAMOUNT_TEXT_TITLE;
  $this->description = MODULE_SHIPPING_FREEAMOUNT_TEXT_DESCRIPTION;
  $this->sort_order = MODULE_SHIPPING_FREEAMOUNT_SORT_ORDER;
  $this->icon ='';
  $this->enabled = ((MODULE_SHIPPING_FREEAMOUNT_STATUS == 'True') ? true : false);

  if ( ($this->enabled == true) && ($this->cg_id != '1') && ((int)MODULE_SHIPPING_FREEAMOUNT_ZONE > 0) ) {

 

Am I using the $this->cg_id incorrectly? As long as I'm using it correctly then I can play around with adding it to other if statements - but since placing it where I did has not changed the outcome any I figured I'd make sure first that I'm using it correctly :blush:

~Tracy
 

Link to comment
Share on other sites

And since the function get_products() got cut off in the post (too long I guess) just that last part (which hasn't changed however).
	function get_products() {

global $languages_id;

// BOF Separate Pricing Per Customer

.................

 

Dear Janz:

 

Greetings fron Spain and sorry for my bad english. I have the same problem that Micke and copied your code on my shoping_cart.php. Now not 1052 error, and accept complete order, but in second session with the same customer return this error: "" [b]Fatal error: Call to undefined function: tep_get_hide_status() in c:\oscommerce\catalog\includes\classes\shopping_cart.php on line 118""

 

Please, you can help me?. I'm not know programmation.

 

Thank you in advance.

Link to comment
Share on other sites

I have the same problem that Micke and copied your code on my shoping_cart.php. Now not 1052 error, and accept complete order, but in second session with the same customer return this error: "" Fatal error: Call to undefined function: tep_get_hide_status() in c:\oscommerce\catalog\includes\classes\shopping_cart.php on line 118""
If you copied all the code from this post into your shopping cart you have a problem because in the function restore_contents there is additional code for the Hide products from customers for SPPC contribution.

 

The only thing that needed to be changed in the SPPP attributes mod is one query in the function add_cart because it wasn't compatible with MySQL4 (but worked fine in MySQL5):

// BOF SPPC attribute hide check, original query expanded to include attributes
	$check_product_query = tep_db_query("select p.products_status, options_id, options_values_id, attributes_hide_from_groups, '0' as hide_attr_status from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_ATTRIBUTES . " using(products_id) where p.products_id = '" . (int)$products_id . "'");

MySQL would complain about products_id being ambiguous in version 4 (because you make a join between the two tables on that products_id it shouldn't make the slightest difference which products_id you take...).

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