Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Thank you very much! I added the $customer_group_id as you showed and hopefully that will take care of getting the correct price :)

 

For the includes/modules/2gether.php I now have this:

<?php
if ($_GET['products_id']) {
include(DIR_WS_LANGUAGES . $language . '/2gether.php');

// BOF Separate Pricing Per Customer
if(!tep_session_is_registered('sppc_customer_group_id')) {
$customer_group_id = '0';
} else {
 $customer_group_id = $sppc_customer_group_id;
}
?>
<tr>
<td>
<?php
$together_query = tep_db_query("select distinct product_1_id, product_2_id, discount, type from ". TABLE_2GETHER ."  where product_1_id = '" . (int)$_GET['products_id'] . "' or product_2_id = '" . (int)$_GET['products_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'];
 //edit for SPPC
 if ($customer_group_id != '0'){
 $aq ="select p.products_id, p.products_image, IF(pg.customers_group_price IS NOT NULL, pg.customers_group_price, p.products_price) as products_price, pd.products_name from " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using(products_id), " . 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 ."' and pg.customers_group_id = '".$customer_group_id."'";
 }else{
 $bq ="select p.products_id, p.products_image, p.products_price, 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 ."'";
 }//end edit for SPPC
}

 

When I uploaded the above I now get an error 1065 - Query was empty

What did I mess up? :huh:

~Tracy
 

Link to comment
Share on other sites

When I uploaded the above I now get an error 1065 - Query was empty

What did I mess up? :huh:

 

I found it :blush:

 

I forgot to have duplicates of BOTH $aq and $bq - I only had half of what I needed there :blush:

 

Ok - back to adding the Hide Products for SPPC part :-" :blush:

~Tracy
 

Link to comment
Share on other sites

Thank you very much! I added the $customer_group_id as you showed and hopefully that will take care of getting the correct price :)
You used the "old" code, not the super global $_SESSION as I used. You can use it, but have to declare $sppc_customer_group_id a global then.

 

For the includes/modules/2gether.php I propose this:

<?php
if ($_GET['products_id']) {
include(DIR_WS_LANGUAGES . $language . '/2gether.php');

global $sppc_customer_group_id;
// BOF Separate Pricing Per Customer
if(!tep_session_is_registered('sppc_customer_group_id')) {
$customer_group_id = '0';
} else {
 $customer_group_id = $sppc_customer_group_id;
}
?>
<tr>
<td>
<?php
$together_query = tep_db_query("select distinct product_1_id, product_2_id, discount, type from ". TABLE_2GETHER ."  where product_1_id = '" . (int)$_GET['products_id'] . "' or product_2_id = '" . (int)$_GET['products_id'] . "' and status = 1");
$num_together = tep_db_num_rows($together_query);
if ($num_together > 0) {
  while ($_record = tep_db_fetch_array($together_query)) {
$record1[] = $_record;
 }
 // I guess there should be only one row, but just in case there are more
 // we code it as that may happen, only the last row fetched will be used!
 foreach ($record1 as $key => $record) {
if ($record['product_1_id'] == (int)$_GET['products_id']) {
  	$discount = $record['discount'];
  	$discount_type = $record['type'];
  $other_product_id = $record['product_2_id']
} else {
// not product_1_id, then $_GET['products_id'] is product_2_id
  	$discount = $record['discount'];
  	$discount_type = $record['type'];
  $other_product_id = $record['product_1_id']	
}
 } // end foreach ($record1 as $key => $record)
  //edit for SPPC
  if ($customer_group_id != '0') {
  $aq ="select p.products_id, p.products_image, IF(pg.customers_group_price IS NOT NULL, pg.customers_group_price, p.products_price) as products_price, pd.products_name from " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using(products_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd  where p.products_id='". $other_product_id ."' and p.products_id = pd.products_id and products_status = '1' and pd.language_id ='". $languages_id ."' and pg.customers_group_id = '".$customer_group_id."'";
  } else {
  $aq ="select p.products_id, p.products_image, p.products_price, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd  where p.products_id='". $other_product_id ."' and p.products_id = pd.products_id and products_status = '1' and pd.language_id ='". $languages_id ."'";
  } //end edit for SPPC
} // end if ($num_together > 0)

Note that I named the queries the same ($aq). You can add in the find_in_set stuff in both queries (but it doesn't look at the category!

Link to comment
Share on other sites

You used the "old" code, not the super global $_SESSION as I used. You can use it, but have to declare $sppc_customer_group_id a global then.

 

For the includes/modules/2gether.php I propose this:

Note that I named the queries the same ($aq). You can add in the find_in_set stuff in both queries (but it doesn't look at the category!

 

Thank you JanZ!! I will try this on Monday :)

~Tracy
 

Link to comment
Share on other sites

However, I come up with a problem about "product-listing".

I have to assign products to different categories. When I do searching for a product with reference to either its product reference or through manufacturer's name, the result page lists the product repeatedly according to the number of categories it belongs to, which means, if an item belongs to 5 categories, it repeatedly appears five times on the result page.

 

I wonder if a hack could fix the problem: by means of showing once ONLY disregarding how many categories the item belongs to.

 

I am not sure if such hack is already available.

Never tried that but I assume you can avoid that in SPPC while retrieving the results of the query in product_listing.php. Something along the lines of:

	while ($_listing = tep_db_fetch_array($listing_query)) {
// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {
$listing[] = $_listing;
}
$_list_of_prdct_ids[] = $_listing['products_id'];
} // end while ($_listing = tep_db_fetch_array($listing_query)) 
// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

Link to comment
Share on other sites

Hi All,

 

I have installed a cross sell module called family_products(3.4) and it is working but it has no reference to the SPPC/wPriceBreak pricing when it selects a related product and therefore shows the default retail price.

 

I see if I add

// BOF Separate Pricing Per Customer

if(!tep_session_is_registered('sppc_customer_group_id')) {

$customer_group_id = '0';

} else {

$customer_group_id = $sppc_customer_group_id;

}

 

I can then determine the $customer_group.

 

Now the question is how to modify the following query to include the SPPC/BP elements to get the correct price for the customer_group in the variable $family['products_price'] ?????????

 

if (tep_db_num_rows($family_name_query) == '1') {

$family = tep_random_select("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = pf.products_id and p.products_id != '" . $products_id . "'" . $where_clause2);

} else {

$family = tep_random_select("select distinct p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS_FAMILIES . " pf, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and (" . $where_clause . ") and p.products_id = pf.products_id and p.products_id != '" . $products_id . "'" . $where_clause2);

}

$where_clause2 .= " and p.products_id != '" . $family['products_id'] . "'";

Link to comment
Share on other sites

Never tried that but I assume you can avoid that in SPPC while retrieving the results of the query in product_listing.php. Something along the lines of:

	while ($_listing = tep_db_fetch_array($listing_query)) {
// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {
$listing[] = $_listing;
}
$_list_of_prdct_ids[] = $_listing['products_id'];
} // end while ($_listing = tep_db_fetch_array($listing_query)) 
// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

 

Dear Jan, Thanks for your reply. I'm not a programmer but I tried hard to figure out where I should put your lines, the extract of my file appears as below:

 

	if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
  $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
}

$list_box_contents[0][] = array('align' => $lc_align,
								'params' => 'class="productListing-heading"',
								'text' => ' ' . $lc_text . ' ');
 }

if ($listing_split->number_of_rows > 0) {

$rows = 0;
$listing_query = tep_db_query($listing_split->sql_query);
// BOF Separate Pricing per Customer, Price Break 1.11.3 modification
$no_of_listings = tep_db_num_rows($listing_query);
// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

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

 $default_settings = array('products_price1' => '0.0000', 'products_price2' => '0.0000', 'products_price3' => '0.0000',
'products_price4' => '0.0000', 'products_price5' => '0.0000', 'products_price6' => '0.0000', 'products_price7' => '0.0000', 'products_price8' => '0.0000', 'products_price1_qty' => '0', 'products_price2_qty' => '0', 'products_price3_qty' => '0', 'products_price4_qty' => '0', 'products_price5_qty' => '0', 'products_price6_qty' => '0', 'products_price7_qty' => '0', 'products_price8_qty' => '0', 'products_qty_blocks' => '1');

[b]while ($_listing = tep_db_fetch_array($listing_query)) {
// let's start with default settings, you never know
$_new_listing =	array_merge($_listing , $default_settings);
$listing[] = $_new_listing;
$list_of_prdct_ids[] = $_listing['products_id'];
} [/b] 
// next part is a debug feature, when uncommented it will print the info that this module receives

 

I recognise the above bolded lines, but I don't know how to change them. Can you offer me further guidance of doing so?

Thanks again for your help.

 

James

Link to comment
Share on other sites

I recognise the above bolded lines, but I don't know how to change them. Can you offer me further guidance of doing so?
I guess this should work:

	while ($_listing = tep_db_fetch_array($listing_query)) {
$_new_listing = array_merge($_listing , $default_settings);
// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {
$listing[] = $_new_listing;
}
$_list_of_prdct_ids[] = $_new_listing['products_id'];
} // end while ($_listing = tep_db_fetch_array($listing_query)) 
// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

