Jump to content
scendent

Seperate Pricing Per Customer v3.5

Recommended Posts

I am facing a problem. I have created 2 customer groups. But when a customer from any of the groups place an order, no tax is added to it. But is a customer who is not under any group places an order, the tax is added to the items in his cart. How to fix that?

I am running OSC 2.3.1

Edited by anam_funny

Share this post


Link to post
Share on other sites

Hello,

 

thanks again for a great contribution. I am using it in 2.31 and all works fine, accept for an issue I just noticed on the admin. When creating a new product, I enter all the details including the (SPPC) dealer price. When I save for the first time, all is saved to the database but the (SPPC) dealer price? If I edit again and re-enter the dealer price and save, it is then inserted into the database and shows? What would cause the database for the SPPC dealer input not to save the first time, but accept on the second save?

 

Thanks JR

Share this post


Link to post
Share on other sites

Hopefully someone with brains in here can help with this
smile.png
What I am trying to do is get SPPC to use prices from two extra price columns I have in the products table (special_price_2 & Special_price_3) rather than let it get the prices from the -customers_group_price from " . TABLE_PRODUCTS_GROUPS-
I have tried changing if ($customer_group_id
> 0
) to if ($customer_group_id
= 1
)
and "
select customers_group_price from " . TABLE_PRODUCTS_GROUPS
to "
select
special_price_2 from " . TABLE_PRODUCTS
but it then fails because of
and customers_group_id = '" . $customer_group_id .
not being in the table.
If i am thinking correctly and remove the
and customers_group_id = '" . $customer_group_id .
it should then work?
Can anyone give me the correct syntax for the line after removing this part as i beleive it does not need to look up the customer_group_id as it gets this from the customers account table and i am setting the if ($customer_group_id = 1)

 

 

 

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

Share this post


Link to post
Share on other sites

Hi Everybody!

 

First of all big-big thanks for the feedback for every person who sended especially for Mr. Jan Zonjee and for the GREAT contirb!

 

After trying lots of hours unsuccessfully manage my problem I am trying to ask some help for my problem.

 

My problem details:

Everything works great (minimum order quantity, rounding, volume discounts etc) except one half thing.

 

I am selling products in different colors and of course I setted up for every product a discount category (if someone orders 5 red and 10 black thing from the same product it would count as it would be 15).

 

The problem is with the price calculation. It doesn't corrects the price after adding 2-3 colors from the same product (of course after reaching a volume discount category) when product_info.php has is a quantity field. When the customer cicks on the update cart or if the customers logs in-out or the customer updates the quantity (at shopping_cart.php) everything is correct.

 

I have already went through 2-3 times if it is everything correct or not, and to tell you the truth I am fully disappointed...

I really really hope that somebody could help me out.

Share this post


Link to post
Share on other sites

I have modified the product_listing.php as below.

but I now have the problem when I want attribute price to add 12USD retail and 10USD on group "1", then for every attribute price changes I add on groupe"1" some attribute disappears and finally non of the attributes shows in group"1".

What is wrong in the code below?

 

// BOF SPPC Hide attributes from customer groups
$products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 ");
$products_attributes = tep_db_fetch_array($products_attributes_query);
if ($products_attributes['total'] > 0) {
?>
<p><?php echo TEXT_PRODUCT_OPTIONS; ?></p>
<p>
<!--
		// Code segment includes/modified for Multiple product option lines.
 // maintainance and Qns : Harishyam :> feenix_666@yahoo.com
-->
<?php	
	if ($products_options_total['total'] == 1) {
  for($i=0;$i<$products_attributes['total'];$i++)
  {
  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
	$products_options_array = array();
	$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
$list_of_prdcts_attributes_id = '';
$products_options = array(); // makes sure this array is empty again
	while ($_products_options = tep_db_fetch_array($products_options_query)) {
 $products_options[] = $_products_options;
 $list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
}
if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') {
  $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
  $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
  while ($pag_array = tep_db_fetch_array($pag_query)) {
   $cg_attr_prices[] = $pag_array;
  }

  // substitute options_values_price and prefix for those for the customer group (if available)
  if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
   for ($n = 0 ; $n < count($products_options); $n++) {
	for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
	 if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
	  $products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
	  $products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
	 }
	} // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
   }
  } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
 } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')
 for ($n = 0 ; $n < count($products_options); $n++) {
  $products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
  if ($products_options[$n]['options_values_price'] != '0') {
   $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
  }
 }
