Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

I have been searching for hours trying to find a way to add a working quantity box in the product listing pages.

 

I can get it to show the input box, thats easy but when I hit add to cart you either get nothing or you just get one of that item added to the cart.

 

here is my product_listing.php

<?php
/*
 $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $
 adapted for Separate Pricing Per Customer v4 and Price Break 1.11.3 2005/03/12

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, '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, 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';
		if ($listing[$x]['products_quantity'] < 0) {
			$lc_text = ' 0 ';
		} else {
			$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; 
//OLD WORKING _ NEW NOT WORKING
		/*case 'PRODUCT_LIST_BUY_NOW':
		$lc_align = 'center';
		$lc_text = '<form name="cart_quantity" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=add_product&products_id=' . $listing[$x]['products_id']) . '"><input type="hidden" name="products_id" value="' . $listing[$x]['products_id'] . '"><input type="text" name="quantity" value="1" maxlength="3" size="3"><br />' . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</form>';
		break; */
//ORIGINAL
	  /*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_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a> ';
		break;*/
//SHOWS QUANTITY BOX BUT DOESN"T WORK
		case 'PRODUCT_LIST_BUY_NOW':
		$lc_align = 'center';
		if($listing[$x]['products_quantity'] > 0) {
		$lc_text =  "Quantity:" . tep_draw_input_field('cart_quantity', $pf->adjustQty(1), 'size="3" maxlength="3"') . '<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_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a> ';
		} else {
$lc_text = '<span class="stockWarning">This item is out of stock</a>';
}
		break;
	}
// EOF Separate Pricing per Customer, Price Break 1.11.3 modification
	$list_box_contents[$cur_row][] = array('align' => $lc_align,
										   'params' => 'class="productListing-data"',
										   'text'  => $lc_text);
  }
}

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

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
 }
?>

Link to comment
Share on other sites

It sounds like you missed adding the code for QPB to product_info.php (around line 78):

	$pf->loadProduct((int)$HTTP_GET_VARS['products_id'], (int)$languages_id);
$products_price=$pf->getPriceString();

This picks up the quantity price for the customer group and the function getPriceString will show the price break table (a pretty ugly one if you ask me ;) ).

 

Thanks Jan, but I had put that in ? I dont know a hell of a lot about PHP but in QPB it says this .

 

***REPLACE***

 

if ($new_price = tep_get_products_special_price($product_info['products_id'])) {

// BOF Separate Price per Customer

 

$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'];

}

// EOF Separate Price 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 Price per Customer

$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'];

}

// EOF Separate Price per Customer

 

$products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));

}

 

***WITH***

 

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

$pf->loadProductSppc((int)$HTTP_GET_VARS['products_id'], (int)$languages_id, $product_info);

$products_price = $pf->getPriceString();

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

 

 

It seems to me that it has taken out a lot of code to be replaced by not enough ..

Also now neither the SPPC or QPB seem to move thier changes through to the product info.

Link to comment
Share on other sites

Janz

 

It's 6:30 am Monday morning and I have not been to bed yet. I've been battling with this all night and finally found the solution to my "hide the add to cart button" issue.

 

The code I finally got to on product_info.php is

<td class="main" align="right"><?php if (tep_session_is_registered('customer_id') && $customer_group_id > 0 ){
echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
	  }?></td>

 

rather than the if else statement that kept breaking my page layout. I've tested it and it seems to work, but if I am overlooking a potential problem, please make comment so that others don't use this. It almost seems too simple.

 

Now if I can please pick your brains a little more on the shopping cart workaround. Where must I use the code you posted? shopping_cart.php? - Sorry if I'm being dense but I'm not sure if I am understanding what you have written correctly.

 

Thanks again for the help!

 

 

 

Vivienne,

 

What about:

<td class="main" align="right"><?php if (tep_session_is_registered('customer_id') && $customer_group_id > 0 ){
// only show 'add to card' button to wholesale customers (customer group id higher than 0)
			  echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
 } elseif (tep_session_is_registered('customer_id') && $customer_group_id == '0' ) {
// hide 'add to card' button for retail customers but fill up the space of the button with a 1px gif
// adjust size to what you need or use no-break spaces
 echo tep_draw_separator('pixel_trans.gif', '24', '15');
			  }else{
			  RETURN'Login for price';
			  }?></td>

