Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

The code is from the price_break modification for SPPC. Did you ran the price-break_1113_sppc.sql (succesfully..)?

 

Hi Janz,

 

Thanks.... Its working now. I have my website host run all the SQL stuff, and I do the editing of the php files......he had forgotten to run that part.

 

But, now, I had Salemaker installed and it's all fubar. I need to know how to integrate Salemaker into my site while leaving the SPPC working. I have wholesale customers that I need to have different prices for. But I also have several sales throughout the month that are usually category wide sales. I have close to 2000 products listed in my store, so going and doing each individual product is not an option. Too much. I got to the catalog/includes/functions/general.php file and found that the code I was supposed to replace with Salemakers code was already replaced by SPPC. The other files I did with no problem. Can you help me with that?

 

Thanks!

 

Julie

Link to comment
Share on other sites

Neither, they don't touch that part of the code (I think the class split_page_results deals with that and takes it settings from the configuration keys).

Me too, that should work  :huh:

Thnx quick reply.

Confusion is always sweeter when shared. But we are no less wiser :-(

I think my predesessor fumbled a bit with "products in rows" but I have no logs of the changes made.

Any idea how to reset the design/display of products? Maybe that will help ?

damsbo

Link to comment
Share on other sites

I got to the catalog/includes/functions/general.php file and found that the code I was supposed to replace with Salemakers code was already replaced by SPPC.  The other files I did with no problem. 
So you mean you already had the Price Break contribution working together with Salemakers?

That function in general.php is not really the problem. First Salemakers in the admin part should be made customer_group_id aware (which does not seem to be that much of a deal, seems to work already after some changes) but the Price Break contribution is a much bigger problem IMHO.

 

Where did you find the code for Price Break combined with Salemakers?

Link to comment
Share on other sites

I think my predesessor fumbled a bit with "products in rows" but I have no logs of the changes made.

Any idea how to reset the design/display of products?

You will have to compare the code that is on the site now with the code that SPPC uses. There is no magic formula that can solve your problem. Sorry.
Link to comment
Share on other sites

So you mean you already had the Price Break contribution working together with Salemakers?

That function in general.php is not really the problem. First Salemakers in the admin part should be made customer_group_id aware (which does not seem to be that much of a deal, seems to work already after some changes) but the Price Break contribution is a much bigger problem IMHO.

 

Where did you find the code for Price Break combined with Salemakers?

 

Hey Jan,

 

No, I had Salemaker working fine. Installed the Price Break and now Salemaker does not function fully. It will not allow me to choose a date to end a sale, give me this text in the date field whenever I use the pull down calendar and change the date: "DATE_FOR5AT_SPIFFYCAL"

 

(note that in that statement the # in it refers to the month that you are picking from on the calendar)

 

So it will not even let me type a date in manually. So therefore, it wont do a sale without a date range. How do I make Salemaker customer_group_id aware? Got the SPPC working fine now. Just need to get my Salemaker back up and working properly.

 

I didnt find any code for Price Break combined with Salemaker.

 

Julie

Edited by Baybee
Link to comment
Share on other sites

I just did a new test account and then went to log in with the account and it goes to a screen with a pull down menu that says "Choose a Customer Group" and allows any new customer to choose from all my customer groups and then even if the account is set to "Retail" it will allow them to choose ANY group. HELP!!

 

For existing customers, it does not go to that Choose a Customer Group screen, it goes straight to the store main page and shows them whatever prices are set for the group they are in.

Edited by Baybee
Link to comment
Share on other sites

I just did a new test account and then went to log in with the account and it goes to a screen with a pull down menu that says "Choose a Customer Group" and allows any new customer to choose from all my customer groups and then even if the account is set to "Retail" it will allow them to choose ANY group.  HELP!!

 

For existing customers, it does not go to that Choose a Customer Group screen, it goes straight to the store main page and shows them whatever prices are set for the group they are in.

 

:-"

Wow.... whatta doofus I am. I forgot all about the login.php email address I had to put in. That would be *WHY* I was getting the choose a customer group screen!!! DUH!!!! :wacko:

 

So all is well in my little store for now except for the darn Salemaker still not working with SPPC......... :unsure:

 

Julie

Link to comment
Share on other sites

It will not allow me to choose a date to end a sale, give me this text in the date field whenever I use the pull down calendar and change the date: "DATE_FOR5AT_SPIFFYCAL"
Sounds like you at least didn't add this to includes/languages/english.php (or the file was replaced but this wasn't added back in):

// BOF salemaker 1.02
define('DATE_FORMAT_SPIFFYCAL', 'MM/dd/yyyy');  //Use only 'dd', 'MM' and 'yyyy' here in any order
// EOF salemaker 1.02

I wasted a lot of time on this Salemaker 1.02 code and so I will list the changes I made to make it work with SPPC 4.11 combined with Price_Break for SPPC (!). I think it is a waste of time because the Salemaker code uses a lot of mysql queries (typically three for every product, which means that if you have a product listing with 10 product there are 30 extra queries... ). Personally, I feel that contribution should have taken it one step further: using the conditions that the code gives to do inserts/updates/deletions in the table specials (which then should be expanded with a salemaker_id column).

 

Also I found that if you go back to edit a sale, the category/subcategory which was on sale does not get shown. Could be my problem, but if you saw it also, it means another bad point for this contribution.

 

Anyway here are the code changes, it might be incomplete so you better check it thoroughly (check the Salemaker contribution if there are obvious ones missed in this list).

 

Of course due to the way Salemaker works the listing according to price (in the product listing) and the search using a limit on the price (in advanced_search_results.php) is not working correctly, but it never has.

 

All in all, I'm not impressed with Salemaker at it is now.

 

SQL for changing the table salemaker to make it customer_group_id aware:

ALTER TABLE salemaker_sales
ADD customers_group_id smallint UNSIGNED NOT NULL default '0';

admin/includes/languages/english/salemaker.php

Line 20

**AFTER**

define('TABLE_HEADING_ACTION', 'Action');

**ADD**

// BOF Separate Pricing per Customer
define('TABLE_HEADING_CUST_GROUPS', 'Customer Group');
define('TEXT_SALEMAKERS_CUST_GROUPS', 'Customer Group:');
// EOF Separate Pricing per Customer

admin/salemaker.php

Line 18

**AFTER**

 require(DIR_WS_CLASSES . 'currencies.php');
 $currencies = new currencies();
 
**ADD***

 // BOF Separate Pricing Per Customer 
     $customers_groups_query = tep_db_query("select customers_group_name, customers_group_id from " . TABLE_CUSTOMERS_GROUPS . " order by customers_group_id ");
   while ($existing_groups =  tep_db_fetch_array($customers_groups_query)) {
        $input_groups[] = array("id"=>$existing_groups['customers_group_id'], "text"=> $existing_groups['customers_group_name']);
       $all_groups[$existing_groups['customers_group_id']]=$existing_groups['customers_group_name'];
   }
// EOF Separate Pricing Per Customer

Lines 67-76

**REPLACE**

       $salemaker_sales_data_array = array('sale_name' => tep_db_prepare_input($HTTP_POST_VARS['name']),
                                           'sale_deduction_value' => tep_db_prepare_input($HTTP_POST_VARS['deduction']),
                                           'sale_deduction_type' => tep_db_prepare_input($HTTP_POST_VARS['type']),
                                           'sale_pricerange_from' => tep_db_prepare_input($HTTP_POST_VARS['from']),
                                           'sale_pricerange_to' => tep_db_prepare_input($HTTP_POST_VARS['to']),
                                           'sale_specials_condition' => tep_db_prepare_input($HTTP_POST_VARS['condition']),
                                           'sale_categories_selected' => $categories_selected_string,
                                           'sale_categories_all' => $categories_all_string,
                                           'sale_date_start' => ((tep_db_prepare_input($HTTP_POST_VARS['start']) == '') ? '0000-00-00' : tep_date_raw($HTTP_POST_VARS['start'])),
                                           'sale_date_end' => ((tep_db_prepare_input($HTTP_POST_VARS['end']) == '') ? '0000-00-00' : tep_date_raw($HTTP_POST_VARS['end'])));

**WITH**

       $salemaker_sales_data_array = array('sale_name' => tep_db_prepare_input($HTTP_POST_VARS['name']),
                                           'sale_deduction_value' => tep_db_prepare_input($HTTP_POST_VARS['deduction']),
                                           'sale_deduction_type' => tep_db_prepare_input($HTTP_POST_VARS['type']),
                                           'sale_pricerange_from' => tep_db_prepare_input($HTTP_POST_VARS['from']),
                                           'sale_pricerange_to' => tep_db_prepare_input($HTTP_POST_VARS['to']),
                                           'sale_specials_condition' => tep_db_prepare_input($HTTP_POST_VARS['condition']),
                                           'sale_categories_selected' => $categories_selected_string,
                                           'sale_categories_all' => $categories_all_string,
                                           'sale_date_start' => ((tep_db_prepare_input($HTTP_POST_VARS['start']) == '') ? '0000-00-00' : tep_date_raw($HTTP_POST_VARS['start'])),
                                           'sale_date_end' => ((tep_db_prepare_input($HTTP_POST_VARS['end']) == '') ? '0000-00-00' : tep_date_raw($HTTP_POST_VARS['end'])),
        // BOF Separate Pricing Per Customer
        'customers_group_id' => tep_db_prepare_input($HTTP_POST_VARS['customers_group']));
        // EOF Separate Pricing Per Customer
        
Line 273-275

**AFTER**

         <tr>
           <td class="main"><?php echo TEXT_SALEMAKER_SPECIALS_CONDITION; ?> </td>
           <td class="main"><?php echo tep_draw_pull_down_menu('condition', $specials_condition_array, $sInfo->sale_specials_condition); ?></td>
         </tr>
  
**ADD**

<!-- BOF Separate Pricing per Customer -->
         <tr>
           <td class="main"><?php echo TEXT_SALEMAKERS_CUST_GROUPS; ?> </td>
           <td class="main"><?php echo tep_draw_pull_down_menu('customers_group', $input_groups, $sInfo->customers_group_id)
 ?> </td>
         </tr>
<!-- EOF Separate Pricing per Customer -->

Line 354-358

**REPLACE**

               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
             </tr>
<?php
   $salemaker_sales_query_raw = "select sale_id, sale_status, sale_name, sale_deduction_value, sale_deduction_type, sale_pricerange_from, sale_pricerange_to, sale_specials_condition, sale_categories_selected, sale_categories_all, sale_date_start, sale_date_end, sale_date_added, sale_date_last_modified, sale_date_status_change from " . TABLE_SALEMAKER_SALES . " order by sale_name";
  
**WITH**

<!-- BOF Separate Pricing Per Customer v 4.11 -->	
 <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUST_GROUPS; ?></td>
<!-- EOF Separate Pricing Per Customer v 4.11 -->  
               <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_STATUS; ?></td>
               <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?> </td>
             </tr>
<?php
// BOF Separate Pricing Per Customer v 4.11
   $salemaker_sales_query_raw = "select sale_id, sale_status, sale_name, sale_deduction_value, sale_deduction_type, sale_pricerange_from, sale_pricerange_to, sale_specials_condition, sale_categories_selected, sale_categories_all, sale_date_start, sale_date_end, sale_date_added, sale_date_last_modified, sale_date_status_change, cg.customers_group_name from " . TABLE_SALEMAKER_SALES . " left join customers_groups cg using(customers_group_id)  order by sale_name";
// EOF Separate Pricing Per Customer v 4.11

Line 377

**AFTER**

               <td  class="dataTableContent" align="center"><?php echo (($salemaker_sales['sale_date_end'] == '0000-00-00') ? TEXT_SALEMAKER_NEVER : tep_date_short($salemaker_sales['sale_date_end'])); ?></td>
 
**ADD**

<!-- BOF Separate Pricing Per Customer -->
 <td class="dataTableContent" align="center"><?php
               if (strlen($salemaker_sales['customers_group_name']) > 17 ) {
            print ("<acronym title=\"".$customers['customers_group_name']."\"> ".substr($salemaker_sales['customers_group_name'], 0, 17)."?</acronym>");
            } else {
               echo $salemaker_sales['customers_group_name'];
               }  
 ?></td><!-- EOF Separate Pricing Per Customer -->

includes/functions/general.php

Line 96-111

**REPLACE**

 function tep_get_products_special_price($product_id) {
// BOF Separate Pricing Per Customer
 global $sppc_customer_group_id;
 
 if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
    $customer_group_id = $sppc_customer_group_id;
 }
  
       $product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status and customers_group_id = '" . (int)$customer_group_id . "'");
// EOF Separate_Pricing Per Customer
   $product = tep_db_fetch_array($product_query);

   return $product['specials_new_products_price'];
 }
 
