Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Jan you are always so helpful, i thank you! however, its not working crying.gif I have the wholesale greeting in lang/english.php file, and i can log in as a wholesale buyer but it is returning the same result for logged in retail and wholesale accounts. in admin, my groups are listed as retail 4 and wholesale 2. what am i missing? site goes online saturday and my brain is misfiring after days of computer code. plus I really dont know what i am

I have made a small function that list which group the logged in customer belongs in. Maybe you can use this?

function tep_customer_group_name() { 
 global $sppc_customer_group_id, $customer_first_name; 

 if (tep_session_is_registered('customer_first_name')) { //Logged inn Retail
$group_name_string = sprintf(MEMBER_RETAIL_REGISTERED, tep_output_string_protected($customer_first_name), tep_href_link(FILENAME_PRODUCTS_NEW)); 
if (tep_session_is_registered('sppc_customer_group_id')) { 
  	if ( $sppc_customer_group_id == '1' ) { 
  	$group_name_string = sprintf(MEMBER_VIP_MEDIUM, tep_output_string_protected($customer_first_name)); 
 	}
  	if ( $sppc_customer_group_id == '2' ) { 
  	$group_name_string = sprintf(MEMBER_VIP_BRONZE, tep_output_string_protected($customer_first_name)); 
 	} 
  	if ( $sppc_customer_group_id == '3' ) { 
  	$group_name_string = sprintf(MEMBER_VIP_SILVER, tep_output_string_protected($customer_first_name));   
       }
if ( $sppc_customer_group_id == '4' ) { 
  	$group_name_string = sprintf(MEMBER_VIP_GOLD, tep_output_string_protected($customer_first_name)); 
 	} 
} // end if ( tep_session_is_registered('sppc_customer_group_id') ) 
 } else { // Unregistered (Guest)
$group_name_string = sprintf(MEMBER_RETAIL, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL')); 
 } 
 return $group_name_string; 
 }

 

Maybe you get the idea of this code to make it what you want..

Link to comment
Share on other sites

Jan you are always so helpful, i thank you! however, its not working crying.gif I have the wholesale greeting in lang/english.php file, and i can log in as a wholesale buyer but it is returning the same result for logged in retail and wholesale accounts. in admin, my groups are listed as retail 4 and wholesale 2. what am i missing? site goes online saturday and my brain is misfiring after days of computer code. plus I really dont know what i am

BTW, put this in your catalog/includes/languages/english.php (and other language files):

// Members
define('MEMBER_RETAIL', '(Retail No member)');
define('MEMBER_RETAIL_REGISTERED', '(Retail Member)');
define('MEMBER_VIP_MEDIUM', '(VIP Medium Member)');
define('MEMBER_VIP_BRONZE', '(VIP Bronze Member)');
define('MEMBER_VIP_SILVER', '(VIP Silver Member)');
define('MEMBER_VIP_GOLD', '(VIP Gold Member)');

..and define your own text for each group. Hope this helps...

Link to comment
Share on other sites

Looks like you want to do this:

 

// Return a customer greeting
function tep_customer_greeting() {
 global $sppc_customer_group_id, $customer_first_name;

 if (tep_session_is_registered('customer_first_name')) {
    $greeting_string = sprintf(TEXT_GREETING_PERSONAL, tep_output_string_protected($customer_first_name), tep_href_link(FILENAME_PRODUCTS_NEW));
   if (tep_session_is_registered('sppc_customer_group_id')) {
      if ( $sppc_customer_group_id == '2' ) {
      $greeting_string = sprintf(TEXT_GREETING_WHOLESALE, tep_output_string_protected($customer_first_name));
     }
   } // end if ( tep_session_is_registered('sppc_customer_group_id') )
 } else {
   $greeting_string = sprintf(TEXT_GREETING_GUEST, tep_href_link(FILENAME_LOGIN, '', 'SSL'), tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));
 }
 return $greeting_string;
 }

 

 

Ok this does work perfectly

thank you

 

question - in "my php admin" on the customers groups table 0=retail, 1=wholesale.

in "osc admin" at bottom of customer list it says

 

Customer Group No.

Retail 4

Wholesale 2

what? how? where is 2& 4 used and obviously 0&1 are used in cat/incl/funct/general.

I know the 2& 4 happened when i first started naming the groups and deleted and renamed ect.

if i create a third group will it be 5 in admin and 2 in php table?

carie

Link to comment
Share on other sites

question - in "my php admin" on the customers groups table 0=retail, 1=wholesale.

in "osc admin" at bottom of customer list it says

 

Customer Group No.