Be aware that although you hide the buttons you can often (depends a bit on the contributions you have added) still add products to the shopping basket by typing in a url manually. For example http:// theshop.com/index.php?products_id=##&action=buy_now

 

To avoid that (in your case) you could make the shopping cart actions depend on the customer group id.

 

For example wrap them in an if condition:

  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) {
// starts around line 318 in includes/application_top.php
// Shopping cart actions
 if (isset($HTTP_GET_VARS['action'])) {
// redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled
.
.
.

}
 }
} // end if ($customer_group_id > 0)

// include the who's online functions

Link to comment
Share on other sites

;) :lol:

This picks up the quantity price for the customer group and the function getPriceString will show the price break table (a pretty ugly one if you ask me ;) ).

 

Hi Jan .. Is ok now .. I found the piece of code that was messing things up.

 

:lol: I see what you mean about the break table being a bit ugly ;) .. How hard is it to make it look a bit better ?

 

Here is my site if you want to take a look www.tocs.com.au.

We are still working on it so be kind :lol:

I have -> Audio -> Headsets -> Logitech Premium USB Headset 350 set up with price breaks at this time.

 

If there is something you can do to make the break table suite my site better please let me know.

Also what cost might be involed - remember I am in Australia so our $ isnt worth as much as yours, assuming you are in the USA. :blush:

 

Please let me know what, if anything you can do .. Thankyou.

 

Ross.

Link to comment
Share on other sites

hi JanZ,

 

You won't find an answer because this is a basic PHP error. You doubled up code. This is what that area (starting from around line 79) should look like:

<?php
if (isset($cPath) && strpos('_', $cPath)) {
// check to see if there are deeper categories within the current category
$category_links = array_reverse($cPath_array);
for($i=0, $n=sizeof($category_links); $i<$n; $i++) {
$categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', categories_hide_from_groups) = 0");
$categories = tep_db_fetch_array($categories_query);
if ($categories['total'] < 1) {
// do nothing, go through the loop
} else {
$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name");
break; // we've found the deepest category the customer is in
}
} 
} else {
// ################## End Added Enable Disable Categorie #################
// $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' order by sort_order, cd.categories_name");
$categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.categories_image, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_status = '1' and c.parent_id = '" . (int)$current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', categories_hide_from_groups) = 0 order by sort_order, cd.categories_name");
// ################## End Added Enable Disable Categorie #################
// EOF Hide categories from groups
}

$number_of_categories = tep_db_num_rows($categories_query);

Basically I think you can follow "Enable Disable Categorie" but use find_in_set('".$customer_group_id."', categories_hide_from_groups) = 0 instead of c.categories_status = '1'

 

i have make everything what you have said and know i have 2 problems

 

1. the articel's which i had till know in my shop are hidden.. they are hidden for every kind of customer.. (retail und end-consumer)

2. i only can say that a categorie should be hidden or not.. when i say hidden, then he don't show it me.. and it doesn't matter if i login as a retail or end-consumer customer

 

what can / must i do,...

.....that he show my article which i addet in the last days / weeks in my shop..

.....that i can say that a article (not categorie) just where hidden for retail...

 

because i have a lot of article which aren't for end-sonsumer..

 

i have installed first the "Enable Disable Categorie" contribution and then make the changes in the code that you have said.

 

thank you a lot for your help... i don't know what to do.. i have a shop without article.. and it takes to much time to add all the article new in the shop.

 

greetz

tali

Link to comment
Share on other sites

Hi!

 

Once logged in I tested to buy products and to take them through the checkout process. Everything worked out as it should as far as I can see.

 

What I forgot to do, was to buy products and then logout and login again to complete the order. Now I've done that and the items that I bought before I logged out doesn't appear anymore. The image of the product is now gone, there's only a "place holder", no text appear and the Sub-Total shows only: 0.00. The only thing that shows up correct is the quantity.

 

I would appreciate help in finding the file(s) I have to look into, or even better which part(s) of the code that are responsible here.

 

I hope I don't have to roll back everything because I really want to have SPPC :)

Link to comment
Share on other sites

I tried your code and it's doing the same thing - it hides the button but it also makes my entire right hand column totally disappear from the page - the middle content stretches across as if there never was a column on the right. Logically it makes no sense that this snippet of code is changing my entire page layout though. If you have any other ideas I would be really thankful
The RETURN'Login for price' seems odd. Try this:

<td class="main" align="right"><?php if (tep_session_is_registered('customer_id') && $customer_group_id > 0 ){
// only show 'add to card' button to wholesale customers (customer group id higher than 0)
			  echo tep_draw_hidden_field('products_id', $product_info['products_id']) . tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART);
 } elseif (tep_session_is_registered('customer_id') && $customer_group_id == '0' ) {
// hide 'add to card' button for retail customers but fill up the space of the button with a 1px gif
// adjust size to what you need or use no-break spaces
 echo tep_draw_separator('pixel_trans.gif', '24', '15');
			  } else {
			   echo 'Login for price';
			  } ?></td>

Link to comment
Share on other sites

I have been searching for hours trying to find a way to add a working quantity box in the product listing pages.

 

I can get it to show the input box, thats easy but when I hit add to cart you either get nothing or you just get one of that item added to the cart.

//SHOWS QUANTITY BOX BUT DOESN"T WORK
		case 'PRODUCT_LIST_BUY_NOW':
		$lc_align = 'center';
		if($listing[$x]['products_quantity'] > 0) {
		$lc_text =  "Quantity:" . tep_draw_input_field('cart_quantity', $pf->adjustQty(1), 'size="3" maxlength="3"') . '<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_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a> ';

I don't think I have seen this one before, with the $pf->adjustQty(1) but did you make the appropriate changes in application_top.php with regard to the changes needed to "case buy_now" ?

The original code in application_top.php does not take into account any multiple amounts:

	  // performed by the 'buy now' button in product listings and review page
  case 'buy_now' :		if (isset($HTTP_GET_VARS['products_id'])) {
							if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
							  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
							} else {
							  $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;

Besides that, the code you show does not add the multiple quantity to the GET variables (&blabla=##) whereas you can't use POST variables since there are no longer form tags around this piece of code. You seem to be mixing and matching stuff without really knowing what you are doing IMHO.

Link to comment
Share on other sites

It's 6:30 am Monday morning and I have not been to bed yet. I've been battling with this all night and finally found the solution to my "hide the add to cart button" issue.
I found it doesn't make much sense to stay up that late, because you are to sleep-deprived anyway to be thinking clearly ;)
Where must I use the code you posted? shopping_cart.php?
Perhaps the lack of sleep ;)

Part of it goes above the original lines, and there is a "}" as a last extra line. The clue I left in the code was the comment line:

// starts around line 318 in includes/application_top.php
// Shopping cart actions

So the code I gave above that should be added and also the last line:

} // end if ($customer_group_id > 0)

// include the who's online functions

which goes just above the line: // include the who's online functions.

 

I hope you can make sense out of that.

Link to comment
Share on other sites

I see what you mean about the break table being a bit ugly .. How hard is it to make it look a bit better ?
I don't know, I'm neither a graphic designer nor a programmer (although better in the latter than in the former).

 

Try to change the orginal html to something you like better and then change the code in the class PriceFormatter to output the new html. This is the very basic table you have now:

<table align="top" border="1" cellspacing="0" cellpadding="0">
<tr>
<td align="center" class=productPriceInBox colspan="2">$69.00</td>
</tr>
<tr>
<td class=productPriceInBox>5+?</td>
<td class=productPriceInBox>$44.00</td>
</tr>
<tr>
<td class=productPriceInBox>10+?</td>
<td class=productPriceInBox>$33.00</td>
</tr>
</table>

Perhaps the Quantity Price Breaks Per Product Price Table Formatter can give you some ideas. The function that needs changing is called getPriceString($style='productPriceInBox') and is close to the bottom of the file.

Also what cost might be involed - remember I am in Australia so our $ isnt worth as much as yours, assuming you are in the USA.
So far I have avoided accepting any paid work and I don't intend changing that. I'm in the Netherlands (Europe, not the capital of Copenhagen ;) ) by the way.
Link to comment
Share on other sites

hi,

 

don't have someone a idea what i can do about my problem???

please..

 

i have make everything what you have said and know i have 2 problems

 

1. the articel's which i had till know in my shop are hidden.. they are hidden for every kind of customer.. (retail und end-consumer)

2. i only can say that a categorie should be hidden or not.. when i say hidden, then he don't show it me.. and it doesn't matter if i login as a retail or end-consumer customer

 