Link to comment
Share on other sites

Now the question is how to modify the following query to include the SPPC/BP elements to get the correct price for the customer_group in the variable $family['products_price'] ?????????
I wouldn't try that. To me it looks like you only need one product_id. Than I would retrieve the products_id(s) that $family_name_query (might) give, don't know this contribution.... Then either use the one that is returned or tep_random_select from the multiple, making sure that p.products_id != $family['products_id'].

 

Then you just do a:

$pf= new PriceFormatter;
// products_id from the family_query/ tep_random_select from the multiple product_id's
$family = $pf->loadProduct($products_id, $languages_id));

etcetera.

Look at the class shopping_cart.php and function calculate for examples how that is used.

Link to comment
Share on other sites

I guess this should work:

	while ($_listing = tep_db_fetch_array($listing_query)) {
$_new_listing = array_merge($_listing , $default_settings);
// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {
$listing[] = $_new_listing;
}
$_list_of_prdct_ids[] = $_new_listing['products_id'];
} // end while ($_listing = tep_db_fetch_array($listing_query)) 
// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

 

Dear Jan,

 

Thanks for your prompt reply. I inserted your code as below:

 if ($listing_split->number_of_rows > 0) {

$rows = 0;
$listing_query = tep_db_query($listing_split->sql_query);
// BOF Separate Pricing per Customer, Price Break 1.11.3 modification
$no_of_listings = tep_db_num_rows($listing_query);
// global variable (session) $sppc_customer_group_id -> local variable customer_group_id

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

 $default_settings = array('products_price1' => '0.0000', 'products_price2' => '0.0000', 'products_price3' => '0.0000',
'products_price4' => '0.0000', 'products_price5' => '0.0000', 'products_price6' => '0.0000', 'products_price7' => '0.0000', 'products_price8' => '0.0000', 'products_price1_qty' => '0', 'products_price2_qty' => '0', 'products_price3_qty' => '0', 'products_price4_qty' => '0', 'products_price5_qty' => '0', 'products_price6_qty' => '0', 'products_price7_qty' => '0', 'products_price8_qty' => '0', 'products_qty_blocks' => '1');

  while ($_listing = tep_db_fetch_array($listing_query)) {
$_new_listing = array_merge($_listing , $default_settings);
// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {
$listing[] = $_new_listing;
}
$_list_of_prdct_ids[] = $_new_listing['products_id'];
} // end while ($_listing = tep_db_fetch_array($listing_query)) 
// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

The search result then appears as below:

listing.gif

I think I might have mixed up your code. And also, I forgot to tell you the contribution I have installed on my site, http://www.educity.hk/select.

I am operating the site in Traditional Chinese (i.e. Language 4) ONLY. I installed SPPC, Price Break, Hide Price, Account Balance, Article Manager, Download, EasyPopulate, FAQDesk, Point and Rewards, Live Support, Referral Points, Poll Booth, etc.

The manufacturer's box search result appears originally as below

listing2.gif

 

As you can see, the products (i.e. Books) repeated appearing in a few lines because the item is assigned to more than one category.

I hope the above information is useful to you.

Looking forward to your further guidance to help fix the problem of "repetitions". Thanks in advance.

 

Cheers

 

James

Edited by booksfarm
Link to comment
Share on other sites

Is this happening on the email address you setup to test the conrib. with? I know for me, if I used a different email address I didn't get the option to choose. Only the test email address gives you the option to choose what group to log in as so that you can test things are working for any of your groups through just one account.

 

It threw me for a loop until JanZ pointed that out - ;) But for me it only asks if I log in with my testing account. If I create a different account with a different email address then it doesn't ask me anymore ;)

 

 

thats it. thank you

Link to comment
Share on other sites

I inserted your code as below:
Tiny error, this part:

// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {
$listing[] = $_new_listing;

should have been:

// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($_list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {
$listing[] = $_new_listing;

