Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

done some more testuing and have doubts abut the prveious code so please dont use it whilst I recheck what i am doing.

 

Thanks

Alas cant get the uhtml to work with sppc, bth work seperatley, can get the tiny mce in the sppc but cant get the e-mails to go via uhtml.

 

as its more important to email newsletters by groups for this site I will have to leave it be and till someone can offere a solution.

 

It cant be so hard(lol spent most of the day trying), theres only two files after all, and each set works fine on their own. Its just the integration.

 

as for the pdf invoices by e-mail, cant get that to work with sppc either and the issue is with the entry in checkout_process.php, works fine on its own, the invoice system works on its own, just the email with invoices when using sppc.

 

so again short term I can switch the email invoices off.

 

Help someone must know the solution?

 

Johnny

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

Okay I have development question.

 

Is it possible to create a system where a customer can have several groups assigned to their account.

 

for example:-

 

customer a , has special pricing on product groups A, B and C

 

customer b, just has special pricing on product group B

 

customer c,has special pricing on product groups A and C

 

This would require some coding, include a check box for each group a customer is signed up to.

 

this would work similar to the retail(default price) and customer group price except that you could have more than one group.

 

 

 

so if customer has just one group, they get product price for their group and retail prices for items that are not there group.

so if customer has two groups, they get product price for their two groups and retail prices for items that are not there group.

 

the thinking is to minimise thenumber of groups created, but to allow customers to get the best prices for each package they are using.

 

The alternative is to setup several shops or offer the seperate price groups as one product range regardless of what they have signed up to.

 

your thoughts are appreciated on this.

 

Thanks

johnny

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

Is it possible to create a system where a customer can have several groups assigned to their account.

 

for example:-

 

customer a , has special pricing on product groups A, B and C

 

customer b, just has special pricing on product group B

 

customer c,has special pricing on product groups A and C

 

This would require some coding, include a check box for each group a customer is signed up to.

 

this would work similar to the retail(default price) and customer group price except that you could have more than one group.

I'm sure it could be written but then you would have to change virtually all code to look for the "product_group" a product is in too. I don't see the value of that if you could simply create the same thing by having more customers groups.

 

Probably you can simply update insert/update prices after updating prices from group A to update prices from group customer c etc. with sql statements.

Link to comment
Share on other sites

Alas cant get the uhtml to work with sppc, bth work seperatley, can get the tiny mce in the sppc but cant get the e-mails to go via uhtml.

 

as its more important to email newsletters by groups for this site I will have to leave it be and till someone can offere a solution.

 

It cant be so hard(lol spent most of the day trying), theres only two files after all, and each set works fine on their own. Its just the integration.

 

as for the pdf invoices by e-mail, cant get that to work with sppc either and the issue is with the entry in checkout_process.php, works fine on its own, the invoice system works on its own, just the email with invoices when using sppc.

 

so again short term I can switch the email invoices off.

 

Help someone must know the solution?

 

Johnny

 

 

 

The problem was i had put the wrong general.php function file in the catalogue/includes, god only knows how I managed it, but there you go. it works fine now

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

I'm sure it could be written but then you would have to change virtually all code to look for the "product_group" a product is in too. I don't see the value of that if you could simply create the same thing by having more customers groups.

 

Probably you can simply update insert/update prices after updating prices from group A to update prices from group customer c etc. with sql statements.

 

 

Okay, would it not be possible to have say 10 individual price groups. (customer_group)

 

these 10 price groups being assigned to the one customer at the same time.

 

currently you can only have one price group assigned to a customer.

 

so customer_group1 through to ten actaully represents the ten categories prices, and that a customer could have all ten groups assigned to them?

 

 

Johnny

Getting better with mods but no programmer am I.

Link to comment
Share on other sites

hi,

 

i dont know what the request authentication stands for. there ist an option when i'm editing a customer, but i dont know whats the meaning of "alert on" and "alert off". could somebody give me a hint? :)

 