**WITH**

//BOF Adapted for Separate_Pricing Per Customer/Salemaker 1.02 
 function tep_get_products_special_price($product_id) {
    global $sppc_customer_group_id;
 
 if(!tep_session_is_registered('sppc_customer_group_id')) { 
 $customer_group_id = '0';
 } else {
    $customer_group_id = $sppc_customer_group_id;
 }

 $product_query = tep_db_query("select products_price, products_model, categories_id from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_CATEGORIES . " using (products_id) WHERE p.products_id = '" . $product_id . "'");
 
    $product = tep_db_fetch_array($product_query);
    $product_price = $product['products_price'];
    $category = $product['categories_id'];

   if ($customer_group_id != '0') {
   $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . $product_id . "' AND customers_group_id = '" . $customer_group_id . "'");  
      if (tep_db_num_rows($customer_group_price_query)) {
    $customer_group_price = tep_db_fetch_array($customer_group_price_query);
    $product_price = $customer_group_price['customers_group_price'];
      }
   }
   $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $product_id . "' and status and customers_group_id = '" . (int)$customer_group_id . "'");
   if (tep_db_num_rows($specials_query)) {
     $special = tep_db_fetch_array($specials_query);
  $special_price = $special['specials_new_products_price'];
   } else {
  $special_price = false;
   }

   if(substr($product['products_model'], 0, 4) == 'GIFT') {    //Never apply a salededuction to Ian Wilson's Giftvouchers
     return $special_price;
   }

   $sale_query = tep_db_query("select sale_specials_condition, sale_deduction_value, sale_deduction_type from " . TABLE_SALEMAKER_SALES . " where sale_categories_all like '%," . $category . ",%' and sale_status = '1' and (sale_date_start <= now() or sale_date_start = '0000-00-00') and (sale_date_end >= now() or sale_date_end = '0000-00-00') and (sale_pricerange_from <= '" . $product_price . "' or sale_pricerange_from = '0') and (sale_pricerange_to >= '" . $product_price . "' or sale_pricerange_to = '0') and customers_group_id = '" . (int)$customer_group_id . "'");
   if (tep_db_num_rows($sale_query)) {
     $sale = tep_db_fetch_array($sale_query);
   } else {
  return $special_price;
   }

   if (!$special_price) {
     $tmp_special_price = $product_price;
   } else {
     $tmp_special_price = $special_price;
   }

   switch ($sale['sale_deduction_type']) {
     case 0:
       $sale_product_price = $product_price - $sale['sale_deduction_value'];
       $sale_special_price = $tmp_special_price - $sale['sale_deduction_value'];
       break;
     case 1:
       $sale_product_price = $product_price - (($product_price * $sale['sale_deduction_value']) / 100);
       $sale_special_price = $tmp_special_price - (($tmp_special_price * $sale['sale_deduction_value']) / 100);
       break;
     case 2:
       $sale_product_price = $sale['sale_deduction_value'];
       $sale_special_price = $sale['sale_deduction_value'];
       break;
     default:
       return $special_price;
   }

   if ($sale_product_price < 0) {
     $sale_product_price = 0;
   }

   if ($sale_special_price < 0) {
     $sale_special_price = 0;
   }

   if (!$special_price) {
     return number_format($sale_product_price, 4, '.', '');
} else {
     switch($sale['sale_specials_condition']){
       case 0:
         return number_format($sale_product_price, 4, '.', '');
         break;
       case 1:
         return number_format($special_price, 4, '.', '');
         break;
       case 2:
         return number_format($sale_special_price, 4, '.', '');
         break;
       default:
         return number_format($special_price, 4, '.', '');
     }
   }
 }