// EOF SPPC attributes mod
	if (is_string($HTTP_GET_VARS['products_id']) && isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {	  
  $selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
} else {
  $selected_attribute = false;
}
?>


<?php			
$count	  = 1;
$maxPerList = 20;
$total = $products_attributes['total'];
if ($products_options_total['total'] == 1) {
echo "<ul style='float:left;'>"; //Start list
for($i=0;$i<$products_attributes['total'];$i++) {
 $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
 while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
  $products_options_array = array();
  $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0");
  $list_of_prdcts_attributes_id = '';
  $products_options = array(); // makes sure this array is empty again
  while ($_products_options = tep_db_fetch_array($products_options_query)) {
$products_options[] = $_products_options;
$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
  }
  if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') {
$select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")";
$pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $customer_group_id . "'");
while ($pag_array = tep_db_fetch_array($pag_query)) {
 $cg_attr_prices[] = $pag_array;
}

// substitute options_values_price and prefix for those for the customer group (if available)
if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) {
 for ($n = 0 ; $n < count($products_options); $n++) {
  for ($i = 0; $i < count($cg_attr_prices) ; $i++) {
   if ($cg_attr_prices[$i]['products_attributes_id'] == $products_options[$n]['products_attributes_id']) {
	$products_options[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix'];
	$products_options[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price'];
   }
  } // end for ($i = 0; $i < count($cg_att_prices) ; $i++)
 }
} // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices))
  } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0')
  for ($n = 0 ; $n < count($products_options); $n++) {
$products_options_array[] = array('id' => $products_options[$n]['products_options_values_id'], 'text' => $products_options[$n]['products_options_values_name']);
if ($products_options[$n]['options_values_price'] != '0') {
 $products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
}
  }

  if (is_string($HTTP_GET_VARS['products_id']) && isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {	  
$selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];
  } else {
$selected_attribute = false;
  }


		echo '<li><input type="text" name='.$i.'_quantity value="" style="text-align:right;" size="3">';
		echo tep_draw_hidden_field($i.'_id[' . $products_options_name['products_options_id'] . ']', $products_options_array[$i]['id']) . $products_options_array[$i]['text'];  
		echo "</li>";


  if ($count % $maxPerList == 0 && $count != $total) {  //Check if remainder is 0 or if it is the last product
echo "</ul><ul style='float:left;  padding-left: 10px;'>";   ///Close list and start a new one
  }
  $count++;  
 }
} // End of loop
echo "</ul>"; //Close any left open tag
}
}
}} else {
//do your regular thing

Share this post


Link to post
Share on other sites

I am struggling to install this module into a new install of oscommerce 2.3.1 with sppc added. The install goes fine until i try to mod the admin/categories file. I have tried 3 times so far and keep getting errors.

 

Does someone have a working copy of the admin/categories file i can have please.


REMEMBER BACKUP, BACKUP AND BACKUP

Get the latest Responsive osCommerce CE (community edition) here

It's very easy to over complicate what are simple things in life

Share this post


Link to post
Share on other sites

Does anyone has install the SPPC 4.4.2 in a 2.3.1 store that has also the HeaderTags_SEO_V_3.2.7 contribution? How did he solve the problems in product listing and in other files? Don't tell me about winmerge cause i have made it twice and i am getting a problem with the products. Everything seems to be ok in the first page, all the products are there , when you choosing a product from the first page ( Whats new...) all ok, but when i am choosing a product from the categgories then the product it doesn't exists.....I don't have a picture not anything so i am gessing that the problem is in the file of product_listing at least or in the categories. Does anyone has face that?


One amateur made the Arc, 5.000 pro made the Titanic...

Share this post


Link to post
Share on other sites

Someone must have added sppc and quantity price breaks together and have a copy of the admin/categories.php file i could have. This is driving me crazy.. I have spent another day on this and still it does not work correctly.

 

If no one has a file does someone have any tips on how to combine these to add ons.


REMEMBER BACKUP, BACKUP AND BACKUP

Get the latest Responsive osCommerce CE (community edition) here

It's very easy to over complicate what are simple things in life

Share this post


Link to post
Share on other sites

Does anyone has install the SPPC 4.4.2 in a 2.3.1 store that has also the HeaderTags_SEO_V_3.2.7 contribution? How did he solve the problems in product listing and in other files? Don't tell me about winmerge cause i have made it twice and i am getting a problem with the products. Everything seems to be ok in the first page, all the products are there , when you choosing a product from the first page ( Whats new...) all ok, but when i am choosing a product from the categgories then the product it doesn't exists.....I don't have a picture not anything so i am gessing that the problem is in the file of product_listing at least or in the categories. Does anyone has face that?

 

If i can ever get the two add ons working together i am planning on doing this next.


REMEMBER BACKUP, BACKUP AND BACKUP

Get the latest Responsive osCommerce CE (community edition) here

It's very easy to over complicate what are simple things in life

Share this post


Link to post
Share on other sites

Hi,

 

I have OSCommerce v2.3.1 with SPPC v4.2.2.2 installed and want the quantity price break addon installed as well. The version for SPPC 4.2.2 is v2 however it is not compatible with OSCommerce v2.3.1.

 

 

Does any body have any new mods for v2.3.1 yet???

 

 

Thanks in advance

Share this post


Link to post
Share on other sites

Hi,

 

I have OSCommerce v2.3.1 with SPPC v4.2.2.2 installed and want the quantity price break addon installed as well. The version for SPPC 4.2.2 is v2 however it is not compatible with OSCommerce v2.3.1.

 

 

Does any body have any new mods for v2.3.1 yet???

 

 

Thanks in advance

 

I have just installed this on 2.3.1 and after a bit of code changing it works fine. You will have to manually update all the files, but the instructions are quite clear and easy to follow. Backup your files first and give it a try. The only thing i will say is that when it comes to the categories page take your time and do not add all the code for the javascript as some of it is already installed and in a newer version.


REMEMBER BACKUP, BACKUP AND BACKUP

Get the latest Responsive osCommerce CE (community edition) here

It's very easy to over complicate what are simple things in life

Share this post


Link to post
Share on other sites

@@14steve14 Hi Steve,

 

I have tried this install as mentioned and can not get the catalog/admin/categories.php to work no matter how I do it with or without the optional javascript as stated at the end of the files edit.

 

 

I have also noticed a couple of lines mentioned in the instructions which do not exist so maybe this is where I'm going wrong??

 

 

 

I have included my categories.php for any to look at and hopefully point me in the right direction.

 

 

Thanks in advance.

 

1. <script language="javascript" src="includes/general.js"></script>

 

2. // BOF Separate Pricing per Customer

if (is_array($value)) {

while (list($k, $v) = each($value)) {

echo tep_draw_hidden_field($key . '[' . $k . ']', htmlspecialchars(stripslashes($v)));

}

} else {

// EOF Separate Pricing per Customer

 

 

 

 

<?php
/*
 $Id$
 adapted for Separate Pricing Per Customer v4.2 2007/08/05, QPBPP for SPPC v2.0 2008/11/23
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2010 osCommerce
 Released under the GNU General Public License
*/
 require('includes/application_top.php');
 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();
 // BOF QPBPP for SPPC
// include the admin version of price formatter for the price breaks contribution
 require(DIR_WS_CLASSES . 'PriceFormatterAdmin.php');
 $pf = new PriceFormatter;
// EOF QPBPP for SPPC
 $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
 if (tep_not_null($action)) {
   switch ($action) {
  case 'setflag':
    if ( ($HTTP_GET_VARS['flag'] == '0') || ($HTTP_GET_VARS['flag'] == '1') ) {
	  if (isset($HTTP_GET_VARS['pID'])) {
	    tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);
	  }
	  if (USE_CACHE == 'true') {
	    tep_reset_cache_block('categories');
	    tep_reset_cache_block('also_purchased');
	  }
    }
    tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $HTTP_GET_VARS['cPath'] . '&pID=' . $HTTP_GET_VARS['pID']));
    break;
  case 'insert_category':
  case 'update_category':
    if (isset($HTTP_POST_VARS['categories_id'])) $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
    $sort_order = tep_db_prepare_input($HTTP_POST_VARS['sort_order']);
    $sql_data_array = array('sort_order' => (int)$sort_order);
    if ($action == 'insert_category') {
	  $insert_sql_data = array('parent_id' => $current_category_id,
							   'date_added' => 'now()');
	  $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
	  tep_db_perform(TABLE_CATEGORIES, $sql_data_array);
	  $categories_id = tep_db_insert_id();
    } elseif ($action == 'update_category') {
	  $update_sql_data = array('last_modified' => 'now()');
	  $sql_data_array = array_merge($sql_data_array, $update_sql_data);
	  tep_db_perform(TABLE_CATEGORIES, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "'");
    }
    $languages = tep_get_languages();
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
	  $categories_name_array = $HTTP_POST_VARS['categories_name'];
	  $language_id = $languages[$i]['id'];
	  $sql_data_array = array('categories_name' => tep_db_prepare_input($categories_name_array[$language_id]));
	  if ($action == 'insert_category') {
	    $insert_sql_data = array('categories_id' => $categories_id,
								 'language_id' => $languages[$i]['id']);
	    $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
	    tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array);
	  } elseif ($action == 'update_category') {
	    tep_db_perform(TABLE_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "categories_id = '" . (int)$categories_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'");
	  }
    }
    $categories_image = new upload('categories_image');
    $categories_image->set_destination(DIR_FS_CATALOG_IMAGES);
    if ($categories_image->parse() && $categories_image->save()) {
	  tep_db_query("update " . TABLE_CATEGORIES . " set categories_image = '" . tep_db_input($categories_image->filename) . "' where categories_id = '" . (int)$categories_id . "'");
    }
    if (USE_CACHE == 'true') {
	  tep_reset_cache_block('categories');
	  tep_reset_cache_block('also_purchased');
    }
    tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
    break;
  case 'delete_category_confirm':