what can / must i do,...

.....that he show my article which i addet in the last days / weeks in my shop..

.....that i can say that a article (not categorie) just where hidden for retail...

 

because i have a lot of article which aren't for end-sonsumer..

 

i have installed first the "Enable Disable Categorie" contribution and then make the changes in the code that you have said.

 

thank you a lot for your help... i don't know what to do.. i have a shop without article.. and it takes to much time to add all the article new in the shop.

 

greetz

tali

 

 

hi,

 

does someone have a idea what i can do??

please..

 

greetz

tali

Link to comment
Share on other sites

Tali,

i have make everything what you have said and know i have 2 problems

 

1. the articel's which i had till know in my shop are hidden.. they are hidden for every kind of customer.. (retail und end-consumer)

2. i only can say that a categorie should be hidden or not.. when i say hidden, then he don't show it me.. and it doesn't matter if i login as a retail or end-consumer customer

 

what can / must i do,...

.....that he show my article which i addet in the last days / weeks in my shop..

.....that i can say that a article (not categorie) just where hidden for retail...

From what you tell me it is not clear to me if you added a new field to the table categories called categories_hide_for_groups, with a default of @ (the same as for products_hide_groups but another name, another table):

ALTER TABLE categories ADD categories_hide_from_groups VARCHAR(255) DEFAULT '@' NOT NULL;

Now for every customer group that should not see this category it should be added to this field, comma separated (with phpMyAdmin, there is no admin part for this, perhaps yet). So the contents of that field for a certain category that should be hidden from retail customers and visitors should be: @,0

Assuming wholesale had customer_group_id 1 and hide for both: @,0,1

Link to comment
Share on other sites

I'm looking for discount contrib that works with SPPC. Any suggestions :rolleyes: ?
I certainly don't know what you are looking for. As I understand it a lot of discount contributions kind of do what SPPC does, but only when you go to checkout. So I don't see what you would want with a discount contribution. If you want to give a group of customers lower prices you could make a new customer group with those prices and change them to that in the admin section.
Link to comment
Share on other sites

What I forgot to do, was to buy products and then logout and login again to complete the order. Now I've done that and the items that I bought before I logged out doesn't appear anymore. The image of the product is now gone, there's only a "place holder", no text appear and the Sub-Total shows only: 0.00. The only thing that shows up correct is the quantity.

 

I would appreciate help in finding the file(s) I have to look into, or even better which part(s) of the code that are responsible here.

SPPC does nothing with that really. If I'm correct the class shopping_cart.php handles that. SPPC deals with prices. Sounds like you use a contribution for the box shopping_cart.php anyway.

 

The standard includes/boxes/shopping_cart.php calls the function get_products from the class shopping_cart.php to, well get the products (as the name implies). The SPPC code in that function does get the customer group price but has nothing to do with images or descriptions.

Link to comment
Share on other sites

Thanks for a quick reply!

 

I'm going to look at it tomorrow, and will probably need some more help.

 

I'm also using Add to Wishlist contrib and it remembers what has been added even after logout.

Link to comment
Share on other sites

Tali,

From what you tell me it is not clear to me if you added a new field to the table categories called categories_hide_for_groups, with a default of @ (the same as for products_hide_groups but another name, another table):

ALTER TABLE categories ADD categories_hide_from_groups VARCHAR(255) DEFAULT '@' NOT NULL;

Now for every customer group that should not see this category it should be added to this field, comma separated (with phpMyAdmin, there is no admin part for this, perhaps yet). So the contents of that field for a certain category that should be hidden from retail customers and visitors should be: @,0

Assuming wholesale had customer_group_id 1 and hide for both: @,0,1

 

hi jan,

 

thank you for your answer.

 

i have in phpmyadmin add the field categories categories_hide_for_groups in the table categories.

 

my problem is, that the categories and products that i had add to my shop bevor i installed the contrib are all hidden and i can't set the status to 1. so that they were show me.

here 2 pics so that you know what i mean:

1.JPG

2.JPG

 

and when i add a new categorie and set the status = 0, then he don't show me the categorie. not for retail customers, visitors or wholesale.

and i can't change the status.

 

how can i say him, that when status=0, he just hide the categorie from the retail customers and visitors. and what must i change in the code, so that i should be able so change the status?

 

thank you a lot for your help.

 