catalog/includes/modules/product_listing.php

Line 180-198

**REPLACE**

// an extra query is needed for all the specials

$specials_query = tep_db_query("select products_id, specials_new_products_price from " . TABLE_SPECIALS . " where (".$select_list_of_prdct_ids.") and status = '1' and customers_group_id = '" .$customer_group_id. "'");
while ($specials_array = tep_db_fetch_array($specials_query)) {
$new_s_prices[] = array ('products_id' => $specials_array['products_id'], 'products_price' => '', 'specials_new_products_price' => $specials_array['specials_new_products_price'] , 'final_price' => $specials_array['specials_new_products_price']);
}

// add the correct specials_new_products_price and replace final_price
for ($x = 0; $x < $no_of_listings; $x++) {
     
       if(!empty($new_s_prices)) {
    for ($i = 0; $i < count($new_s_prices); $i++) {
  if( $listing[$x]['products_id'] == $new_s_prices[$i]['products_id'] ) {
    $listing[$x]['specials_new_products_price'] = $new_s_prices[$i]['specials_new_products_price'];
    $listing[$x]['final_price'] = $new_s_prices[$i]['final_price'];
  }
       }
   } // end if(!empty($new_s_prices)
} // end for ($x = 0; $x < $no_of_listings; $x++)

**WITH**