So isset($list_of_prdct_ids) -> isset($_list_of_prdct_ids)

Link to comment
Share on other sites

Tiny error, this part:

Additionally, you should reset the $no_of_listings = tep_db_num_rows($listing_query); above to the new number of items like so:

// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
$no_of_listings = count($list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

Link to comment
Share on other sites

Tiny error, this part:

// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {
$listing[] = $_new_listing;

should have been:

// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($_list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {
$listing[] = $_new_listing;

So isset($list_of_prdct_ids) -> isset($_list_of_prdct_ids)

 

Dear JanZ,

 

You are Super. The above could successully remove all the duplicate rows.

See below.

listing3.gif

 

Many Many Thanks to the real hero ----- JanZ

 

James

Link to comment
Share on other sites

Additionally, you should reset the $no_of_listings = tep_db_num_rows($listing_query); above to the new number of items like so:

// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
$no_of_listings = count($list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

 

Dear JanZ again,

 

The above code can successfully removed all empty rows. See image in the above posting.

 

Just one tiny problem: The first item(/row) i.e. "5327" disappeared from the list, but the rest of all other pages are fine. And, there is a bottom row on each page that has a $0.0.

 

Besides, the code works just fine.

Thanks again JanZ. You are a genius.

 

Cheers

 

James

Link to comment
Share on other sites

Just one tiny problem: The first item(/row) i.e. "5327" disappeared from the list, but the rest of all other pages are fine. And, there is a bottom row on each page that has a $0.0.
Hmm, not correct yet. Try this:

  while ($_listing = tep_db_fetch_array($listing_query)) {
    $_new_listing = array_merge($_listing , $default_settings);

// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($_list_of_prdct_ids) && !in_array($_new_listing['products_id'], $_list_of_prdct_ids))) {
      $listing[] = $_new_listing;
// if $_list_of_prdct_ids is not an array yet, the first item should be added
} elseif (!isset($_list_of_prdct_ids)) {
      $listing[] = $_new_listing;	
}
$_list_of_prdct_ids[] = $_new_listing['products_id'];
   } // end while ($_listing = tep_db_fetch_array($listing_query)) 
// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
$no_of_listings = count($list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

Link to comment
Share on other sites

Hmm, not correct yet. Try this:

  while ($_listing = tep_db_fetch_array($listing_query)) {
    $_new_listing = array_merge($_listing , $default_settings);

// in first iteration $_list_of_prdct_ids is not an array yet
if (isset($_list_of_prdct_ids) && !in_array($_new_listing['products_id'], $_list_of_prdct_ids))) {
      $listing[] = $_new_listing;
// if $_list_of_prdct_ids is not an array yet, the first item should be added
} elseif (!isset($_list_of_prdct_ids)) {
      $listing[] = $_new_listing;	
}
$_list_of_prdct_ids[] = $_new_listing['products_id'];
   } // end while ($_listing = tep_db_fetch_array($listing_query)) 
// no duplicate product_id's:
$list_of_prdct_ids = array_unique($_list_of_prdct_ids);
$no_of_listings = count($list_of_prdct_ids);
// next part is a debug feature, when uncommented it will print the info that this module receives

 

Dear JanZ

 

Many thanks for your patience. I think there's a small typo above. Would this (below) work? It's copied from your previous code.

	if (isset($_list_of_prdct_ids) && (! in_array($_listing['products_id'], $_list_of_prdct_ids))) {

 

Here's the result:

listing4.gif

 

It's amazing. Your code works. The 1st row re-appeared and the last row disappeared.

I think the rest is fantastic. Superb! You are always the most reliable and promising expert here.

 

Thanks again!

 

James

Link to comment
Share on other sites

Dear JanZ

 

Sorry to change your code, actually your previous version of code also works.

	if (isset($_list_of_prdct_ids) && !in_array($_new_listing['products_id'], $_list_of_prdct_ids)) {

I just took out the extra ")" .

 

Thanks again once more! :lol:

 

James

Link to comment
Share on other sites

You used the "old" code, not the super global $_SESSION as I used. You can use it, but have to declare $sppc_customer_group_id a global then.

 

For the includes/modules/2gether.php I propose this:

  if ($customer_group_id != '0') {
  $aq ="select p.products_id, p.products_image, IF(pg.customers_group_price IS NOT NULL, pg.customers_group_price, p.products_price) as products_price, pd.products_name from " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using(products_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd  where p.products_id='". $other_product_id ."' and p.products_id = pd.products_id and products_status = '1' and pd.language_id ='". $languages_id ."' and pg.customers_group_id = '".$customer_group_id."'";
  } else {
  $aq ="select p.products_id, p.products_image, p.products_price, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd  where p.products_id='". $other_product_id ."' and p.products_id = pd.products_id and products_status = '1' and pd.language_id ='". $languages_id ."'";
  } //end edit for SPPC
} // end if ($num_together > 0)

Note that I named the queries the same ($aq). You can add in the find_in_set stuff in both queries (but it doesn't look at the category!

 

Does this mean I no longer would need the $bq queries? It appears to me that you turned the $other_product_id into something that can be either product_1_id OR product_2_id depending on the results of the $together_query Is that correct ? :blush:

~Tracy
 

Link to comment
Share on other sites

Does this mean I no longer would need the $bq queries? It appears to me that you turned the $other_product_id into something that can be either product_1_id OR product_2_id depending on the results of the $together_query Is that correct ? :blush:

 

PS - if that is correct then how does the script know how to do the math :huh: Underneath that lovely query stuff I have this - which calls the products from the $aq and $bq queries, so I'm not sure how to differentiate the two different products without the $bq query:

if ($num_together > 0) { 

 $image_height = 50;
 $image_width = 50;
 $show_money_savings = true; // show percentage discount as money savings or percentage
 $tblw   = ' width="85%" '; 

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

 if ($discount > 0) {
if ($discount_type == 'p') {
  $together_price = tep_round(($product_a['products_price'] + $product_b['products_price']) * (100-$discount)/100, 6);
  if ($show_money_savings) {
	 $together_savings = $product_a['products_price'] + $product_b['products_price'] - $together_price;
	 $together_savings_string = TOGETHER_TEXT_YOU_SAVE . $currencies->format($together_savings) . ' !';
  } else {
	 $together_savings_string = TOGETHER_TEXT_YOU_SAVE . $discount . '%';
  }
  $together_image = '<img src=' . DIR_WS_IMAGES . 'save-icon_blink.gif alt="$" title="$">';
  if (stristr(basename($PHP_SELF),'b2offers')) {
	$together_text = '';
  } else {
	$together_text = TOGETHER_HEADING_TEXT_SPECIAL_OFFER . '<br>';
  }
} else {
   $together_price = tep_round($product_a['products_price'] + $product_b['products_price'] - $discount,6);
   $together_savings = $discount;
  }
 } else {
  $together_price = tep_round(($product_a['products_price'] + $product_b['products_price']), 6);
  $together_savings_string = '';
  $together_image = '<img src=' . DIR_WS_IMAGES . 'info_blue_small.jpg alt="i" title="i">';
  $together_text = '<font color="orange">'.TOGETHER_HEADING_TEXT_SUGGESTION . '</font><br>';
}
$together_string = $currencies->format($together_price);

echo '<a name="b2">';
echo '<table'.$tblw.$border.'cellpadding="2" align="center">' .
'<tr>
 <td valign="top" width="1px" align="left">' . $together_image . '</td>' . 
'<td colspan="5" class="pageHeading">' . $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">';?>
<script language="javascript"><!--
document.write('<?php echo '<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'products_id=' . $product_a['products_id']) . 'ℑ=0\\\')">' . tep_image(DIR_WS_PRODUCT_IMAGES . $product_a['products_image'], str_replace('\'','`',$product_a['products_name'])) . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_PRODUCT_IMAGES . $product_a['products_image']) . '">' . tep_image(DIR_WS_PRODUCT_IMAGES . $product_a['products_image'], str_replace('\'','`',$product_a['products_name'])) . '</a>'; ?>
</noscript> 
<?php echo '</td><td align="center" width="100px"><img src="images/icon_plus.gif" border="0" style="vertical-align: middle"></td>' .
'<td width="80px" align="center">';?>
<script language="javascript"><!--
document.write('<?php echo '<a href="java script:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'products_id=' . $product_b['products_id']) . 'ℑ=0\\\')">' . tep_image(DIR_WS_PRODUCT_IMAGES . $product_b['products_image'], str_replace('\'','`',$product_b['products_name'])) . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_PRODUCT_IMAGES . $product_b['products_image']) . '">' . tep_image(DIR_WS_PRODUCT_IMAGES . $product_b['products_image'], str_replace('\'','`',$product_b['products_name'])) . '</a>'; ?>
</noscript>
<?php
echo	'</td><td width="2%"></td>'.
'<td align="middle" nowrap valign="middle" class="buybothText">' . TOGETHER_TEXT_TOGETHER . ' ' . '<font color=#00>'.$together_string . '</font><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('buy_tinn_add', $product_b['products_id']) . tep_image_submit('button_buy_now.gif', 'Add Them Together');
echo '</form>';
echo '<table>';

if ($discount > 0) {
 echo '<tr> 
	 <td class="buybothText" nowrap align="center"><font color="red">' . $together_savings_string . '</font></td>
	</tr>
	<tr>
	  <td class="vsmalltext" nowrap align="center">(Receive your discount at checkout)</td>
	</tr>';
}
echo '</table>';
echo '</td></tr>';
echo	'</table></td></tr><tr><td>' . tep_draw_separator('pixel_trans.gif', '100%', '10') . '</td></tr>';
}
}

 