greetz

tali

Link to comment
Share on other sites

how can i say him, that when status=0, he just hide the categorie from the retail customers and visitors. and what must i change in the code, so that i should be able so change the status?
You can't do that using the admin part of "Enable Disable Categories". You will have to use phpMyAdmin to manually change the field categories_hide_from_groups as I explained above (@,0 for hiding for retail).
Link to comment
Share on other sites

You can't do that using the admin part of "Enable Disable Categories". You will have to use phpMyAdmin to manually change the field categories_hide_from_groups as I explained above (@,0 for hiding for retail).

hi jan, thank you for your help..

 

i have tried to set some categories in phpmyadmin 0 or 1... (@,0 or @,1 to say it exactly) but the categories doesn't shown me!?

Link to comment
Share on other sites

SPPC does nothing with that really. If I'm correct the class shopping_cart.php handles that. SPPC deals with prices. Sounds like you use a contribution for the box shopping_cart.php anyway.

 

The standard includes/boxes/shopping_cart.php calls the function get_products from the class shopping_cart.php to, well get the products (as the name implies). The SPPC code in that function does get the customer group price but has nothing to do with images or descriptions.

 

Sorry for my ignorance with OSC!

 

Among other contributions, I use Purchase Without Account and Product Attributes - Option Type Feature.

 

I opened the class shopping_cart.php and found a few places where I might have merged wrong. I fixed it and now my cart has got its memory back. When I proceed with the checkout process I can pass checkout_shipping.php and checkout_payment.php without problems. When I come to checkout_confirmation.php, the Shipping Address and the Shipping Method shows up right, but the products doesn't and no Billing Information at all shows up.

 

I am still able to buy and go through with an order if the product has not been assigned any group other than Retail.

 

What about shopping_cart_pbpc.php? Maybe OTF-code has to be there also?

 

I'm posting my classes/shopping_cart.php as it looks now:

Link to comment
Share on other sites