// BOF Salemaker 1.02

// add the correct specials_new_products_price and replace final_price

for ($x = 0; $x < $no_of_listings; $x++) {
     
   $salemaker_price = tep_get_products_special_price($listing[$x]['products_id']);
if (tep_not_null($salemaker_price)) {
 $listing[$x]['specials_new_products_price'] = $salemaker_price;
 $listing[$x]['final_price'] = $listing[$x]['specials_new_products_price'];
} else {
 $listing[$x]['specials_new_products_price'] = '';
 $listing[$x]['final_price'] = $listing[$x]['products_price'];
}
   
} // end for ($x = 0; $x < $no_of_listings; $x++)
// EOF Salemaker 1.02 

catalog/includes/classes/PriceFormatter.php

Line 194-198 AND Line 248-252 (so has to be done twice!)

**REPLACE**

 // now get the specials price for this customer_group and add it to product_info array
 $special_price_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = " . (int)$product_id . " and status ='1' and customers_group_id = '" . $customer_group_id . "'");
 if ($specials_price = tep_db_fetch_array($special_price_query)) {
  $product_info['specials_new_products_price'] = $specials_price['specials_new_products_price'];
 }

**WITH**

 // now get the specials price for this customer_group and add it to product_info array
/*  $special_price_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = " . (int)$product_id . " and status ='1' and customers_group_id = '" . $customer_group_id . "'");
 if ($specials_price = tep_db_fetch_array($special_price_query)) {
  $product_info['specials_new_products_price'] = $specials_price['specials_new_products_price'];
 } */
 if ($specials_sales_price = tep_get_products_special_price((int)$product_id)) {
  $product_info['specials_new_products_price'] = $specials_sales_price;
 }

Link to comment
Share on other sites

Hi Jan,

 