Share this post


Link to post
Share on other sites

I'm having to pot my code in seperate replies as its too long for an all in one hit...

 

 

 

if (isset($HTTP_POST_VARS['categories_id'])) {
	  $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
	  $categories = tep_get_category_tree($categories_id, '', '0', '', true);
	  $products = array();
	  $products_delete = array();
	  for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
	    $product_ids_query = tep_db_query("select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$categories[$i]['id'] . "'");
	    while ($product_ids = tep_db_fetch_array($product_ids_query)) {
		  $products[$product_ids['products_id']]['categories'][] = $categories[$i]['id'];
	    }
	  }
	  reset($products);
	  while (list($key, $value) = each($products)) {
	    $category_ids = '';
	    for ($i=0, $n=sizeof($value['categories']); $i<$n; $i++) {
		  $category_ids .= "'" . (int)$value['categories'][$i] . "', ";
	    }
	    $category_ids = substr($category_ids, 0, -2);
	    $check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$key . "' and categories_id not in (" . $category_ids . ")");
	    $check = tep_db_fetch_array($check_query);
	    if ($check['total'] < '1') {
		  $products_delete[$key] = $key;
	    }
	  }
// removing categories can be a lengthy process
	  tep_set_time_limit(0);
	  for ($i=0, $n=sizeof($categories); $i<$n; $i++) {
	    tep_remove_category($categories[$i]['id']);
	  }
	  reset($products_delete);
	  while (list($key) = each($products_delete)) {
	    tep_remove_product($key);
	  }
    }
    if (USE_CACHE == 'true') {
	  tep_reset_cache_block('categories');
	  tep_reset_cache_block('also_purchased');
    }
    tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
    break;
  case 'delete_product_confirm':
    if (isset($HTTP_POST_VARS['products_id']) && isset($HTTP_POST_VARS['product_categories']) && is_array($HTTP_POST_VARS['product_categories'])) {
	  $product_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
	  $product_categories = $HTTP_POST_VARS['product_categories'];
	  // BOF Separate Pricing Per Customer
	  tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . tep_db_input($product_id) . "' ");
	  // EOF Separate Pricing Per Customer
	  for ($i=0, $n=sizeof($product_categories); $i<$n; $i++) {
	    tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "' and categories_id = '" . (int)$product_categories[$i] . "'");
	  }
   // BOF QPBPP for SPPC
	    tep_db_query("delete from " . TABLE_PRODUCTS_PRICE_BREAK . " where products_id = '" . (int)$product_id . "'");