Or should the $bq query just be a duplicate of the $aq query? :blush:

~Tracy
 

Link to comment
Share on other sites

PS - if that is correct then how does the script know how to do the math :huh: Underneath that lovely query stuff I have this - which calls the products from the $aq and $bq queries, so I'm not sure how to differentiate the two different products without the $bq query:

 

Or should the $bq query just be a duplicate of the $aq query? :blush:

 

Ugh - can't find an "edit" option so I apologize for two long posts in a row (first one being somewhat useless at this point other than the question). <_<

 

This 2gether Discount contrib. is definitely interesting to modify for all the other contrib's I have installed at the moment. I couldn't get the most recent version working - so I ended up starting with the original first release and slowly working my way up - making edits and changes as they were posted. I have now gotten to the newer version of the includes/modules/2gether.php and amazingly have it functioning at the moment :blush:

 

I tried with your query from above - but I kept getting an error that I had an unexpected '{' or '}' (forget which one) and for the life of me I could not figure out why - I even went through and commented all of the '}' tags as to what they were ending throughout the whole page and still couldn't figure out why. So I re-modified slightly to the below and at least the page isn't giving me errors anymore and it is working.

 

So - my question is - do I need to change the array for the $other_product_id, is it terrible to leave it as is?

 

here is the page in it's entirety at the moment (still need to add in the hide products part - I don't think it will matter that it doesn't do the hide category as the only way to see this particular table is to be on the product page of a product that has a 2gether discount - so if the category is hidden to begin with they shouldn't be able to get to the product - right?) :blush:

 