<?php
/*
 $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $
 adapted for Separate Pricing Per Customer v3.6 2005/01/27

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class shoppingCart {
var $contents, $total, $weight, $cartID, $content_type;

function shoppingCart() {
  $this->reset();
}

function restore_contents() {
  global $customer_id;

  if (!tep_session_is_registered('customer_id')) return false;

// insert current cart contents in database
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $qty = $this->contents[$products_id]['qty'];
	  $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  if (!tep_db_num_rows($product_query)) {
		tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
		if (isset($this->contents[$products_id]['attributes'])) {
		  reset($this->contents[$products_id]['attributes']);
		  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
			//clr 031714 udate query to include attribute value. This is needed for text attributes.
			$attr_value = $this->contents[$products_id]['attributes_values'][$option];
			tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
		  }
		}
	  } else {
		tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	  }
	}
  }

// reset per-session cart contents, but not the database contents
  $this->reset(false);

  $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
  while ($products = tep_db_fetch_array($products_query)) {
	$this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);
// attributes
	//CLR 020606 update query to pull attribute value_text. This is needed for text attributes.
	$attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
	while ($attributes = tep_db_fetch_array($attributes_query)) {
	  $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
	  //CLR 020606 if text attribute, then set additional information
	  if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) {
		$this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text'];
	  }
	}
  }

  $this->cleanup();
}

function reset($reset_database = false) {
  global $customer_id;

  $this->contents = array();
  $this->total = 0;
  $this->weight = 0;
  $this->content_type = false;

  if (tep_session_is_registered('customer_id') && ($reset_database == true)) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
  }

  unset($this->cartID);
  if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');
}

function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
  // BOF Separate Pricing Per Customer, Price Break 1.11.3 modification
  global $new_products_id_in_cart, $customer_id, $languages_id;

  $pf = new PriceFormatter;
  $pf->loadProduct($products_id, $languages_id);
  $qty = $pf->adjustQty($qty);

  // EOF Separate Pricing Per Customer, Price Break 1.11.3 modification
  $products_id = tep_get_uprid($products_id, $attributes);
  if ($notify == true) {
	$new_products_id_in_cart = $products_id;
	tep_session_register('new_products_id_in_cart');
  }

  if ($this->in_cart($products_id)) {
	$this->update_quantity($products_id, $qty, $attributes);
  } else {
	$this->contents[] = array($products_id);
	$this->contents[$products_id] = array('qty' => $qty);
// insert into database
	if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id, $products_id_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')");

	if (is_array($attributes)) {
	  reset($attributes);
	  while (list($option, $value) = each($attributes)) {
		//CLR 020606 check if input was from text box.  If so, store additional attribute information
		//CLR 020708 check if text input is blank, if so do not add to attribute lists
		//CLR 030228 add htmlspecialchars processing.  This handles quotes and other special chars in the user input.$attr_value = NULL;
		$blank_value = FALSE;
		if (strstr($option, TEXT_PREFIX)) {
		  if (trim($value) == NULL)
		  {
			$blank_value = TRUE;
		  } else {
			$option = substr($option, strlen(TEXT_PREFIX));
			$attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
			$value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
			$this->contents[$products_id]['attributes_values'][$option] = $attr_value;
		  }
		}

		if (!$blank_value)
		{
		  $this->contents[$products_id]['attributes'][$option] = $value;
// insert into database
		//CLR 020606 update db insert to include attribute value_text. This is needed for text attributes.
		//CLR 030228 add tep_db_input() processing
		  if (tep_session_is_registered('customer_id') && $customer_id>0) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id, $products_id_string) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')");
		}
	  }
	}
  }
  $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
  $this->cartID = $this->generate_cart_id();
}

function update_quantity($products_id, $quantity = '', $attributes = '') {
  global $customer_id;

  if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

  $this->contents[$products_id] = array('qty' => $quantity);
// update database
  if (tep_session_is_registered('customer_id') && $customer_id>0) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id, $products_id_string) . "'");

  if (is_array($attributes)) {
	reset($attributes);
	while (list($option, $value) = each($attributes)) {
	  //CLR 020606 check if input was from text box.  If so, store additional attribute information
	  //CLR 030108 check if text input is blank, if so do not update attribute lists
	  //CLR 030228 add htmlspecialchars processing.  This handles quotes and other special chars in the user input.
	  $attr_value = NULL;
	  $blank_value = FALSE;
	  if (strstr($option, TEXT_PREFIX)) {
		if (trim($value) == NULL)
		{
		  $blank_value = TRUE;
		} else {
		  $option = substr($option, strlen(TEXT_PREFIX));
		  $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES);
		  $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID;
		  $this->contents[$products_id]['attributes_values'][$option] = $attr_value;
		}
	  }

	  if (!$blank_value)
	  {
		$this->contents[$products_id]['attributes'][$option] = $value;
// update database
		//CLR 020606 update db insert to include attribute value_text. This is needed for text attributes.
		//CLR 030228 add tep_db_input() processing


		if (tep_session_is_registered('customer_id') && $customer_id>0)  tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id, $products_id_string) . "' and products_options_id = '" . (int)$option . "'");
	  }
	}
  }
}

function cleanup() {
  global $customer_id;

  reset($this->contents);
  while (list($key,) = each($this->contents)) {
	if ($this->contents[$key]['qty'] < 1) {
	  unset($this->contents[$key]);
// remove from database
	  if (tep_session_is_registered('customer_id')) {
		tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
		tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
	  }
	}
  }
}

function count_contents() {  // get total number of items in cart 
  $total_items = 0;
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $total_items += $this->get_quantity($products_id);
	}
  }

  return $total_items;
}

function get_quantity($products_id) {
  if (isset($this->contents[$products_id])) {
	return $this->contents[$products_id]['qty'];
  } else {
	return 0;
  }
}

function in_cart($products_id) {
  if (isset($this->contents[$products_id])) {
	return true;
  } else {
	return false;
  }
}

function remove($products_id) {
  global $customer_id;

  unset($this->contents[$products_id]);
// remove from database
  if (tep_session_is_registered('customer_id')) {
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
	tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
  }

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
  $this->cartID = $this->generate_cart_id();
}

function remove_all() {
  $this->reset();
}

function get_product_id_list() {
  $product_id_list = '';
  if (is_array($this->contents)) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  $product_id_list .= ', ' . $products_id;
	}
  }

  return substr($product_id_list, 2);
}

function calculate() {
  $this->total = 0;
  $this->weight = 0;
  if (!is_array($this->contents)) return 0;
// BOF Separate Pricing Per Customer, Price Break 1.11.3 mod
  global $languages_id;
  $pf = new PriceFormatter;

  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
	$qty = $this->contents[$products_id]['qty'];

// products price
//	$product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

//	if ($product = tep_db_fetch_array($product_query)) {
	if ($product = $pf->loadProduct($products_id, $languages_id)){		
	  $prid = $product['products_id'];
	  $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
 //		$products_price = $product['products_price'];
	  $products_price = $pf->computePrice($qty);
	  $products_weight = $product['products_weight'];
// EOF Separate Pricing Per Customer, Price Break 1.11.3 mod
	  $this->total += tep_add_tax($products_price, $products_tax) * $qty;
	  $this->weight += ($qty * $products_weight);
	}

// attributes price
	if (isset($this->contents[$products_id]['attributes'])) {
	  reset($this->contents[$products_id]['attributes']);
	  while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
		$attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
		$attribute_price = tep_db_fetch_array($attribute_price_query);
		if ($attribute_price['price_prefix'] == '+') {
		  $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		} else {
		  $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
		}
	  }
	}
  }
}

function attributes_price($products_id) {
  $attributes_price = 0;

  if (isset($this->contents[$products_id]['attributes'])) {
	reset($this->contents[$products_id]['attributes']);
	while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
	  $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
	  $attribute_price = tep_db_fetch_array($attribute_price_query);
	  if ($attribute_price['price_prefix'] == '+') {
		$attributes_price += $attribute_price['options_values_price'];
	  } else {
		$attributes_price -= $attribute_price['options_values_price'];
	  }
	}
  }

  return $attributes_price;
}

function get_products() {
  global $languages_id;
// BOF Separate Pricing Per Customer v4, Price Break 1.11.3 modification
  if (!is_array($this->contents)) return false;
  $pf = new PriceFormatter;

  $products_array = array();
  reset($this->contents);
  while (list($products_id, ) = each($this->contents)) {
/*		$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
	if ($products = tep_db_fetch_array($products_query)) {
	  $prid = $products['products_id'];
	  $products_price = $products['products_price'];

	  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
	  if (tep_db_num_rows($specials_query)) {
		$specials = tep_db_fetch_array($specials_query);
		$products_price = $specials['specials_new_products_price'];
	  } */

  if ($products = $pf->loadProduct($products_id, $languages_id)) {
	  $products_price = $pf->computePrice($this->contents[$products_id]['qty']);
// EOF Separate Pricing Per Customer v4, Price Break 1.11.3 modification	  
	  $products_array[] = array('id' => $products_id,
								'name' => $products['products_name'],
								'model' => $products['products_model'],
								'image' => $products['products_image'],
								'price' => $products_price,
								'quantity' => $this->contents[$products_id]['qty'],
								'weight' => $products['products_weight'],
								'final_price' => ($products_price + $this->attributes_price($products_id)),
								'tax_class_id' => $products['products_tax_class_id'],
								'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
								'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));

	}
  }

  return $products_array;
}