// EOF QPBPP for SPPC

	  $product_categories_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'");
	  $product_categories = tep_db_fetch_array($product_categories_query);
	  if ($product_categories['total'] == '0') {
	    tep_remove_product($product_id);
	  }
    }
    if (USE_CACHE == 'true') {
	  tep_reset_cache_block('categories');
	  tep_reset_cache_block('also_purchased');
    }
    tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath));
    break;
  case 'move_category_confirm':
    if (isset($HTTP_POST_VARS['categories_id']) && ($HTTP_POST_VARS['categories_id'] != $HTTP_POST_VARS['move_to_category_id'])) {
	  $categories_id = tep_db_prepare_input($HTTP_POST_VARS['categories_id']);
	  $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);
	  $path = explode('_', tep_get_generated_category_path_ids($new_parent_id));
	  if (in_array($categories_id, $path)) {
	    $messageStack->add_session(ERROR_CANNOT_MOVE_CATEGORY_TO_PARENT, 'error');
	    tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories_id));
	  } else {
	    tep_db_query("update " . TABLE_CATEGORIES . " set parent_id = '" . (int)$new_parent_id . "', last_modified = now() where categories_id = '" . (int)$categories_id . "'");
	    if (USE_CACHE == 'true') {
		  tep_reset_cache_block('categories');
		  tep_reset_cache_block('also_purchased');
	    }

Share this post


Link to post
Share on other sites
 tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&cID=' . $categories_id));
	  }
    }
    break;
  case 'move_product_confirm':
    $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']);
    $new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_category_id']);
    $duplicate_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$new_parent_id . "'");
    $duplicate_check = tep_db_fetch_array($duplicate_check_query);
    if ($duplicate_check['total'] < 1) tep_db_query("update " . TABLE_PRODUCTS_TO_CATEGORIES . " set categories_id = '" . (int)$new_parent_id . "' where products_id = '" . (int)$products_id . "' and categories_id = '" . (int)$current_category_id . "'");
    if (USE_CACHE == 'true') {
	  tep_reset_cache_block('categories');
	  tep_reset_cache_block('also_purchased');
    }
    tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $new_parent_id . '&pID=' . $products_id));
    break;
  case 'insert_product':
  case 'update_product':
    if (isset($HTTP_GET_VARS['pID'])) $products_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);
    $products_date_available = tep_db_prepare_input($HTTP_POST_VARS['products_date_available']);
    $products_date_available = (date('Y-m-d') < $products_date_available) ? $products_date_available : 'null';
    $sql_data_array = array('products_quantity' => (int)tep_db_prepare_input($HTTP_POST_VARS['products_quantity']),
						    'products_model' => tep_db_prepare_input($HTTP_POST_VARS['products_model']),
						    'products_price' => tep_db_prepare_input($HTTP_POST_VARS['products_price']),
    // BOF QPBPP for SPPC
							  'products_qty_blocks' => (($i = (int)tep_db_prepare_input($_POST['products_qty_blocks'][0])) < 1) ? 1 : $i,
							  'products_min_order_qty' => (($min_i = (int)tep_db_prepare_input($_POST['products_min_order_qty'][0])) < 1) ? 1 : $min_i,
// EOF QPBPP for SPPC
						    'products_date_available' => $products_date_available,
						    'products_weight' => (float)tep_db_prepare_input($HTTP_POST_VARS['products_weight']),
						    'products_status' => tep_db_prepare_input($HTTP_POST_VARS['products_status']),
						    'products_tax_class_id' => tep_db_prepare_input($HTTP_POST_VARS['products_tax_class_id']),
						    'manufacturers_id' => (int)tep_db_prepare_input($HTTP_POST_VARS['manufacturers_id']));
    $products_image = new upload('products_image');
    $products_image->set_destination(DIR_FS_CATALOG_IMAGES);
    if ($products_image->parse() && $products_image->save()) {
	  $sql_data_array['products_image'] = tep_db_prepare_input($products_image->filename);
    }
    if ($action == 'insert_product') {
	  $insert_sql_data = array('products_date_added' => 'now()');
	  $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
	  tep_db_perform(TABLE_PRODUCTS, $sql_data_array);
	  $products_id = tep_db_insert_id();
	  tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$products_id . "', '" . (int)$current_category_id . "')");
    } elseif ($action == 'update_product') {
	  $update_sql_data = array('products_last_modified' => 'now()');
	  $sql_data_array = array_merge($sql_data_array, $update_sql_data);
	  tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "'");

   // BOF QPBPP for SPPC