thanks in advance

Edited by eFFeKt
Link to comment
Share on other sites

and now my problem :)

 

i've merged the latest version of sppc (Separate Pricing Per Customer v 4.2.2 BUG FIX - manual install) an the contribution qtpro. my problem is, that my attributes don't show the priced stored in the database row "options_values_price". i can't get the groups price showing up in the attributes list. i hope you understand what i mean, my english is quite bad...

 

here is my code from the pd_base.php of qtpro:

function _build_attributes_array($build_stocked, $build_nonstocked) {
  global $languages_id;
  global $currencies;
  global $cart;

  if (!($build_stocked | $build_nonstocked)) return null;

  if ($build_stocked && $build_nonstocked) {
	$stocked_where='';
  }
  elseif ($build_stocked) {
	$stocked_where="and popt.products_options_track_stock = '1'";
  }
  elseif ($build_nonstocked) {
	$stocked_where="and popt.products_options_track_stock = '0'";
  }


  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->products_id . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' " . $stocked_where . " and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
  $attributes=array();
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)$this->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++) {
	if ($products_options[$n]['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options[$n]['price_prefix'] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	}
}
// EOF SPPC attributes mod
if (isset($cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']]))
	$selected = $cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']];
else
	$selected = 0;
	$attributes[]=array('oid'=>$products_options_name['products_options_id'],
						'oname'=>$products_options_name['products_options_name'],
						'ovals'=>$products_options_array,
						'default'=>$selected);
	}
return $attributes;
}

 

hope you can help me. the rest ist working well.

Link to comment
Share on other sites

i can't get the groups price showing up in the attributes list.

From glancing over it I see this is a function in which you don't declare customer_group_id global. Probably your best bet would be to add this function (from shopping_cart.php) to the pd_base.php (I assume this is a class?):

// added for Separate Pricing Per Customer, returns customer_group_id
function get_customer_group_id() {
  if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
	$_cg_id = $_SESSION['sppc_customer_group_id'];
  } else {
	 $_cg_id = 0;
  }
  return $_cg_id;
}

Then add to that function _build_attributes_array:

// BOF Separate Pricing Per Customer
$this->cg_id = $this->get_customer_group_id();
// EOF Separate Pricing Per Customer

and instead of using $customer_group_id in the part that queries the group prices you use $this->cg_id

Link to comment
Share on other sites

i dont know what the request authentication stands for. there ist an option when i'm editing a customer, but i dont know whats the meaning of "alert on" and "alert off". could somebody give me a hint? :)

It's in the documentation (HTML version) in your download package. It's just an alert, has no effect on any function of the shop whatsoever.

Link to comment
Share on other sites

Thank you Jan, i've tried everything. i can't get it to work. seems to be impossible to me. : / maybe you got an idea where to put it in exactly?

 

when i put this into the function

   function _build_attributes_array($build_stocked, $build_nonstocked) {
  global $languages_id;
  global $currencies;
  global $cart;
  $this->cg_id = $this->get_customer_group_id();

i'll get an error-message telling me that this is an undefinied method call, so i've tried a million other possibilities, but i'm going in circles.

i'm 28 hours awak trying to get this thing done. maybe i've go to sleep a bit. hopfully you got one more tip for me. sorry for being so annoying.

Link to comment
Share on other sites

Thank you Jan, i've tried everything. i can't get it to work. seems to be impossible to me. : / maybe you got an idea where to put it in exactly?

 

when i put this into the function

   function _build_attributes_array($build_stocked, $build_nonstocked) {
  global $languages_id;
  global $currencies;
  global $cart;
  $this->cg_id = $this->get_customer_group_id();

i'll get an error-message telling me that this is an undefinied method call, so i've tried a million other possibilities, but i'm going in circles.

i'm 28 hours awak trying to get this thing done. maybe i've go to sleep a bit. hopfully you got one more tip for me. sorry for being so annoying.

The above code is fine, however you need to add the function get_customer_group_id() (the one I posted first) to that file too. Before the last } in that file.

Link to comment
Share on other sites

i cant get it. the pd_base.php is a class, which calls the price and the display of the options, instead doing this in the product_info.php. the product_info.php requires the pd_base.php to show the options. right here:

 

//++++ QT Pro: End Changed Code
// 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) {
//++++ QT Pro: Begin Changed code

  $products_id=(preg_match("/^\d{1,10}(\{\d{1,10}\}\d{1,10})*$/",$HTTP_GET_VARS['products_id']) ? $HTTP_GET_VARS['products_id'] : (int)$HTTP_GET_VARS['products_id']); 
  require(DIR_WS_CLASSES . 'pad_' . PRODINFO_ATTRIBUTE_PLUGIN . '.php');
  $class = 'pad_' . PRODINFO_ATTRIBUTE_PLUGIN;
  $pad = new $class($products_id);
  echo $pad->draw();
}

//Display a table with which attributecombinations is on stock to the customer?
if(PRODINFO_ATTRIBUTE_DISPLAY_STOCK_LIST == 'True'): require(DIR_WS_MODULES . "qtpro_stock_table.php"); endif;
//++++ QT Pro: End Changed Code

 

as i assume, this code has no effect on displying the attributes group_price. so i have to edit pd_base.php, which i've modified as far as the file is showing everythin else but the options_values_price of the products_attributes_groups table. as you can see here:

 

<?php
 class pad_base {
var $products_id;
var $products_tax_class_id;
var $show_out_of_stock;
var $mark_out_of_stock;
var $out_of_stock_msgline;
var $no_add_out_of_stock;

function pad_base($products_id=0) {
  $this->products_id = $products_id;
  if ($this->products_id != 0) {
	$tax_class_query = tep_db_query('SELECT p.products_tax_class_id, IF(s.status, s.specials_new_products_price, p.products_price) as products_price FROM ' . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id WHERE p.products_id = '" . (int)$products_id . "'");
	$tax_class_array = tep_db_fetch_array($tax_class_query);
	$this->products_tax_class_id = $tax_class_array['products_tax_class_id'];
	$this->products_original_price = $tax_class_array['products_price'];
  }
  $this->_SetConfigurationProperties('PRODINFO_ATTRIBUTE_');
}

function _SetConfigurationProperties($prefix) {
  $this->show_out_of_stock	= constant($prefix . 'SHOW_OUT_OF_STOCK');
  $this->mark_out_of_stock	= constant($prefix . 'MARK_OUT_OF_STOCK');
  $this->out_of_stock_msgline = constant($prefix . 'OUT_OF_STOCK_MSGLINE');
  $this->no_add_out_of_stock  = constant($prefix . 'NO_ADD_OUT_OF_STOCK');
}

function draw() {
  $out=$this->_draw_table_start();
  $out.=$this->_draw_stocked_attributes();
  $out.=$this->_draw_nonstocked_attributes();
  $out.=$this->_draw_table_end();
  return $out;
}

function _draw_table_start() {
  $out ='		   <table border="0" cellspacing="0" cellpadding="2">';
  $out.='			<tr>';
  $out.='			 <td class="main" colspan="2"><b>' . TEXT_PRODUCT_OPTIONS . '</b></td>';
  $out.='			</tr>';
  return $out;
}

function _draw_stocked_attributes() {
  $out = '';

  $attributes = $this->_build_attributes_array(true, false);
  if (sizeof($attributes)>0) {
	foreach ($attributes as $stocked) {
	  $out .= '<tr><td align="right" class=main><b>' . $stocked['oname'] . ":</b></td><td class=main>" . tep_draw_pull_down_menu('id['.$stocked['oid'].']',array_values($stocked['ovals']),$stocked['default']) . "</td></tr>\n";
	}
  }
  return $out;
}

function _draw_nonstocked_attributes() {
  $out='';
  $nonstocked_attributes = $this->_build_attributes_array(false, true);
  foreach($nonstocked_attributes as $nonstocked)
  {
	$out.='<tr><td align="right" class=main><b>'.$nonstocked['oname'].":</b></td><td class=main>".tep_draw_pull_down_menu('id['.$nonstocked['oid'].']',$nonstocked['ovals'],$nonstocked['default'])."</td></tr>\n";
  }
  return $out;
}

function _draw_table_end() {
  return '		   </table>';
}
/*

 HERE IS THE PART OF CODE I NEED TO DISPLAY THE ATTRIBUTES AND OPTIONS FOR MY NEEDS

*/
function _build_attributes_array($build_stocked, $build_nonstocked) {
  global $languages_id;
  global $currencies;
  global $cart;


  if (!($build_stocked | $build_nonstocked)) return null;

  if ($build_stocked && $build_nonstocked) {
	$stocked_where='';
  }
  elseif ($build_stocked) {
	$stocked_where="and popt.products_options_track_stock = '1'";
  }
  elseif ($build_nonstocked) {
	$stocked_where="and popt.products_options_track_stock = '0'";
  }



  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_track_stock from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$this->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 " . $stocked_where . " order by popt.products_options_name");

  $attributes=array();

  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)$this->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");



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

	while ($products_options = tep_db_fetch_array($products_options_query)) {

	$products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

if(PRODINFO_ATTRIBUTE_ACTUAL_PRICE_PULL_DOWN == 'True'){
//Option prices will displayed as a final product price. This can (currently) only be used with a satisfying result if you have only one option per product.

 if ($products_options['price_prefix'] == '-') {// in case price lowers, don't add values, subtract.
$show_price = 0.0 + $this->products_original_price - $products_options['options_values_price']; // force float (in case) using the 0.0;
 } else {
$show_price = 0.0 + $this->products_original_price + $products_options['options_values_price']; // force float (in case) using the 0.0;
 }

 $products_options_array[sizeof($products_options_array)-1]['text'] .= ' '.$currencies->display_price( $show_price, tep_get_tax_rate($this->products_tax_class_id)).' ';

	}else{ //Display the option prices as differece prices with +/- prefix as usually
	  if ($products_options['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($this->products_tax_class_id)) .')';
	  }
	}


	}
	if (isset($cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']]))
	  $selected = $cart->contents[$this->products_id]['attributes'][$products_options_name['products_options_id']];
	else 
	  $selected = 0;
	$attributes[]=array('oid'=>$products_options_name['products_options_id'],
						'oname'=>$products_options_name['products_options_name'],
						'ovals'=>$products_options_array,
						'default'=>$selected);
  }
  return $attributes;
}


/*

 HERE IT ENDS, AND THE FILE IS STARTING TO CREATE DIFFERENT DISPLAY-OPTIONS

*/
function _build_attributes_combinations($attributes, $showoos, $markoos, &$combinations, &$selected_combination, $oidindex=0, $comb=array(), $id="", $text='', $isselected=true) {
  global $cart;

  foreach ($attributes[$oidindex]['ovals'] as $attrib) {
	$newcomb = $comb;
	$newcomb[$attributes[$oidindex]['oid']] = $attrib['id'];
	$newid=$id.','.$attributes[$oidindex]['oid'].'-'.$attrib['id'];
	$newtext = $text.", ".$attrib['text'];
	if (isset($cart->contents[$this->products_id]['attributes'][$attributes[$oidindex]['oid']]))
	  $newisselected = ($cart->contents[$this->products_id]['attributes'][$attributes[$oidindex]['oid']] == $attrib['id']) ? $isselected : false;
	else 
	  $newisselected = false;
	if (isset($attributes[$oidindex+1])) {
	  $this->_build_attributes_combinations($attributes, $showoos, $markoos, $combinations, $selected_combination, $oidindex+1, $newcomb, $newid, $newtext, $newisselected);
	}
	else {
	  $is_out_of_stock=tep_check_stock(tep_get_prid($this->products_id),1,$newcomb);
	  if (!$is_out_of_stock | ($showoos == true)) {
		switch ($markoos) {
		  case 'Left':   $newtext=($is_out_of_stock ? TEXT_OUT_OF_STOCK.' - ' : '').substr($newtext,2);
						 break;
		  case 'Right':  $newtext=substr($newtext,2).($is_out_of_stock ? ' - '.TEXT_OUT_OF_STOCK : '');
						 break;
		  default:	   $newtext=substr($newtext,2);
						 break;
		}
		$combinations[] = array('comb'=>$newcomb, 'id'=>substr($newid,1), 'text'=>$newtext);
		if ($newisselected) $selected_combination = sizeof($combinations)-1;
	  }
	}
  }
}



function _draw_js_stock_array($combinations) {
  if (!((isset($combinations)) && (is_array($combinations)) && (sizeof($combinations) > 0))){
	return '{}';
  }
  $out='';
  foreach ($combinations[0]['comb'] as $oid=>$ovid) {
	$out.='{'.$ovid.':';
	$opts[]=$oid;
  }
  $out.='1';

  for ($combindex=1; $combindex<sizeof($combinations); $combindex++) {
	$comb=$combinations[$combindex]['comb'];
	for ($i=0; $i<sizeof($opts)-1; $i++) {
	  if ($comb[$opts[$i]]!=$combinations[$combindex-1]['comb'][$opts[$i]]) break;
	}
	$out.=str_repeat('}',sizeof($opts)-1-$i).',';
	if ($i<sizeof($opts)-1) {
	  for ($j=$i; $j<sizeof($opts)-1; $j++)
		$out.=$comb[$opts[$j]].':{';
	}
	$out.=$comb[$opts[sizeof($opts)-1]].':1';
  }
  $out.=str_repeat('}',sizeof($opts));

  return $out;
}

 }
?>

 

i have highlighted the part, which is important to me. the code after it, is building an other display-option. as far as i understand php this:

return $attributes;

 

is the command to show the all i've done before. my php knowledge is a bit unincisive to understand how that code is working exactly. so i have to guess whats going on and where to put code into it. so i placed the code of the shopping cart into the file. my problem is, that i dont know hoow to call the groups price when there is one instead of the actual price, that happend here:

 

if(PRODINFO_ATTRIBUTE_ACTUAL_PRICE_PULL_DOWN == 'True'){
//Option prices will displayed as a final product price. This can (currently) only be used with a satisfying result if you have only one option per product.

 if ($products_options['price_prefix'] == '-') {// in case price lowers, don't add values, subtract.
$show_price = 0.0 + $this->products_original_price - $products_options['options_values_price']; // force float (in case) using the 0.0;
 } else {
$show_price = 0.0 + $this->products_original_price + $products_options['options_values_price']; // force float (in case) using the 0.0;
 }

 

so i've tryed to include an } else { and a code that have to call the groups-prce. but everything i do, it doesnt take effekt or i'm getting error-messages. i think the problem is, that i think a bit to complicated... i also don't now how to include your return $_cg_id; beacause the price is returned by this: return $attributes;.

Edited by eFFeKt
Link to comment
Share on other sites

this is driving me totaly crazy.

What's the point of replying on your questions if you totally ignore what I'm telling you?

 

You are ignoring the scope of variables. $customer_group_id means nothing inside a class and/or a function. See the php-website for examples.

Edited by Jan Zonjee
Link to comment
Share on other sites

sorry jan, i accidentally posted the code of my backup-file, where i was trying around before i posted the first time, and doesn't noticed it...

 

thank you for helping me out. i read the part of the php-manual and understood why should i do this.

 

so, i've added the parts you told me. this part "$this->cg_id = $this->get_customer_group_id();" i put right below global $cart;, as you saw it before, the other part i wrote down after "return $_cg_id; }" (btw. why this part has to be at the bottom? wouldnt it be more logical to declare it befor i use it? or is it not important?).

 

so, now i can see, that the pd_base is handling my groups_id, after i did what you advised me to do. later then i noticed that i havn't set an array to get informations from products_attributes_groups... this is the reason this code doesnt change the standard options_values_price to the options_values_price of the products_attributes_groups. (it was late, i was almost over 30 hours awake working on this code - couldnt see the forest for the trees) :blush:

 

okay, so i added this to my code, to query this table:

if ($this->cg_id != '0')  { // check for a group price
	$pg_query = tep_db_query("select products_attributes_id, customers_group_id, options_values_price, price_prefix, products_id as price from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag where products_id = '" . (int)$this->products_id . "' and pag.customers_group_id = '" . $this->cg_id . "'");
	$customer_group_price_result = tep_db_fetch_array($pg_query);
if (tep_not_null($customer_group_price_result['options_values_price'])) {
	$products_options['options_values_price'] = $customer_group_price_result['options_values_price'];
} // end if (tep_not_null($customer_group_price_result['options_values_price']))
} // end if ($customer_group_id != '0')

 

the price is now showing correctly as far as i'm logged in as retailer (cg_id=0). unfortunately, as i login as another member the script shows only the price of the lowest products_attributes_id for all attributes and ignores the price_prefix (it only adds, don't substrac, no matter what i'm using).

 

here is the whole necessary part of where i display the prices:

if(PRODINFO_ATTRIBUTE_ACTUAL_PRICE_PULL_DOWN == 'True'){
//Option prices will displayed as a final product price. This can (currently) only be used with a satisfying result if you have only one option per product.

if ($this->cg_id != '0')  { // check for a group price
	$pg_query = tep_db_query("select products_attributes_id, customers_group_id, options_values_price, price_prefix, products_id as price from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag where products_id = '" . (int)$this->products_id . "' and pag.customers_group_id = '" . $this->cg_id . "'");
	$customer_group_price_result = tep_db_fetch_array($pg_query);
if (tep_not_null($customer_group_price_result['options_values_price'])) {
	$products_options['options_values_price'] = $customer_group_price_result['options_values_price'];
} // end if (tep_not_null($customer_group_price_result['options_values_price']))
} // end if ($customer_group_id != '0')

if ($products_options['price_prefix'] == '-') {// in case price lowers, don't add values, subtract.
	$show_price = 0.0 + $this->products_original_price - $products_options['options_values_price']; // force float (in case) using the 0.0;
} else {
	$show_price = 0.0 + $this->products_original_price + $products_options['options_values_price']; // force float (in case) using the 0.0;
} // if ($products_options['price_prefix'] == '-')

$products_options_array[sizeof($products_options_array)-1]['text'] .= ' '.$currencies->display_price( $show_price, tep_get_tax_rate($this->products_tax_class_id)).' ';

 

i hope you will help me one more time. i guess it would be the last time ;)

 

disgracefulness how this short piece of code can bother me so long. just wonder how i could get an A for coding at school :lol:

Link to comment
Share on other sites

the price is now showing correctly as far as i'm logged in as retailer (cg_id=0). unfortunately, as i login as another member the script shows only the price of the lowest products_attributes_id for all attributes and ignores the price_prefix (it only adds, don't substrac, no matter what i'm using).

I don't see what your complete code is now but I see many problems (which will fail silently) in your code. For starters, you cannot use the special price table in the function pad_base. The function that gets the special price for a products_id already deals with customer group id, so you should use that to check for special prices and add code for the customer_group_price of course.

 

I noticed that the function _build_attributes_array($build_stocked, $build_nonstocked) very much resembles the code on the standard osCommerce product_info.php page. So look how SPPC does that there to implement that in pad_base.php too.

 

Basically there are two (while) loops for the product_attributes. The first one queries the names so you get different drop-downs. While fetching those names a query is done using the name to get the different values, prices and prefixes. SPPC cuts in there: (while ($products_options = tep_db_fetch_array($products_options_query)) {) to store the results in an array first and get a $list_of_prdcts_attributes_id which is then used to query the table for group prices. In case of the customer group id being other than zero, the table is queried and a double loop is used (the two for loops) to exchange retail prices and prefixes with group prices/prefixes.

 

Then the looping over the products_options_array is done again using a for loop (for ($n = 0 ; $n < count($products_options); $n++) {).

 

You seem to have mixed this up pretty badly but then it took me years to fathom the logic of the product attributes system :)

 

The (class) function for the customer group id can be put almost anywhere (not as the first one though) in the class. Doesn't need to be at the bottom.

 

Inside a function you could also use

// BOF Separate Pricing Per Customer 
  $customer_group_id = $this->get_customer_group_id();
// EOF Separate Pricing Per Customer

That would save you from changing the $customer_group_id to $this->cg_id in the SPPC code that you cut and paste from product_info.php.

Link to comment
Share on other sites

Hi there,

 

I've installed sppc and it works great.

But now...

For example:

I have 4 different groups created.

StandardPrice

G10

G15

G20

 

Now, if i put a user in G20 and a price is not filled in for this group he gives the standard price to that user.

I want it like this,

If the price for G20 is not filled in he will get the G10 price instead of getting back to standard prices.

 

Anyone know how to do this?

 

Thanks in advance!

Link to comment
Share on other sites

Now, if i put a user in G20 and a price is not filled in for this group he gives the standard price to that user.

I want it like this,

If the price for G20 is not filled in he will get the G10 price instead of getting back to standard prices.

 

Anyone know how to do this?

Add those prices to the database...

 

There is no quick fix for this.

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

 

I'm having issues making SPPC work with the X-Sell v2-MS2 contribution...

 

I can get the proper regular pricing to show up on my x-sell items for all customer groups but I cannot get the specials to show up correctly (ie. when I set a special for only "wholesale" it will show up for all groups on the x-sell items). Does anyone have a clue how to correct this?

 

Thanks.

Link to comment
Share on other sites

hello,

 

i installed sppc and want to add this now: http://addons.oscommerce.com/info/4061 (Stock Viewer with Quantity per attribute). There is a part of code, i don't know where/how to put it in.

 

this is my original code of my product_info.php

<?php
  $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_name");
  while ($products_options_name = tep_db_fetch_array($products_options_name_query)) {
	$products_options_array = array();
	$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$products_options_name['products_options_id'] . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.attribute_sort, pa.options_values_price");
	$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']);
	  //// BOF Actual Price Pull Down v1.2.3a
$new_price ? $original_price = $new_price : $original_price = $product_info['products_price']; //// check if set special price

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

//// BOF Actual Price Pull Down v1.2.3a


//// EOF Actual Price Pull Down v1.2.3a

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

 

and this is the part i have to put in:

 

-BEGIN SOURCE CODE-
	$products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix 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 . "'");
	while ($products_options = tep_db_fetch_array($products_options_query)) {
	  $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
	  if ($products_options['options_values_price'] != '0') {
		$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
	  }
-END SOURCE CODE-

Change with:

-BEGIN SOURCE CODE-
	$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.options_quantity 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 . "'");
	while ($products_options = tep_db_fetch_array($products_options_query)) {
	  if($products_options['options_quantity'] == 0) {
	  // If quantity is 0 do not add to list. 
	  }
	  else {
			  $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
			  if ($products_options['options_values_price'] != '0') {
				$products_options_array[sizeof($products_options_array)-1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';
			  }

	  }
-END SOURCE CODE-

 

this contribution hides an option if there is no quantity. but i dont know how to type this in with sppc. anybody can help?

Edited by sak1981
Link to comment
Share on other sites

There is a part of code, i don't know where/how to put it in.

I think this should do the same thing (adding pa.options_quantity to the same query basically and not adding the results to the results array we will with later if that quantity is zero):

        $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.options_quantity, 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 order by pa.attribute_sort, pa.options_values_price");
        $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)) {
	  if ($_products_options['options_quantity'] == 0) {
          // If quantity is 0 do not add to list. 
          }
          else {
        	$products_options[] = $_products_options;
        	$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
	 }
    } // end while ($_products_options = tep_db_fetch_array($products_options_query))

Link to comment
Share on other sites

I think this should do the same thing (adding pa.options_quantity to the same query basically and not adding the results to the results array we will with later if that quantity is zero):

        $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.options_quantity, 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 order by pa.attribute_sort, pa.options_values_price");
        $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)) {
	  if ($_products_options['options_quantity'] == 0) {
          // If quantity is 0 do not add to list. 
          }
          else {
        	$products_options[] = $_products_options;
        	$list_of_prdcts_attributes_id .= $_products_options['products_attributes_id'].",";
	 }
    } // end while ($_products_options = tep_db_fetch_array($products_options_query))

 

lol, as easy as it is, this is exactly what i've been looking for. i tried to put it everywhere after it. thank you jan. :blush:

Link to comment
Share on other sites

Hi All,

 

First let me say what a great mod this is, and many thanks to all who support it!

 

I am a novice at PHP, but know about enough to get me in trouble!

 

I have installed the SPPC mod (v4.15) to an osC-2.2 version with a few mods already installed. I "slowly" preformed the manual install, and (so far) these are my issues:

 

* I have added a "wholesale-1" along with the "retail" price group, but when I try to change a customers group from "RETAIL" to "wholesale-1", then click update, I get the following errors (and the customer group stays at "retail"......

 

Warning: file(includes/tld.txt): failed to open stream: No such file or directory in /home/content/P/o/c/Joe/html/lifestyle/admin/includes/functions/validations.php on line 85

 

Warning: Variable passed to each() is not an array or object in /home/content/P/o/c/Joe/html/lifestyle/admin/includes/functions/validations.php on line 86

 

Warning: eregi(): REG_EMPTY in /home/content/P/o/c/Joe/html/lifestyle/admin/includes/functions/validations.php on line 97

 

 

I have read through "many" of the 265 pages of this thread, and searched for the above errors, but have not found any results!

 

I hope someone can please Help!!!!!! :(

Link to comment
Share on other sites

Warning: file(includes/tld.txt): failed to open stream: No such file or directory in /path_to_admin/includes/functions/validations.php on line 85

I think that if you put back your backup for that page you will get the same error when you try to edit a user.

Those line in validatons.php try to load this particular file (you did check the file is there in your admin/includes/ directory? and is readable by the webserver?)

				// Get authorized TLDs from text file
			$tlds = file(DIR_WS_INCLUDES . 'tld.txt');

Perhaps the webserver can't file that file. In that case it might help if you change the second line in $tlds = file(DIR_FS_ADMIN . DIR_WS_INCLUDES . 'tld.txt');

Link to comment
Share on other sites

Thanks for the quick reply, Jan! I changed the code as you suggested, and I got the same errors (well almost....)... The first error originally referred to the path "includes/tld.txt", where the updated code you gave then produced the path "admin/includes/tld.txt"

 

I put a copy of tld.txt into the admin/includes folder, and ....... No more errors!! :)

 

That is the good news..... The bad? Well, when I change a customer from Retail to Wholesale and update, I get no errors, but the status is NOT changed, and the customer remains as "Retail"! :(

 

Thanks again for your help! :)

 

 

I think that if you put back your backup for that page you will get the same error when you try to edit a user.

Those line in validatons.php try to load this particular file (you did check the file is there in your admin/includes/ directory? and is readable by the webserver?)

				// Get authorized TLDs from text file
			$tlds = file(DIR_WS_INCLUDES . 'tld.txt');

Perhaps the webserver can't file that file. In that case it might help if you change the second line in $tlds = file(DIR_FS_ADMIN . DIR_WS_INCLUDES . 'tld.txt');

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