function show_total() {
  $this->calculate();

  return $this->total;
}

function show_weight() {
  $this->calculate();

  return $this->weight;
}

function generate_cart_id($length = 5) {
  return tep_create_random_value($length, 'digits');
}

function get_content_type() {
  $this->content_type = false;

  if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
	reset($this->contents);
	while (list($products_id, ) = each($this->contents)) {
	  if (isset($this->contents[$products_id]['attributes'])) {
		reset($this->contents[$products_id]['attributes']);
		while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
		  $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");
		  $virtual_check = tep_db_fetch_array($virtual_check_query);

		  if ($virtual_check['total'] > 0) {
			switch ($this->content_type) {
			  case 'physical':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'virtual';
				break;
			}
		  } else {
			switch ($this->content_type) {
			  case 'virtual':
				$this->content_type = 'mixed';

				return $this->content_type;
				break;
			  default:
				$this->content_type = 'physical';
				break;
			}
		  }
		}
	  } else {
		switch ($this->content_type) {
		  case 'virtual':
			$this->content_type = 'mixed';

			return $this->content_type;
			break;
		  default:
			$this->content_type = 'physical';
			break;
		}
	  }
	}
  } else {
	$this->content_type = 'physical';
  }

  return $this->content_type;
}

function unserialize($broken) {
  for(reset($broken);$kv=each($broken);) {
	$key=$kv['key'];
	if (gettype($this->$key)!="user function")
	$this->$key=$kv['value'];
  }
}

 }