Thanks for that code. I found an issue though in my includes/functions/general.php - Here is what I currently have at or around what you say to replace - I dont have the exact code you say to replace. So, what do I replace there?

 

  function tep_get_products_special_price($product_id) {
   $product_query = tep_db_query("select products_price, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $product_id . "'");
   if (tep_db_num_rows($product_query)) {
     $product = tep_db_fetch_array($product_query);
  $product_price = $product['products_price'];
   } else {
  return false;
   }

// BOF Separate Pricing Per Customer
 global $sppc_customer_group_id;

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

       $product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status and customers_group_id = '" . (int)$customer_group_id . "'");
// EOF Separate_Pricing Per Customer
   if (tep_db_num_rows($specials_query)) {
     $special = tep_db_fetch_array($specials_query);
  $special_price = $special['specials_new_products_price'];
   } else {
  $special_price = false;
   }

 

Here is the code you say to replace:

**REPLACE**

function tep_get_products_special_price($product_id) {
// BOF Separate Pricing Per Customer
global $sppc_customer_group_id;

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

$product_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "' and status and customers_group_id = '" . (int)$customer_group_id . "'");
// EOF Separate_Pricing Per Customer
$product = tep_db_fetch_array($product_query);

return $product['specials_new_products_price'];
}

 

So what do I do there? Thanks!

Link to comment
Share on other sites

In Priceformatter.php I dont have the code at all you are saying to replace:

 

catalog/includes/classes/PriceFormatter.php

Line 194-198 AND Line 248-252 (so has to be done twice!)

**REPLACE**

// now get the specials price for this customer_group and add it to product_info array
$special_price_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = " . (int)$product_id . " and status ='1' and customers_group_id = '" . $customer_group_id . "'");
if ($specials_price = tep_db_fetch_array($special_price_query)) {
$product_info['specials_new_products_price'] = $specials_price['specials_new_products_price'];

 

Here is my Priceformatter.php file:

<?php
/*
 $Id: PriceFormatter.php,v 1.6 2003/06/25 08:29:26 petri Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

/*
   PriceFormatter.php - module to support quantity pricing

   Created 2003, Beezle Software based on some code mods by WasaLab Oy (Thanks!)
*/

class PriceFormatter {
 var $hiPrice;
 var $lowPrice;
 var $quantity;
 var $hasQuantityPrice;

 function PriceFormatter($prices=NULL) {
   $this->productsID = -1;

   $this->hasQuantityPrice=false;
   $this->hasSpecialPrice=false;

   $this->hiPrice=-1;
   $this->lowPrice=-1;

   for ($i=1; $i<=8; $i++){
     $this->quantity[$i] = -1;
     $this->prices[$i] = -1;
   }
   $this->thePrice = -1;
   $this->specialPrice = -1;
   $this->qtyBlocks = 1;

   if($prices)
     $this->parse($prices);
 }

 function encode() {
$str = $this->productsID . ":"
       . (($this->hasQuantityPrice == true) ? "1" : "0") . ":"
       . (($this->hasSpecialPrice == true) ? "1" : "0") . ":"
       . $this->quantity[1] . ":"
       . $this->quantity[2] . ":"
       . $this->quantity[3] . ":"
       . $this->quantity[4] . ":"
    . $this->quantity[5] . ":"
    . $this->quantity[6] . ":"
    . $this->quantity[7] . ":"
       . $this->quantity[8] . ":"
       . $this->price[1] . ":"
       . $this->price[2] . ":"
       . $this->price[3] . ":"
       . $this->price[4] . ":"
    . $this->price[5] . ":"
    . $this->price[6] . ":"
    . $this->price[7] . ":"
       . $this->price[8] . ":"
       . $this->thePrice . ":"
       . $this->specialPrice . ":"
       . $this->qtyBlocks . ":"
       . $this->taxClass;
return $str;
 }

 function decode($str) {
list($this->productsID,
     $this->hasQuantityPrice,
     $this->hasSpecialPrice,
     $this->quantity[1],
     $this->quantity[2],
     $this->quantity[3],
     $this->quantity[4],
     $this->quantity[5],
     $this->quantity[6],
     $this->quantity[7],
     $this->quantity[8],
     $this->price[1],
     $this->price[2],
     $this->price[3],
     $this->price[4],
     $this->price[5],
     $this->price[6],
     $this->price[7],
     $this->price[8],
     $this->thePrice,
     $this->specialPrice,
     $this->qtyBlocks,
     $this->taxClass) = explode(":", $str);

$this->hasQuantityPrice = (($this->hasQuantityPrice == 1) ? true : false);
$this->hasSpecialPrice = (($this->hasSpecialPrice == 1) ? true : false);
 }

 function parse($prices) {
   $this->productsID = $prices['products_id'];
   $this->hasQuantityPrice=false;
   $this->hasSpecialPrice=false;

   $this->quantity[1]=$prices['products_price1_qty'];
   $this->quantity[2]=$prices['products_price2_qty'];
   $this->quantity[3]=$prices['products_price3_qty'];
   $this->quantity[4]=$prices['products_price4_qty'];
   $this->quantity[5]=$prices['products_price5_qty'];
   $this->quantity[6]=$prices['products_price6_qty'];
   $this->quantity[7]=$prices['products_price7_qty'];
   $this->quantity[8]=$prices['products_price8_qty'];

   $this->thePrice=$prices['products_price'];
   $this->specialPrice=$prices['specials_new_products_price'];
   $this->hasSpecialPrice=tep_not_null($this->specialPrice);

$this->price[1]=$prices['products_price1'];
   $this->price[2]=$prices['products_price2'];
   $this->price[3]=$prices['products_price3'];
   $this->price[4]=$prices['products_price4'];
$this->price[5]=$prices['products_price5'];
$this->price[6]=$prices['products_price6'];
$this->price[7]=$prices['products_price7'];
   $this->price[8]=$prices['products_price8'];


    /*
      Change support special prices
   If any price level has a price greater than the special
   price lower it to the special price
*/
if ($this->hasSpecialPrice == true) {
 for($i=1; $i<=8; $i++) {
	 if ($this->price[$i] > $this->specialPrice)
   $this->price[$i] = $this->specialPrice;
 }
}
//end changes to support special prices

   $this->qtyBlocks=$prices['products_qty_blocks'];

   $this->taxClass=$prices['products_tax_class_id'];

   if ($this->quantity[1] > 0) {
     $this->hasQuantityPrice = true;
     $this->hiPrice = $this->thePrice;
     $this->lowPrice = $this->thePrice;

     for($i=1; $i<=8; $i++) {
if($this->quantity[$i] > 0) {
  if ($this->price[$i] > $this->hiPrice) {
    $this->hiPrice = $this->price[$i];
  }
  if ($this->price[$i] < $this->lowPrice) {
    $this->lowPrice = $this->price[$i];
  }
}
     }
   }
 }

 function loadProduct($product_id, $language_id=1)
 {
   $sql="select pd.products_name, p.products_model, p.products_image, p.products_id," .
       " p.manufacturers_id, p.products_price, p.products_weight," .
       " p.products_price1,p.products_price2,p.products_price3,p.products_price4, p.products_price5,p.products_price6,p.products_price7,p.products_price8," .
       " p.products_price1_qty,p.products_price2_qty,p.products_price3_qty,p.products_pri
ce4_qty, p.products_price5_qty,p.products_price6_qty,p.products_price7_qty,p.products_pri
ce8_qty," .
       " p.products_qty_blocks," .
       " p.products_tax_class_id," .
       " IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price," .
       " IF(s.status, s.specials_new_products_price, p.products_price) as final_price" .
       " from " . TABLE_PRODUCTS_DESCRIPTION . " pd," .
       "      " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id," .
       "      " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id" .
       " where p.products_status = '1'" .
       "   and p.products_id = '" . (int)$product_id . "'" .
       "   and pd.products_id = '" . (int)$product_id . "'" .
       "   and pd.language_id = '". (int)$language_id ."'";

   $product_info_query = tep_db_query($sql);
   $product_info = tep_db_fetch_array($product_info_query);
   $this->parse($product_info);

   return $product_info;
 }

 function computePrice($qty)
 {
$qty = $this->adjustQty($qty);

// Compute base price, taking into account the possibility of a special
$price = ($this->hasSpecialPrice === TRUE) ? $this->specialPrice : $this->thePrice;

for ($i=1; $i<=8; $i++)
 if (($this->quantity[$i] > 0) && ($qty >= $this->quantity[$i]))
	 $price = $this->price[$i];

return $price;
 }

 function adjustQty($qty) {
// Force QTY_BLOCKS granularity
$qb = $this->getQtyBlocks();
if ($qty < 1)
 $qty = 1;

if ($qb >= 1)
{
 if ($qty < $qb)
	 $qty = $qb;

 if (($qty % $qb) != 0)
	 $qty += ($qb - ($qty % $qb));
}
return $qty;
 }

 function getQtyBlocks() {
   return $this->qtyBlocks;
 }

 function getPrice() {
   return $this->thePrice;
 }

 function getLowPrice() {
   return $this->lowPrice;
 }

 function getHiPrice() {
   return $this->hiPrice;
 }

 function hasSpecialPrice() {
   return $this->hasSpecialPrice;
 }

 function hasQuantityPrice() {
   return $this->hasQuantityPrice;
 }

 function getPriceString($style='productPriceInBox') {
   global $currencies;

   if ($this->hasSpecialPrice == true) {
  	 $lc_text = '<table align="top" border="1" cellspacing="0" cellpadding="0">';
       $lc_text .= '<tr><td align="center" class=' . $style. ' colspan="2">';
      $lc_text .= ' <s>'
 . $currencies->display_price($this->thePrice,
        tep_get_tax_rate($this->taxClass))
 . '</s>  <span class="productSpecialPrice">'
 . $currencies->display_price($this->specialPrice,
        tep_get_tax_rate($this->taxClass))
 . '</span> '
 .'</td></tr>';
   }
   else
   {
 $lc_text = '<table align="top" border="1" cellspacing="0" cellpadding="0">';
 $lc_text .= '<tr><td align="center" class=' . $style. ' colspan="2">'
 . $currencies->display_price($this->thePrice,
 tep_get_tax_rate($this->taxClass))
 . '</td></tr>';
   }
     // If you want to change the format of the price/quantity table
     // displayed on the product information page, here is where you do it.

   if($this->hasQuantityPrice == true) {
 for($i=1; $i<=8; $i++) {
	 if($this->quantity[$i] > 0) {
   $lc_text .= '<tr><td class='.$style.'>'
   . $this->quantity[$i]
   .'+ </td><td class='.$style.'>'
   . $currencies->display_price($this->price[$i],
   tep_get_tax_rate($this->taxClass))
   .'</td></tr>';
	 }
 }

 $lc_text .= '</table>';

     }
     else {
 if ($this->hasSpecialPrice == true) {
	 $lc_text = ' <s>'
    . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass))
    . '</s>  <span class="productSpecialPrice">'
    . $currencies->display_price($this->specialPrice, tep_get_tax_rate($this->taxClass))
    . '</span> ';
 }
 else {
	 $lc_text = ' '
  	 . $currencies->display_price($this->thePrice,
          tep_get_tax_rate($this->taxClass))
  	 . ' ';
 }
    	 }

   return $lc_text;
 }

 function getPriceStringShort() {
   global $currencies;

   if ($this->hasSpecialPrice == true) {
     $lc_text = ' <s>'
. $currencies->display_price($this->thePrice,
        tep_get_tax_rate($this->taxClass))
. '</s>  <span class="productSpecialPrice">'
. $currencies->display_price($this->specialPrice,
        tep_get_tax_rate($this->taxClass))
. '</span> ';
   }
   else {
     if($this->hasQuantityPrice == true) {
$lc_text = ' '
  . $currencies->display_price($this->lowPrice,
          tep_get_tax_rate($this->taxClass))
  . ' - '
  . $currencies->display_price($this->hiPrice,
          tep_get_tax_rate($this->taxClass))
  . ' ';
     }
     else {
$lc_text = ' '
  . $currencies->display_price($this->thePrice,
          tep_get_tax_rate($this->taxClass))
  . ' ';
     }
   }
   return $lc_text;
 }
}