Retail 4

Wholesale 2

what? how? where is 2& 4 used and obviously 0&1 are used in cat/incl/funct/general.

I know the 2& 4 happened when i first started naming the groups and deleted and renamed ect.

if i create a third group will it be 5 in admin and 2 in php table?

OK, a misunderstanding here. The No. refers to the number of customers in the group Retail and Wholesale. Not the customer_group_id (which frankly is not really an interesting number for the shop owner).

Link to comment
Share on other sites

OK, a misunderstanding here. The No. refers to the number of customers in the group Retail and Wholesale. Not the customer_group_id (which frankly is not really an interesting number for the shop owner).

i hope that made you laugh. i was so very confused. i tried changing the 2 to a one yesterday but then uploaded the general file to admin so it really didnt work and i didnt find that error till this morning.

thanks again.

carie

Link to comment
Share on other sites

Im back again. spent hours on such a little thing. i need to sort my product option value by the value number. i already have must select installed with "please select an option" as the option value #1, and want it to be default.

in product info everything i found is similar to this (

 

$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 . "' order by pa.attribute_sort, pa.options_values_price");

 

shouldn't it be by pa.products_options_values?

and sppc is like this

 

$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][' '] . $currencies->display_price($products_options[$n]['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') ';

}

}

// EOF SPPC attributes mod

 

if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']])) {

$selected_attribute = $cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$products_options_name['products_options_id']];

} else {

$selected_attribute = false;

}

?>

carie

Link to comment
Share on other sites

Im back again. spent hours on such a little thing. i need to sort my product option value by the value number. i already have must select installed with "please select an option" as the option value #1, and want it to be default.

in product info everything i found is similar to this (

 

$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 . "' order by pa.attribute_sort, pa.options_values_price");

 

I have this line here for sorting:

 $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 pov.products_options_values_name");

Is this what you are looking for?

Link to comment
Share on other sites

I have this line here for sorting:

 $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 pov.products_options_values_name");

Is this what you are looking for?

that works

thank you

dont know how i missed it (up too late)

carie

Link to comment
Share on other sites

i installed QPB for SPPC and with it the add to cart button in package. now the add to cart button on product info page (only) is adding an extra item to cart. says1 adds 2, says 4 adds 5. now it only happens the first time for the item. if you have 3 in cart and add 1 more it only adds one.

thanks

carie

 

i am almost out of your hair

the site should have gone up last sat

Link to comment
Share on other sites

i installed QPB for SPPC and with it the add to cart button in package. now the add to cart button on product info page (only) is adding an extra item to cart. says1 adds 2, says 4 adds 5. now it only happens the first time for the item. if you have 3 in cart and add 1 more it only adds one.

thanks

carie

 

i am almost out of your hair

the site should have gone up last sat

 

do i need to add something for easy populate now that i have QPB

carie

Link to comment
Share on other sites

Jan and all,

 

Thank you for your great work on these forums... very few people here are as helpful...

I too am hoping for a little help...

 

I have a customers site thats almost complete. I have two modules that seem to not be "Specials" price aware and I would like to learn how to resolve this. I have SPPC 4.22 and SPPC Price break 2.0. Somewhere in this specials issue there is the "Priceformatter class" ??? as well, which has given me some minor grief previously.

 

I would like to see if I can make the follwong two modules "Specials" price aware... ie show the regular price unless a specials price exits:

Web 2.0 Scrolling Best Sellers 1.1

2gether Discount 2.04

 

As much as I hate pasting long code, here are the relevent snippets I think:

 

Web 2.0 Scrolling Best Sellers 1.1