<?php
if (!$together_id) $together_id = $_GET['products_id'];
if ($together_id) {
include(DIR_WS_LANGUAGES . $language . '/2gether.php');
global $sppc_customer_group_id;
$show_money_savings = true; // show money savings
$show_percentage_savings = true; // show percentage savings
$show_original_prices = true; // show origibal prices of the products

//BOF Separate Pricing Per Customer
if(!tep_session_is_registered('sppc_customer_group_id')) {
$customer_group_id = '0';
}else{
$customer_group_id = $sppc_customer_group_id;
}
?>
<tr>
<td>
<?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) {
if ($customer_group_id != '0') {
$aq ="select p.products_id, p.products_image, IF(pg.customers_group_price IS NOT NULL, pg.customers_group_price, p.products_price) as products_price,  p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using(products_id), " . 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 ."' and pg.customers_group_id = '".$customer_group_id."'";
$bq ="select p.products_id, p.products_image, IF(pg.customers_group_price IS NOT NULL, pg.customers_group_price, p.products_price) as products_price,  p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_PRODUCTS_GROUPS . " pg using(products_id), " . 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 ."' and pg.customers_group_id = '".$customer_group_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 ."'";
 }
}
 $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);

 if ($discount > 0) {

$together_image = '<img src=' . DIR_WS_IMAGES . 'save-icon_blink.gif alt="$" title="$">';
if (stristr(basename($PHP_SELF),'b2offers')) {
  $together_text = '';
} else {
  $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['products_price'] + $product_b['products_price']) * (100-$discount)/100, 6);
  if ($show_money_savings) {
	   $together_savings = $product_a['products_price'] + $product_b['products_price'] - $together_price;
	   $together_savings_string .= $currencies->display_price($together_savings, tep_get_tax_rate($product_a['products_tax_class_id']));
  }
  if ($show_percentage_savings) {
	   $together_savings_string .= ' ' . $discount . '%';
  }
} else {
   $together_price = tep_round($product_a['products_price'] + $product_b['products_price'] - $discount,6);
   if ($show_money_savings) {
	 $together_savings = $product_a['products_price'] + $product_b['products_price'] - $together_price;
	 $together_savings_string .= $currencies->display_price($together_savings, tep_get_tax_rate($product_a['products_tax_class_id']));
   }
   if ($show_percentage_savings) {
	 $together_percentage = ($discount /($product_a['products_price'] + $product_b['products_price']))*100;
	 $together_savings_string .= ' ' . $together_percentage . '%';
   }
  }
 } else {
  $together_price = tep_round(($product_a['products_price'] + $product_b['products_price']), 6);
  $together_savings_string = '';
  $together_image = '<img src=' . DIR_WS_IMAGES . 'info_blue_small.jpg alt="i" title="i">';
  $together_text = '<font color="orange">'.TOGETHER_HEADING_TEXT_SUGGESTION . '</font><br>';
}
$together_string = $currencies->display_price($together_price, tep_get_tax_rate($product_a['products_tax_class_id']));