?>

Link to comment
Share on other sites

Here is what I currently have at or around what you say to replace - I dont have the exact code you say to replace.  So, what do I replace there?
True, you didn't take out the old code, so what you posted as what you have now should be replaced.
Link to comment
Share on other sites

True, you didn't take out the old code, so what you posted as what you have now should be replaced.

 

Ok, so that entire code I posted as what I have needs to be replaced with the code you suggested? I just want to make sure than I am not screwing something up. :) Thanks for your help!

 

Julie

Link to comment
Share on other sites

Ok, so that entire code I posted as what I have needs to be replaced with the code you suggested?
Exactly, the code that you posted below: "Here is what I currently have at or around what you say to replace" to be precise.

 

Always make a backup of your files before you make any changes... you never know (I usually add the date to it: e.g. products_listing_backup20050508.php). Also it is usually safer to comment out the parts of the code you replace and only delete those parts after you verified the code works. Just to be on the safe side.

Link to comment
Share on other sites

Now I'm getting all kinds of errors.

 

On left hand column:

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/wizlair/public_html/catalog/includes/functions/database.php on line 103

 

And also get the same error on all product listings.

Link to comment
Share on other sites

Ok, fixed all my errors. :D

 

Now.... In catalog/includes/modules/new_products.php

 

I want the sale prices to reflect in that box at the bottom of my main page. Right now all that is showing is the regular prices, it does not show sale prices when I have a sale going on. Also, I would like it to show the prices ranges for my "wholesale" group. It only shows the retail price only.

 