// BOF entries in products_groups
$customers_group_query = tep_db_query("select customers_group_id, customers_group_name from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id != '0' order by customers_group_id");
while ($customers_group = tep_db_fetch_array($customers_group_query)) // Gets all of the customers groups
 {
 $attributes_query = tep_db_query("select customers_group_id, customers_group_price, products_qty_blocks, products_min_order_qty from " . TABLE_PRODUCTS_GROUPS . " where ((products_id = '" . $products_id . "') && (customers_group_id = " . $customers_group['customers_group_id'] . ")) order by customers_group_id");
 $attributes = tep_db_fetch_array($attributes_query);
// set default values for quantity blocks and min order quantity 
 $pg_products_qty_blocks = 1;
 $pg_products_min_order_qty = 1;
 $delete_row_from_pg = false;
 if (isset($_POST['products_qty_blocks'][$customers_group['customers_group_id']]) && (int)$_POST['products_qty_blocks'][$customers_group['customers_group_id']] > 1) {
 $pg_products_qty_blocks = (int)$_POST['products_qty_blocks'][$customers_group['customers_group_id']];
 }
 if (isset($_POST['products_min_order_qty'][$customers_group['customers_group_id']]) && (int)$_POST['products_min_order_qty'][$customers_group['customers_group_id']] > 1) {
 $pg_products_min_order_qty = (int)$_POST['products_min_order_qty'][$customers_group['customers_group_id']];
 }
 if ($_POST['sppcprice'][$customers_group['customers_group_id']] == '' && $pg_products_qty_blocks == 1 && $pg_products_min_order_qty == 1) {
   $delete_row_from_pg = true; // no need to have default values for qty blocks and min order qty in the table
 }
 if ($_POST['sppcprice'][$customers_group['customers_group_id']] == '') {
   $pg_cg_group_price = 'null';
 } else {
   $pg_cg_group_price = "'" . (float)$_POST['sppcprice'][$customers_group['customers_group_id']] . "'";
 }
 if (tep_db_num_rows($attributes_query) > 0 && $delete_row_from_pg == false) {
// there is already a row inserted in products_groups, update instead of insert 
   if ($_POST['sppcoption'][$customers_group['customers_group_id']]) { // this is checking if the check box is checked
    tep_db_query("update " . TABLE_PRODUCTS_GROUPS . " set customers_group_price = " . $pg_cg_group_price . ", products_qty_blocks = " . $pg_products_qty_blocks . ", products_min_order_qty = " . $pg_products_min_order_qty . " where customers_group_id = '" . $attributes['customers_group_id'] . "' and products_id = '" . $products_id . "'");
   }
   else {
  tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'");
   }
 } elseif (tep_db_num_rows($attributes_query) > 0 && $delete_row_from_pg == true) {
  tep_db_query("delete from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '" . $customers_group['customers_group_id'] . "' and products_id = '" . $products_id . "'");
 } elseif (($_POST['sppcoption'][$customers_group['customers_group_id']]) && $delete_row_from_pg == false) {
   tep_db_query("insert into " . TABLE_PRODUCTS_GROUPS . " (products_id, customers_group_id, customers_group_price, products_qty_blocks, products_min_order_qty) values ('" . $products_id . "', '" . $customers_group['customers_group_id'] . "', " . $pg_cg_group_price . ", " . $pg_products_qty_blocks . ", " . $pg_products_min_order_qty . ")");
 }
} // end while ($customers_group = tep_db_fetch_array($customers_group_query))
// EOF entries in products_groups
// BOF entries in products_to_discount_categories
 foreach ($_POST['discount_categories_id'] as $dc_cg_id => $dc_id) {
   $current_discount_category = (int)$_POST['current_discount_cat_id'][$dc_cg_id];
   $new_discount_category = (int)$dc_id;
   $discount_category_result = qpbpp_insert_update_discount_cats($products_id, $current_discount_category, $new_discount_category, $dc_cg_id);
  if ($discount_category_result == false) {
	  $messageStack->add_session(ERROR_UPDATE_INSERT_DISCOUNT_CATEGORY, 'error');
   }
 } // end foreach ($_POST['discount_categories_id'] as $dc_cg_id => $dc_id