<!-- new products //-->
         <tr>
           <td>
           <?php
		if (isset($current_category_id) && (current_category_id >0)){
$rp_query =tep_db_query("select distinct p.products_id, p.products_price, p.products_image, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_status = '1' and c.categories_status = 1 and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and '" . (int)$current_category_id . "' in (c.categories_id, c.parent_id) order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
} else {
		$rp_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_price, p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
	} 

 if (tep_db_num_rows($rp_query)) {

$i = 0;
   while ($random_product = tep_db_fetch_array($rp_query)) {
$pausecontent_bs[$i] = "<center><br><a href=\'" . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"]) . "\'>" . tep_image(DIR_WS_IMAGES . $random_product['products_image'], tep_output_string($random_product['products_name'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>', '&' => '&')), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . "</a><br/><a href=\'" . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . "\'>" . tep_output_string($random_product['products_name'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>', '&' => '&')) . "</a><br/>";
if (intval($random_product['specials_new_products_price']) > 0) {
	$pausecontent_bs[$i] .= "<s>" . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . "</s><br/><span class=\'productSpecialPrice\'>" . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id']))."</span></center><br/><br/>";
   } else {
	$pausecontent_bs[$i] .= "<span class=\'productSpecialPrice\'>" . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . "</s><br/></center><br/><br/>";
   }
	$i++;
   }

?>
<?php
 }
?>

 

2gether Discount 2.04

too much code to post... maybe if I can fix the above I will be able to carry the solution to this, so I will refrain for the moment.

 

Thank you for any feedback or a kick in the right direction.

 

Dave

-Dave

Link to comment
Share on other sites

I would like to see if I can make the follwong two modules "Specials" price aware... ie show the regular price unless a specials price exits:

Web 2.0 Scrolling Best Sellers 1.1

I would use something along this line (could contain bugs, haven't tried it). Modeled according to includes/products_new.php:

 

<!-- new products //-->
         <tr>
           <td>
           <?php
 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
   $customer_group_id = $_SESSION['sppc_customer_group_id'];
 } else {
   $customer_group_id = '0';
 }

                       if (isset($current_category_id) && (current_category_id >0)){
       $rp_query =tep_db_query("select distinct p.products_id, p.products_price, p.products_image, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_status = '1' and c.categories_status = 1 and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and '" . (int)$current_category_id . "' in (c.categories_id, c.parent_id) order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
       } else {
                       $rp_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_price, p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
               } 

 if (tep_db_num_rows($rp_query)) {

   //    $i = 0;
   while ($_random_product = tep_db_fetch_array($rp_query)) {
     $random_product[] = $_random_product;
  $list_of_prdct_ids[] = $_random_product['products_id'];    
   } // end while ($random_product = tep_db_fetch_array($rp_query))
   $no_of_random_products = count($random_product);

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

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

// an extra query is needed for all the specials
$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where products_id in (" . implode(',', $list_of_prdct_ids) . ") and status = '1' and customers_group_id = '" .$customer_group_id. "' ");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
}

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

   for ($i = 0; $i < $no_of_random_products; $i++) {
       $pausecontent_bs[$i] = "<center><br><a href=\'" . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"]) . "\'>" . tep_image(DIR_WS_IMAGES . $random_product['products_image'], tep_output_string($random_product['products_name'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>', '&' => '&')), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . "</a><br/><a href=\'" . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . "\'>" . tep_output_string($random_product['products_name'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>', '&' => '&')) . "</a><br/>";
       if (intval($random_product['specials_new_products_price']) > 0) {
               $pausecontent_bs[$i] .= "<s>" . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . "</s><br/><span class=\'productSpecialPrice\'>" . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id']))."</span></center><br/><br/>";
       } else {
               $pausecontent_bs[$i] .= "<span class=\'productSpecialPrice\'>" . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . "</s><br/></center><br/><br/>";
      }
//  $i++;
   } // end for ($i = 0; $i < $no_of_random_products; $i++)

?>
<?php
 }
?>

Link to comment
Share on other sites

Im sorry I meant this one

Quick Group Discounts module for sppc

http://addons.oscommerce.com/info/5569

I can't say I'm familiar with that one but I'm quite sure it won't. I would add the popup window with group prices in there if you want to do it on that page. Don't know how hard that would be.

Link to comment
Share on other sites

i installed QPB for SPPC and with it the add to cart button in package. now the add to cart button on product info page (only) is adding an extra item to cart. says1 adds 2, says 4 adds 5. now it only happens the first time for the item. if you have 3 in cart and add 1 more it only adds one.

thanks

carie

 

i am almost out of your hair

the site should have gone up last sat

Are you sure the code in application_top.php has been adapted correctly for this?

 

I'm not familiar with Easy populate so can't say anything about that.

Link to comment
Share on other sites

I would use something along this line (could contain bugs, haven't tried it). Modeled according to includes/products_new.php:

 

Thank you Jan! I was able to resolve the special price not appearing with your suggested code. Just a couple of tweaks from your post to get apecials price working. The code I now have is posted below.

 

It is working EXCEPT for the product(s) being "scrolled" is now just one item repeatedly... ie the same as whatever is appearing in products_new box... How should I modify the below so that the items being scrolled are the "Best Sellers"?

 

Ive tried to compare the original scrolling file to the new modified but dont have the php aptitude skills to see/understand what Im trying to do :(

 

Thank you for your help!

 

Where I am at:

<!-- new products - being adapted to web 2.0 scrolling best sellers//-->
         <tr>
	   <td>
<?php
// BOF SPPC
 if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
     $customer_group_id = $_SESSION['sppc_customer_group_id'];
    } else {
	    $customer_group_id = '0';
	}
// EOF SPPC  
            if (isset($current_category_id) && (current_category_id >0)){
		         $rp_query =tep_db_query("select distinct p.products_id, p.products_price, p.products_image, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_status = '1' and c.categories_status = 1 and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and '" . (int)$current_category_id . "' in (c.categories_id, c.parent_id) order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
	} else {
                    $rp_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_price, p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
		    }

  if (tep_db_num_rows($rp_query)) {

//    $i = 0;
   while ($_random_product = tep_db_fetch_array($rp_query)) {
      $random_product[] = $_random_product;
	           $list_of_prdct_ids[] = $_random_product['products_id'];
} // end while ($random_product = tep_db_fetch_array($rp_query))
$no_of_random_products = count($random_product);

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

  for ($x = 0; $x < $no_of_random_products; $x++) {       

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

// an extra query is needed for all the specials
       $specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where products_id in (" . implode(',', $list_of_prdct_ids) . ") and status = '1' and customers_group_id = '" .$customer_group_id. "' ");
	while ($specials_array = tep_db_fetch_array($specials_query)) {
	$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
   }

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

for ($i = 0; $i < $no_of_random_products; $i++) {

//// Note issue with single quote vs double quote here: => '"', (2 occurences) single quotes were causing grief ////  
     $pausecontent_bs[$i] = "<center><br><a href=\'" . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"]) . "\'>" . tep_image(DIR_WS_IMAGES . $random_product['products_image'], tep_output_string($random_product['products_name'], array('"' => '"', '\'' => '"', '<' => '<', '>' => '>', '&' => '&')), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . "</a><br/><a href=\'" . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . "\'>" . tep_output_string($random_product['products_name'], array('"' => '"', '\'' => '"', '<' => '<', '>' => '>', '&' => '&')) . "</a><br/>";

if (intval($random_product['specials_new_products_price']) > 0) {
	 $pausecontent_bs[$i] .= "<s>" . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . "</s><br/><span class=\'productSpecialPrice\'>" . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id']))."</span></center><br/><br/>";
} else {
	 $pausecontent_bs[$i] .= "<span class=\'productSpecialPrice\'>" . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . "</s><br/></center><br/><br/>";
}
//  $i++;
} // end for ($i = 0; $i < $no_of_random_products; $i++)


?>
<?php
 }
?>

<script type="text/javascript">
//<![CDATA[
/* merge server php and client javascript arrays */
var pausecontent_bs=new Array();
<?php
$i = 0;
while ($pausecontent_bs[$i]) {
echo "pausecontent_bs[".$i."] = '".$pausecontent_bs[$i]."';

";
$i++;
}
?>

 

Original web 2.0 scrolling best sellers code:

<!-- new products //-->
         <tr>
           <td>
           <?php
		if (isset($current_category_id) && (current_category_id >0)){
$rp_query =tep_db_query("select distinct p.products_id, p.products_price, p.products_image, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and '" . (int)$current_category_id . "' in (c.categories_id, c.parent_id) order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
} else {
		$rp_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_price, p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_ordered > 0 and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
	} 

 if (tep_db_num_rows($rp_query)) {

$i = 0;
   while ($random_product = tep_db_fetch_array($rp_query)) {
$pausecontent_bs[$i] = "<center><br><a href=\'" . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product["products_id"]) . "\'>" . tep_image(DIR_WS_IMAGES . $random_product['products_image'], tep_output_string($random_product['products_name'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>', '&' => '&')), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . "</a><br/><a href=\'" . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . "\'>" . tep_output_string($random_product['products_name'], array('"' => '"', '\'' => ''', '<' => '<', '>' => '>', '&' => '&')) . "</a><br/>";
if (intval($random_product['specials_new_products_price']) > 0) {
	$pausecontent_bs[$i] .= "<s>" . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . "</s><br/><span class=\'productSpecialPrice\'>" . $currencies->display_price($random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id']))."</span></center><br/><br/>";
   } else {
	$pausecontent_bs[$i] .= "<span class=\'productSpecialPrice\'>" . $currencies->display_price($random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . "</s><br/></center><br/><br/>";
   }
	$i++;
   }

?>
<?php
 }
?>
<script type="text/javascript">
//<![CDATA[
/* merge server php and client javascript arrays */
var pausecontent_bs=new Array();
<?php
$i = 0;
while ($pausecontent_bs[$i]) {
echo "pausecontent_bs[".$i."] = '".$pausecontent_bs[$i]."';

";
$i++;
}
?>

-Dave

Link to comment
Share on other sites

Thank you Jan! I was able to resolve the special price not appearing with your suggested code. Just a couple of tweaks from your post to get apecials price working. The code I now have is posted below.

Yes, I didn't take a look at that true. Was getting bedtime for me :)

 

Looks like you need to add [$i] to the $random_products in this piece of code, otherwise you will see the same item repeated $no_of_random_products.

       if (intval($random_product[$i]['specials_new_products_price']) > 0) {
                $pausecontent_bs[$i] .= "<s>" . $currencies->display_price($random_product[$i]['products_price'], tep_get_tax_rate($random_product[$i]['products_tax_class_id'])) . "</s><br/><span class=\'productSpecialPrice\'>" . $currencies->display_price($random_product[$i]['specials_new_products_price'], tep_get_tax_rate($random_product[$i]['products_tax_class_id']))."</span></center><br/><br/>";
       } else {
                $pausecontent_bs[$i] .= "<span class=\'productSpecialPrice\'>" . $currencies->display_price($random_product[$i]['products_price'], tep_get_tax_rate($random_product[$i]['products_tax_class_id'])) . "</s><br/></center><br/><br/>";
       }
//  $i++;

Link to comment
Share on other sites

Looks like you need to add [$i] to the $random_products in this piece of code, otherwise you will see the same item repeated $no_of_random_products.

 

Jan, Thank you very much for the assistance. I tried your suggested code and it seems to break it more than improve. The same item repeating remained, but the prices shown were totally random and changing with each scroll of the item...very bizaare results were occuring.

 

The original tweaked code you suggested as posted above (without the suggested [$i]'s) works perfectly as far as format, image, price, and specials price appearing, just the item was repeating instead of displaying the "best Sellers" as determined by the initial queries ending "

order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);". For max-bestsellers I have 6, so should see the top 6 selling items in the scroll box.

 

I hope that makes sense and any suggestions are quite appreciated.

-Dave

Link to comment
Share on other sites

The original tweaked code you suggested as posted above (without the suggested [$i]'s) works perfectly as far as format, image, price, and specials price appearing, just the item was repeating instead of displaying the "best Sellers" as determined by the initial queries ending "

order by p.products_ordered desc, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);". For max-bestsellers I have 6, so should see the top 6 selling items in the scroll box.

Of course all instances of $random_product['fieldname'] after:

       for ($i = 0; $i < $no_of_random_products; $i++) {

//// Note issue with single quote vs double quote here: => '"', (2 occurences) single quotes were causing grief ////  

had to be changed to $random_product[$i]['fieldname'].

 

I went as far as installing this contribution to see what the problem was :'(

 

It appears that the variable $random_product is used in other parts too. When emptying that variable by redeclaring it everything went back to normal.

 

//    $i = 0;
   $random_product = array(); // empty $random_product
   while ($_random_product = tep_db_fetch_array($rp_query)) {

 

One final change needed is in the special products section:

 

// replace products_price with the correct specials_new_products_price
    if(!empty($new_s_prices)) {
        for ($x = 0; $x < $no_of_random_products; $x++) {
           for ($i = 0; $i < count($new_s_prices); $i++) {
              if ($random_product[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
//     $random_product[$x]['products_price'] = $new_s_prices[$i]['specials_new_products_price'];
                  $random_product[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price']; // changed
               }
            }
        }
    } // end if(!empty($new_s_prices)

Link to comment
Share on other sites

I went as far as installing this contribution to see what the problem was :'(

 

Jan, as usual, your awesome! Thank you very much. Everything works perfectly now.

I posted the modified SPPC + scrolling_best_sellers.php file to the contributions. Hopefully it will be of help to others:

http://addons.oscommerce.com/info/6552

 

Next I am off to make the awesome 2gether Discount contibution SPPC and product specials compatible. I think I can do it.

 

Thank you again! without help like you provide, novice non-coders like myself would be lost.

Much appreciation

-Dave

-Dave

Link to comment
Share on other sites

Jan, Good morning. I worked on the 2gether module last night. I think I have everything as it should be for SPPC, unfortunately I still cant get the Specials price to carry into the 2gether module. The correct prices and specials carry thru to the shopping cart and order totals, just not to the visual presentation of the price and 'together for only' calculation in the 2gether box presented on the product info page.

 

I have a test page here: test page

Note that the price is $188.00, on Special for $179.00

Look to the bottom of the page at the 2gether box. You see $188.00 still.

If you add to cart the Special is working, just not visually on the page.

 

Do you have any suggestion or have I missed something obvious?

Here is where I am at:

 

<?php

if (!$together_id) $together_id = (int)$_GET['products_id'];  // added (int)
if ($together_id) {
include(DIR_WS_LANGUAGES . $language . '/2gether.php');
$show_money_savings = true; // show money savings
$show_percentage_savings = true; // show percentage savings
$show_original_prices = true; // show origibal prices of the products
$show_images_as_links = true; // show images as links instead of popup the image
?>
<tr>
<td>
<div id="gether">
<?php
$together_query = tep_db_query("select distinct product_1_id, product_2_id, discount, type from ". TABLE_2GETHER ."  where (product_1_id = '" . $together_id . "' or product_2_id = '" . $together_id . "') and status = 1");
$num_together = tep_db_num_rows($together_query);
if ($num_together > 0) {
 $record = tep_db_fetch_array($together_query);
 $discount = $record['discount'];
 $discount_type = $record['type'];
 if ($record['product_1_id'] == $together_id) {
   $aq ="select p.products_id, p.products_image, p.products_price,  p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd  where p.products_id='". $record['product_1_id'] ."' and p.products_id = pd.products_id and products_status = '1' and pd.language_id ='". $languages_id ."'";
   $bq ="select p.products_id, p.products_image, p.products_price,  p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd  where p.products_id='". $record['product_2_id'] ."' and p.products_id = pd.products_id and products_status = '1' and pd.language_id ='". $languages_id ."'";
 } else {
    $aq ="select p.products_id, p.products_image, p.products_price,  p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd  where p.products_id='". $record['product_2_id'] ."' and p.products_id = pd.products_id and products_status = '1' and pd.language_id ='". $languages_id ."'";
    $bq ="select p.products_id, p.products_image, p.products_price,  p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd  where p.products_id='". $record['product_1_id'] ."' and p.products_id = pd.products_id and products_status = '1' and pd.language_id ='". $languages_id ."'";
 }

// Begin per Jan
// BOF SPPC
 $list_of_prdct_ids = array($record['product_1_id'], $record['product_2_id']);

     if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') {
      $customer_group_id = $_SESSION['sppc_customer_group_id'];
	} else {
	  $customer_group_id = '0';
    }
// EOF SPPC
// End per Jan

 $product_a_query = tep_db_query($aq);
 $product_a = tep_db_fetch_array($product_a_query);
 $product_b_query = tep_db_query($bq);
 $product_b = tep_db_fetch_array($product_b_query);
 $product_a_price = $product_a['products_price'];
 $product_b_price = $product_b['products_price'];

// Begin per Jan
// BOF SPPC - specials
// get all customers_group_prices for products with the particular customer_group_id
// however not necessary for customer_group_id = 0
if ($customer_group_id != '0') {
    $pg_query = tep_db_query("select pg.products_id, customers_group_price as price from " . TABLE_PRODUCTS_GROUPS . " pg where products_id in (" . implode(',', $list_of_prdct_ids) . ") and pg.customers_group_id = '".$customer_group_id."'");
         while ($pg_array = tep_db_fetch_array($pg_query)) {
		     $new_prices[] = array ('products_id' => $pg_array['products_id'], 'products_price' => $pg_array['price'], 'specials_new_products_price' => '');
			}

  for ($x = 0; $x < 2; $x++) {

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

// an extra query is needed for all the specials
       $specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where products_id in (" . implode(',', $list_of_prdct_ids) . ") and status = '1' and customers_group_id = '" .$customer_group_id. "' ");
	        while ($specials_array = tep_db_fetch_array($specials_query)) {
               $new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
		    }

// replace products_price with the correct specials_new_products_price
    if(!empty($new_s_prices)) {
    for ($x = 0; $x < 2; $x++) {
		 for ($i = 0; $i < count($new_s_prices); $i++) {
			if ($product_a['products_id'] == $new_s_prices[$i]['products_id'] ) {
			    $product_a['products_price'] = $new_s_prices[$i]['specials_new_products_price'];
			}
			if ($product_b['products_id'] == $new_s_prices[$i]['products_id'] ) {
			    $product_b['products_price'] = $new_s_prices[$i]['specials_new_products_price'];
			}
         }  // end for ($i = 0; $i < count($new_s_prices); $i++) {
       }  // end for ($x = 0; $x < 2; $x++) {
 } // end if(!empty($new_s_prices)
// EOF SPPC - specials
// End per Jan

 if (DISPLAY_PRICE_WITH_TAX) {
   $product_a_price =  tep_add_tax($product_a_price,tep_get_tax_rate($product_a['products_tax_class_id']));
   $product_b_price =  tep_add_tax($product_b_price,tep_get_tax_rate($product_b['products_tax_class_id']));
 }

 if ($discount > 0) {

   $together_image = '<img src=' . DIR_WS_IMAGES . 'save-icon_blink.gif alt="$" title="$">';
   $together_text = TOGETHER_HEADING_TEXT_SPECIAL_OFFER . '<br>';
  if (($show_money_savings) or ($show_percentage_savings)) {
   $together_savings_string = TOGETHER_TEXT_YOU_SAVE;
  } else {
   $together_savings_string = '';
  }
   if ($discount_type == 'p') {
     $together_price = tep_round(($product_a_price + $product_b_price) * (1-($discount/100)), 1);
     if ($show_money_savings) {
          $together_savings = $product_a_price + $product_b_price - $together_price;
          $together_savings_string .= $currencies->format($together_savings);
     }
     if ($show_percentage_savings) {
          $together_savings_string .= ' ' . $discount . '%';
     }
   } else {
      $together_price = tep_round($product_a_price + $product_b_price - $discount,1);
      if ($show_money_savings) {
        $together_savings = $product_a_price + $product_b_price - $together_price;
        $together_savings_string .= $currencies->format($together_savings);
      }
      if ($show_percentage_savings) {
        $together_percentage = ($discount /($product_a_price + $product_b_price))*100;
        $together_savings_string .= ' ' . $together_percentage . '%';
      }
     }
 } else {
     $together_price = tep_round(($product_a_price + $product_b_price), 1);
     $together_savings_string = '';
     $together_image = '<img src=' . DIR_WS_IMAGES . 'info_blue_small.jpg alt="i" title="i">';
     $together_text = '<font color="orange"><span class="getslogan">'.TOGETHER_HEADING_TEXT_SUGGESTION . '</span></font><br>';
   }
$together_string = $currencies->format($together_price);
echo '<table width="99%" class="borderGray" cellpadding="2" align="center">' .
'<tr>
 <td valign="top" width="1px" align="left">' . $together_image . '</td>' . 
'<td colspan="5" class="gettitolo">' . $together_text . TOGETHER_TEXT_BUY . ' <a href="' . tep_href_link('product_info.php', 'products_id=' . $product_a['products_id']) . '">' . str_replace('\'','`',$product_a['products_name']) . ' ' . tep_image('images/ico_arrow.gif', ICON_ARROW_RIGHT) . '</a> ' . TOGETHER_TEXT_AND . ' <a href="' . tep_href_link('product_info.php', 'products_id=' . $product_b['products_id']) . '">' . str_replace('\'','`',$product_b['products_name']) . ' ' . tep_image('images/ico_arrow.gif', ICON_ARROW_RIGHT) . '</a></td>' . 
'</tr>
<tr>
 <td></td>' . 
'<td width="80px" align="center">' ;?>
<?php #show images as link ...
 if ($show_images_as_links) {
      echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_a['products_image']) . '">' . ' <a href="' . tep_href_link('product_info.php', 'products_id=' . $product_a['products_id']) . '">' . ' ' . tep_image(DIR_WS_IMAGES . $product_a['products_image'], str_replace('\'','`',$product_a['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '</a>';
 } else { #... instead of popup the image
?>
<script language="javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_a['products_id']) . 'ℑ=0\\\')">' . tep_image(DIR_WS_IMAGES . $product_a['products_image'], str_replace('\'','`',$product_a['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_a['products_image']) . '">' . tep_image(DIR_WS_IMAGES . $product_a['products_image'], str_replace('\'','`',$product_a['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '</a>'; ?>
</noscript> 
<?php 
}

echo tep_draw_form('together', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'));

if ($show_original_prices) echo '<br><span class="prezzo">'.$currencies->format($product_a_price);

//Jader

$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)$product_a['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' 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 from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$product_a['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 . "'" . " order by pa.options_values_price, pa.products_attributes_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'])) .') ';
         }
       }

       if (isset($cart->contents[$product_a['products_id']]['attributes'][$products_options_name['products_options_id']])) {
         $selected_attribute = $cart->contents[$product_a['products_id']]['attributes'][$products_options_name['products_options_id']];
       } else {
         $selected_attribute = false;
       }
?>
           <?php echo '<br>' . $products_options_name['products_options_name'] . ':'; ?><br>
             <?php echo tep_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?><br>
<?php
     }

//-Jader

echo '</span></td><td align="center" width="100px"><img src="images/icon_plus.gif" border="0" style="vertical-align: middle"></td>' .
'<td width="80px" align="center">' ;?>
<?php
if ($show_images_as_links) {
echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_b['products_image']) . '">' . ' <a href="' . tep_href_link('product_info.php', 'products_id=' . $product_b['products_id']) . '">' . ' ' . tep_image(DIR_WS_IMAGES . $product_b['products_image'], str_replace('\'','`',$product_b['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '</a>';
} else { ?>
<script language="javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_b['products_id']) . 'ℑ=0\\\')">' . tep_image(DIR_WS_IMAGES . $product_b['products_image'], str_replace('\'','`',$product_b['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_b['products_image']) . '">' . tep_image(DIR_WS_IMAGES . $product_b['products_image'], str_replace('\'','`',$product_b['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '</a>'; ?>
</noscript>
<?php 
}

if ($show_original_prices) echo '<br><span class="prezzo">'.$currencies->format($product_b_price);

//Jader

$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)$product_b['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' 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 from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$product_b['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 . "'" . " order by pa.options_values_price, pa.products_attributes_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'])) .') ';
         }
       }

       if (isset($cart->contents[$product_b['products_id']]['attributes'][$products_options_name['products_options_id']])) {
         $selected_attribute = $cart->contents[$product_b['products_id']]['attributes'][$products_options_name['products_options_id']];
       } else {
         $selected_attribute = false;
       }
?>
           <?php echo '<br>' . $products_options_name['products_options_name'] . ':'; ?><br>
             <?php echo tep_draw_pull_down_menu('id_b[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute); ?><br>
<?php
     }

//-Jader

echo '</span></td><td width="2%"></td>'.
'<td align="middle" nowrap valign="middle" class="getprezzo">' . TOGETHER_TEXT_TOGETHER . ' ' . '<br><font color=#00><b>'.$together_string . '</b></font><br><br>'; 
//echo tep_draw_form('together', tep_href_link(FILENAME_PRODUCT_INFO, tep_get_all_get_params(array('action')) . 'action=add_product'));

echo tep_draw_hidden_field('products_id', $product_a['products_id']) . tep_draw_hidden_field('quantity',1) . tep_draw_hidden_field('buy_tinn_add', $product_b['products_id']) . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW);
echo '</form>';
echo '<table>';
if ($discount > 0) echo '<tr><td class="getrisparmio" nowrap align="center"><br><font color="red">' . $together_savings_string . '</font></td></tr><tr><td class="vsmalltext" nowrap align="center">('. TOGETHER_TEXT_RECEIVE_CHECKOUT . ')</td></tr>';
echo '</table>';
echo '</td></tr>';
echo '</table>';

echo '</div></td></tr><tr><td class="spazio"></td></tr>';

}
}
?>

-Dave

Link to comment
Share on other sites

Jan, Good morning.

Not for me anymore. I was in Seattle last week but I'm back home now so it's evening for me again :)

I worked on the 2gether module last night. I think I have everything as it should be for SPPC, unfortunately I still cant get the Specials price to carry into the 2gether module. The correct prices and specials carry thru to the shopping cart and order totals, just not to the visual presentation of the price and 'together for only' calculation in the 2gether box presented on the product info page.

I used the wrong variable in this piece. It should be $products_a_price instead of $products_a['products_price'] (and for b ditto). Try that.

 

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

// an extra query is needed for all the specials
       $specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where products_id in (" . implode(',', $list_of_prdct_ids) . ") and status = '1' and customers_group_id = '" .$customer_group_id. "' ");
                       while ($specials_array = tep_db_fetch_array($specials_query)) {
               $new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'specials_new_products_price' => $specials_array['specials_new_products_price']);
                           }

// replace products_price with the correct specials_new_products_price
    if(!empty($new_s_prices)) {
           for ($x = 0; $x < 2; $x++) {
                        for ($i = 0; $i < count($new_s_prices); $i++) {
                               if ($product_a['products_id'] == $new_s_prices[$i]['products_id'] ) {
                                   $product_a_price = $new_s_prices[$i]['specials_new_products_price'];
                               }
                               if ($product_b['products_id'] == $new_s_prices[$i]['products_id'] ) {
                                   $product_b_price = $new_s_prices[$i]['specials_new_products_price'];
                               }
                }  // end for ($i = 0; $i < count($new_s_prices); $i++) {
       }  // end for ($x = 0; $x < 2; $x++) {
 } // end if(!empty($new_s_prices)
// EOF SPPC - specials

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