In the product listing it shows: for product A $8.50-$12.00 instead of the regular single retail price. I'd like the new_products to show that for the wholesale people too and show sale prices for the retail group when I'm having a sale. I thought I'd had it doing that before. but it does not seem to be doing that now that I modified the file for SPPC.

 

Thanks!

 

Julie

Link to comment
Share on other sites

I have just installed this mod, and it's fab !

 

Does anyone have any idea if it works with Easy Populate ?

 

I need to change 2206 products to the different group discounts and don't feel like doing it manually for obvious reasons.

 

If anyone can just point me in the direction it would help.

 

What I need to know is:

what do i call the price fields when creating the csv file?

 

Is it something like v_products_price_wholesale ?

 

Just the structure would help.

 

Regards

Martin

Link to comment
Share on other sites

I have just installed this mod, and it's fab !

 

Does anyone have any idea if it works with Easy Populate ?

 

I need to change 2206 products to the different group discounts and don't feel like doing it manually for obvious reasons.

 

If anyone can just point me in the direction it would help.

 

What I need to know is:

what do i call the price fields when creating the csv file?

 

Is it something like v_products_price_wholesale ?

 

Just the structure would help.

 

Regards

Martin

 

Hi Martin,

 

Not sure if this mod works with EasyPopulate or not. I am changing over 1300 products one by one the old fashioned way. :)

 

Julie

Link to comment
Share on other sites

I have just installed this mod, and it's fab !

 

Does anyone have any idea if it works with Easy Populate ?

 

I need to change 2206 products to the different group discounts and don't feel like doing it manually for obvious reasons.

 

If anyone can just point me in the direction it would help.

 

What I need to know is:

what do i call the price fields when creating the csv file?

 

Is it something like v_products_price_wholesale ?

 

Just the structure would help.

 

Regards

Martin

 

Yes, I was able to get it work just fine... :) Look in the Easy Populate documentation for instructions on using the two contribs together. It's pretty straightforward.

Link to comment
Share on other sites

I'll have a peek now - thanks

 