ob_start();
echo '<table width="80%" class="borderGray" cellpadding="2" align="center">' .
'<tr>
 <td valign="top" width="1px" align="left">' . $together_image . '</td>' . 
'<td colspan="5" class="pageHeading">' . $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">';?>
<script language="javascript"><!--
document.write('<?php echo '<a href="java script: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 
if ($show_original_prices) echo '<br>'.$currencies->display_price($product_a['products_price'], tep_get_tax_rate($product_a['products_tax_class_id']));
echo '</td><td align="center" width="100px"><img src="images/icon_plus.gif" border="0" style="vertical-align: middle"></td>' .
'<td width="80px" align="center">';?>
<script language="javascript"><!--
document.write('<?php echo '<a href="java script: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>'.$currencies->display_price($product_b['products_price'], tep_get_tax_rate($product_b['products_tax_class_id']));
echo '</td><td width="2%"></td>'.
'<td align="middle" nowrap valign="middle" class="buybothText">' . TOGETHER_TEXT_TOGETHER . ' ' . '<font color=#00>'.$together_string . '</font><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('buy_tinn_add', $product_b['products_id']) . tep_image_submit('button_buy_now.gif', 'Add Them Together');
echo '</form>';
echo '<table>';
if ($discount > 0) echo '<tr><td class="buybothText" nowrap align="center"><font color="red">' . $together_savings_string . '</font></td></tr><tr><td class="vsmalltext" nowrap align="center">(Receive your discount at checkout)</td></tr>';
echo '</table>';
echo '</td></tr>';
echo '</table>';
$contents = ob_get_clean();
echo  $contents;
echo '</td></tr>';
}
}
?>

 

Thank you again for all of your help! This one's just giving me a heck of a time - LOL :blush:

~Tracy
 

Link to comment
Share on other sites

hi guys !

 

i have SPPC working great, including hiding products and catagories from users and groups etc:.

 

I was wondering whether there is a way to , say instead of entering the exact price for any particular customer group, enter a percentage off the retail price?

 

 

Example

Retail - $50

Wholesale $45

Wholesale 1 - $40

 

Could this be done by doing

Retail - $50

Wholesale - 10% off

Wholesale - 20% off

 

And the next big question is could this be done for an entire product group.

 

As you could imagine entering individual prices for each product can get a bit tedious, having to calculate yourself, and knowing every other product in that particular group is the same percentage off

 

hope that makes sense, if anybody can help that would be great,

 

Cheers !!

 

dlyxzen

User is offlineProfile CardPM

 

Report PostGo to the top of the page

+

Link to comment
Share on other sites

I was wondering whether there is a way to , say instead of entering the exact price for any particular customer group, enter a percentage off the retail price?
Sure, you could do something:

insert into products_groups select '1' AS customers_group_id, (0.8 * p.products_price) AS customers_group_price, p.products_id FROM products p;

if the price should be 20% off for customer group 1.

 

You could also use Quick Price Updates for SPPC for faster updates of prices.

Link to comment
Share on other sites

It's amazing. Your code works. The 1st row re-appeared and the last row disappeared.
You were right about the typo. It is still a hack: it mentions results 1-20 and there are only like 5, so it would be better to change the sql (if that is possible in this case...).

 

Don't have any time to look at it though right now...

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