// EOF entries in products_to_discount_categories
// BOF entries in products_price_break
 foreach ($_POST['products_price_break'] as $pbb_cg_id => $price_break_array) {
   foreach ($price_break_array as $key1 => $products_price) {
  $pb_action = 'insert'; // re-set default to insert
  $where_clause = '';
  if (isset($_POST['products_delete'][$pbb_cg_id][$key1]) && $_POST['products_delete'][$pbb_cg_id][$key1] == 'y' && isset($_POST['products_price_break_id'][$pbb_cg_id][$key1])) {
    $delete_from_ppb_array[] = (int)$_POST['products_price_break_id'][$pbb_cg_id][$key1];
    continue;
  }
  if (!tep_not_null($products_price)) {
    continue; // if price is empty this price break is unused
  } elseif (!tep_not_null($_POST['products_qty'][$pbb_cg_id][$key1])) {
    continue; // if qty is not entered we will not update or insert this in the table
  } else {
    $sql_price_break_data_array = array(
	   'products_id' => (int)$products_id,
	   'products_price' => (float)$products_price,
	   'products_qty' => (int)$_POST['products_qty'][$pbb_cg_id][$key1],
	   'customers_group_id' => $pbb_cg_id
	   );

    if (isset($_POST['products_price_break_id'][$pbb_cg_id][$key1]) && (int)$_POST['products_price_break_id'][$pbb_cg_id][$key1] > 0) {
	  $pb_action = 'update';
	  $where_clause = " products_price_break_id = '" . (int)$_POST['products_price_break_id'][$pbb_cg_id][$key1] . "'";
    }
    tep_db_perform(TABLE_PRODUCTS_PRICE_BREAK, $sql_price_break_data_array, $pb_action, $where_clause);
  } // end if/else (!tep_not_null($products_price))
   } // end foreach ($price_break_array as $key1 => $products_price)
 } // end foreach ($_POST['products_price_break'] as $pbb_cg_id => $price_break_array)