I uncommented as suggested in the doc files of easy populate. Re-uploaded the file.

When I download the csv file from my site using EP, it still doesn't show in the file the 2 added columns.

I have changed a few of the products, so I know that it should show a few changes in the new columns.

 

Maybe I'm just overlooking something.

Link to comment
Share on other sites

In reply to JanZ's post of May 5 2005, 09:27 AM, thanks! Your mod enabling the proper handling of "%" format specials pricing in Admin seems to work. Once I'm sure it's bug-free, I'll post it to SPPC's Mod area (right?), with credits to you, of course.

 

Also, I took a look at your suggestion as to how to go about making the Attributes feature group-aware.

 

As far as I know nobody reported a working solution for that. I know I never even looked into it. It might be as simple as adding a customer_group_id to the table with a default of '0' (for retail) and going through all the code that looks for attributes and add the customer_group_id. The admin side might be another story...

 

Looks correct to me, and not too hard :) . (Add to table products_attributes a new field customers_group_id, then change the code where necessary.) I'll work on it when I have a moment.

 

In a related issue, I find myself needing to show certain products only to certain customer groups >_< . Retail customers need to see a certain subset of the products, wholesale customers another subset. There will be overlap, but each category would see products that were invisible to the other.

 

Anybody have any ideas as to how to go about adding this feature?

Link to comment
Share on other sites

Maybe I'm just overlooking something.

 

Hi, I use Easy Populate and it's work great with SPPC 4.1, you have to adjust easy Populate, here what to do for Easy Populate :

 

Open admin/easypopulate.php and search the following lines :

 

// uncomment the customer_price and customer_group to support multi-price per product contrib
 $filelayout = array(
 'v_products_model'  => $iii++,
 'v_products_price'  => $iii++,
 'v_products_quantity'  => $iii++,
 'v_customer_price_1'  => $iii++,
 'v_customer_group_id_1'  => $iii++,
 'v_customer_price_2'  => $iii++,
 'v_customer_group_id_2'  => $iii++,
 'v_customer_price_3'  => $iii++,
 'v_customer_group_id_3'  => $iii++,
 'v_customer_price_4'  => $iii++,
 'v_customer_group_id_4'  => $iii++,

 

These line will be commented out. For each customer group you have, uncomment one of the lines... If you have normal prices, and two another price like me ,uncomment group id #1 and #2 and #3.

 

After that, a little lower, you can find the text file about sql data. It looks like this :

 

// and insert the new record
  if ($v_customer_price_1 != ''){
   $result = tep_db_query('
      INSERT INTO
       '.TABLE_PRODUCTS_GROUPS.'
      VALUES
      (
       ' . $v_customer_group_id_1 . ',
       ' . $v_customer_price_1 . ',
       ' . $v_products_id . ',
       ' . $v_products_price .'
       )'
      );
  }
  if ($v_customer_price_2 != ''){
   $result = tep_db_query('
      INSERT INTO
       '.TABLE_PRODUCTS_GROUPS.'
      VALUES
      (
       ' . $v_customer_group_id_2 . ',
       ' . $v_customer_price_2 . ',
       ' . $v_products_id . ',
       ' . $v_products_price . '
       )'
      );
  }
  if ($v_customer_price_3 != ''){
   $result = tep_db_query('
      INSERT INTO
       '.TABLE_PRODUCTS_GROUPS.'
      VALUES
      (
       ' . $v_customer_group_id_3 . ',
       ' . $v_customer_price_3 . ',
       ' . $v_products_id . ',
       ' . $v_products_price . '
       )'
      );
  }
  if ($v_customer_price_4 != ''){
   $result = tep_db_query('
      INSERT INTO
       '.TABLE_PRODUCTS_GROUPS.'
      VALUES
      (
       ' . $v_customer_group_id_4 . ',
       ' . $v_customer_price_4 . ',
       ' . $v_products_id . ',
       ' . $v_products_price . '
       )'
      );
  }

 }

 

The line ' . $v_products_price . ' is not needed. Erase that whole line. I don't know why commenting the line won't work...but it won't.

 

Anyway, the line above the one you just erased has a comma at the end of it. Erase the comma so that sql knows to start another line.

 

That's it and it work like a charm. :rolleyes:

 

Just upload your excel file in admin panel via Easy Populate.

John

--------------------

osCommerce 2.3.4 Bootstrap Edge

Link to comment
Share on other sites

In a related issue, I find myself needing to show certain products only to certain customer groups  >_< .  Retail customers need to see a certain subset of the products, wholesale customers another subset.  There will be overlap, but each category would see products that were invisible to the other.

 

Anybody have any ideas as to how to go about adding this feature?

You mean something like Hide products from customer groups for SPPC? It will be hard to keep things invisible for wholesale customers, since visitors that are not logged in are considered retail customers. Once they log in they can't order it anymore of course.
Link to comment
Share on other sites

You mean something like Hide products from customer groups for SPPC? It will be hard to keep things invisible for wholesale customers, since visitors that are not logged in are considered retail customers. Once they log in they can't order it anymore of course.

 

Looks like that should do the trick. Thanks a lot. :thumbsup:

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