?>

Link to comment
Share on other sites

Rod,

I can't see any fault in it. Looks fine to me.

 

Of course once you have echo'ed them you can copy and paste them into phpMyAdmin and see if that returns an error.

 

I put in the echo statements and gave it a go. It seems that this problem is specific to just some specific catagories. I can probably live with it by making new catagories and then manually creating the products again, but not knowing why will bug me.

 

It keeps giving me the:

 

1062 - Duplicate entry '0-24' for key 1

 

insert into products_to_categories (products_id, categories_id) values ('0', '24')

 

[TEP STOP]

(for what ever product etc. it is for.)

 

....when I try to copy the products in this catagory even with the echo statements in there (not that they would change anything I don't think). I made a new catagory and tried to copy the products into it, but that threw up the same error. It must be a database thing.

 

Other copies give me stuff like...

 

Insert query:

 

Id of product to be copied is: 156

insert into products (products_quantity, products_model, products_image, products_image_med, products_image_lrg, products_image_sm_1, products_image_xl_1, products_image_sm_2, products_image_xl_2, products_image_sm_3, products_image_xl_3, products_image_sm_4, products_image_xl_4, products_image_sm_5, products_image_xl_5, products_image_sm_6, products_image_xl_6, products_price, products_date_added, products_date_available, products_weight, products_dim_type, products_weight_type, products_length, products_width, products_height, products_ready_to_ship, products_status, products_tax_class_id, manufacturers_id, products_sort_order) values ('10', 'CD188', 'semi-flexible-1.jpg', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '27.0000', now(), '', '0.47', 'in', 'lbs', '19.00', '1.00', '1.00', '1', '0', '1', '12', '35')Product id of duplicated product: 190

 

 

Warning: Cannot modify header information - headers already sent by (output started at /home/leakp/public_html/catalog/admin/categories.php:486) in /home/leakp/public_html/catalog/admin/includes/functions/general.php on line 80.

 

Which is what the echo command is suppose to give. I assume.

 

Thanks for showing me another trick. NowI just need to find out why my per item shipping module keeps adding two extra packages.

I like these mods, there fun! ...65 70 72 75 80 85 125+ contributions installed and counting...

 

Tools I'm using: OSC2.2 milestone2, Filezilla for FTP, PHP Designer 2007PE (nice), Araxis Merge 6.5 to compare files, XP(my box), Remote Server is shared Apache 1.3 Cpanel, CURL, and PHPmyAdmin through my hosts Cpanel to mess up the database.

Link to comment
Share on other sites

I don't think I have seen this one before, with the $pf->adjustQty(1) but did you make the appropriate changes in application_top.php with regard to the changes needed to "case buy_now" ?

The original code in application_top.php does not take into account any multiple amounts:

	  // performed by the 'buy now' button in product listings and review page
  case 'buy_now' :		if (isset($HTTP_GET_VARS['products_id'])) {
							if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
							  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
							} else {
							  $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;

Besides that, the code you show does not add the multiple quantity to the GET variables (&blabla=##) whereas you can't use POST variables since there are no longer form tags around this piece of code. You seem to be mixing and matching stuff without really knowing what you are doing IMHO.

 

Your right, i really don't know what i was doing, I am still trying to figure it out, and was just in a desperate attempt hoping it would work. But yea i just copied the code from the product_info.php page and obviously it did not work, but I understand why, sort of. But here is part of my application_top.php

 // customer adds a product from the products page
  case 'add_product' :	if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {
//	original			   $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+quantity, $HTTP_POST_VARS['id']);
// for price-break-1.11.3
							 $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id'])) + $HTTP_POST_VARS['cart_quantity'], $HTTP_POST_VARS['id']);
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;
  // performed by the 'buy now' button in product listings and review page
  case 'buy_now' :		if (isset($HTTP_GET_VARS['products_id'])) {
							if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {
							  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));
							} else {
							  $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);
							}
						  }
						  tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
						  break;

 

oh, now that i see that again, and you mentioned case 'buy_now', do i need to change that one too, even thought on the product listing i had put the in_cart thing, insead of buy_now, guess i will try it, eventhough, my customer decided to take off the add to cart button/buy now button anyway, he just wants a button that says click here to view details.

 

Thanks for your help, i will test it out when i have time.

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