// delete the unwanted price breaks using their products_price_break_id's
   if (isset($delete_from_ppb_array) && sizeof($delete_from_ppb_array > 0) && tep_not_null($delete_from_ppb_array[0])) {
  tep_db_query("delete from " . TABLE_PRODUCTS_PRICE_BREAK . " where products_price_break_id in (" . implode(',', $delete_from_ppb_array) . ")");
   }
// EOF entries in products_price_break
// EOF QPBPP for SPPC
    }
    $languages = tep_get_languages();
    for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
	  $language_id = $languages[$i]['id'];
	  $sql_data_array = array('products_name' => tep_db_prepare_input($HTTP_POST_VARS['products_name'][$language_id]),
							  'products_description' => tep_db_prepare_input($HTTP_POST_VARS['products_description'][$language_id]),
							  'products_url' => tep_db_prepare_input($HTTP_POST_VARS['products_url'][$language_id]));
	  if ($action == 'insert_product') {
	    $insert_sql_data = array('products_id' => $products_id,
								 'language_id' => $language_id);
	    $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
	    tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
	  } elseif ($action == 'update_product') {
	    tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
	  }
    }
    $pi_sort_order = 0;
    $piArray = array(0);
    foreach ($HTTP_POST_FILES as $key => $value) {
// Update existing large product images
	  if (preg_match('/^products_image_large_([0-9]+)$/', $key, $matches)) {
	    $pi_sort_order++;
	    $sql_data_array = array('htmlcontent' => tep_db_prepare_input($HTTP_POST_VARS['products_image_htmlcontent_' . $matches[1]]),
							    'sort_order' => $pi_sort_order);
	    $t = new upload($key);
	    $t->set_destination(DIR_FS_CATALOG_IMAGES);
	    if ($t->parse() && $t->save()) {
		  $sql_data_array['image'] = tep_db_prepare_input($t->filename);
	    }
	    tep_db_perform(TABLE_PRODUCTS_IMAGES, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and id = '" . (int)$matches[1] . "'");
	    $piArray[] = (int)$matches[1];
	  } elseif (preg_match('/^products_image_large_new_([0-9]+)$/', $key, $matches)) {
// Insert new large product images
	    $sql_data_array = array('products_id' => (int)$products_id,
							    'htmlcontent' => tep_db_prepare_input($HTTP_POST_VARS['products_image_htmlcontent_new_' . $matches[1]]));

Share this post


Link to post
Share on other sites

Not all code added I thought I had sussed it but I haven't.

 

 

Any one who can help with this one file it would really help!!

 

Thanks,

 

:)

Share this post


Link to post
Share on other sites

Combining QPBPP with SPPC

 

 

I really need some help with this one folks!!

 

 

I have installed SPPC 4.2 with OSC 2.3.1 and every thing seems to work fine, I am now trying to install QPBPP with it as well but every time I upload the file admin/categories.php I get a blank page.

 

 

I've noticed that some of the code mentioned in the install file do not exist in the file I am editing.

 

Here are the lines that do not exist...

 

 

<script language="javascript" src="includes/general.js"></script>

 

 

 

// BOF Separate Pricing per Customer

if (is_array($value)) {

while (list($k, $v) = each($value)) {

echo tep_draw_hidden_field($key . '[' . $k . ']', htmlspecialchars(stripslashes($v)));

}

} else {

// EOF Separate Pricing per Customer

 

 

 

 

Thanks in advance.

Share this post


Link to post
Share on other sites

Javascript files have all been moved to your admin/includes/application_top.php file. Most of the javascript code you need to add is already in this file. Make sure you are not calling the same files twice or nothing works.

 

Then if i am not mistaken the next bit of code does not need to be added as the section of code it goes in has all been removed from 2.3.1

 

A while ago i asked a similar question asking for a working copy of the admin/categories.php file from someone who has installed both these contributions and no one answered. I spent ages sorting this out in the end.


REMEMBER BACKUP, BACKUP AND BACKUP

Get the latest Responsive osCommerce CE (community edition) here

It's very easy to over complicate what are simple things in life

Share this post


Link to post
Share on other sites

Does anyone knows why the SPPC 4.4.2 after the instalation cuts the customers name at half?

Before SPPC the customers name was 5 letters and then � in the greek language.

I had fix it, upgrading the database.php files so sql understands utf8 and also with upgrading the numbers of letters in customers name into database with .phpmyadmin .

I had made a test customer and everything was ok.

But after installation of SPPC IN A OSC 2.3.1 i am having the same issue in the greek language, but now i can't fix it.

Does anyone has the solution?


One amateur made the Arc, 5.000 pro made the Titanic...

Share this post


Link to post
Share on other sites

@@14steve14 thanks for the advice.

 

 

Have you had any issues after install with the price not showing up on the product listing and search pages but it shows up ok in the product info page.

 

 

All defaults are set to GPB??

 

 

Any ideas??

 

 

Thanks,

Share this post


Link to post
Share on other sites

Hi! Im hoping someone can point me in the right direction of where to look. I have sppc and hide products installed and the only issue I have run into is if I hide a category it still shows up in best sellers, reviews and new products, I have been looking and looking and I was hoping someone can give me a hint as to which file I messed up. Thanks for any help!

Share this post


Link to post
Share on other sites

Hi! Im hoping someone can point me in the right direction of where to look. I have sppc and hide products installed and the only issue I have run into is if I hide a category it still shows up in best sellers, reviews and new products, I have been looking and looking and I was hoping someone can give me a hint as to which file I messed up. Thanks for any help!

 

Hi,

It isn't combined with sppc. You must looking for select and add clause after where like 'categories_status=1' in each module you want.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×