Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Seperate Pricing Per Customer v3.5


scendent

Recommended Posts

Couple of quick questions re: Admin Specials by Ctaegory contrib - when I enter the specials prices...does the price update the group pricing ? Is it same as when I update customer group pricing under each product?

When a group customer signs on will he/she see these prices as the groups prices?

I like this because I can put a discount %age, it seems.

Yes, you can choose the group for which the special prices are valid. You cannot change the "regular" group prices with this, only the special prices.
Link to comment
Share on other sites

raddygast,

I suspect this is because when you create an account, it doesn't actually log you in under that account, or at least it doesn't go through all the checks that would happen when you do a login with your email and password.

 

Any way to fix this? Is it an SPPC problem

Yes, it is an SPPC problem. The code to register the SPPC session variables wasn't in. It should be like this (create_account.php, starts at around line 232, note that in your case, on August 29 $sppc_customer_group_id = '1'; should be there plus above as you already done)

     if (SESSION_RECREATE == 'True') {
       tep_session_recreate();
     }

     $customer_first_name = $firstname;
     $customer_default_address_id = $address_id;
     $customer_country_id = $country;
     $customer_zone_id = $zone_id;
     tep_session_register('customer_id');
     tep_session_register('customer_first_name');
     tep_session_register('customer_default_address_id');
     tep_session_register('customer_country_id');
     tep_session_register('customer_zone_id');
// BOF Separate Pricing Per Customer 
// register SPPC session variables for a retail customer
// since this is the default for a new account
     $check_customer_group_tax = tep_db_query("select customers_group_show_tax, customers_group_tax_exempt from " . TABLE_CUSTOMERS_GROUPS . " where customers_group_id = '0'");
     $customer_group_tax = tep_db_fetch_array($check_customer_group_tax);
     $sppc_customer_group_show_tax = (int)$customer_group_tax['customers_group_show_tax'];
     $sppc_customer_group_tax_exempt = (int)$customer_group_tax['customers_group_tax_exempt'];

     $sppc_customer_group_id = '0';
     tep_session_register('sppc_customer_group_id');
     tep_session_register('sppc_customer_group_show_tax');
     tep_session_register('sppc_customer_group_tax_exempt');
// BOF Separate Pricing Per Customer

// restore cart contents

Link to comment
Share on other sites

On a different note, has anyone implemented this contrib in conjunction with the "Search Engine Friendly URL" contrib?

 

I tried yesterday and had problems, SPPC was installed and with exception to the foreign language create account side, working okay. Search Engine Friendly URL was then installed on a completely different installation of OSC (same site but different sql database etc.). SEF worked fine but caused problems with this, some of the probs could be fixed by changing GET to POST. Other issues remained on the SPPC site even after uninstalling SEF and the db this was working from.

 

Thanks for any advice,

 

Steve

 

Anyone??

Link to comment
Share on other sites

Hi All.

 

I installed this mod and there seems to be a conflict with the Head Tag Controller mod. When I try to edit a catergory I get this message:

 

Fatal error: Call to undefined function: tep_get_category_htc_title() in /xxx/admin/categories.php on line 1110

 

Is there a way to edit the /admin/categories.php so the 2 can work together.

Thanks!

Clesha

Link to comment
Share on other sites

as i get a lot of mail (keep it comming) and i dont know who i answerd and who not... cant keep track sorry :-" here is the complete master_listing including sppc / pricebreak to show the right price ;)

 

<?php
/*
 $Id: master_listing.php

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

 Copyright (c) 2003 osCommerce
 
 Master Products MS2  - JOHNSON - 05/07/2003 [email protected]

 Copyright (c) 2003 Suomedia - Dynamic Content Management

 Released under the GNU General Public License
   
*/

 $listing_split = new splitPageResults($master_sql, MAX_DISPLAY_SEARCH_RESULTS, 'products_master');
  


 if ( ($listing_split->number_of_rows > 0) && ( (MASTER_PREV_NEXT_BAR_LOCATION == '1') || (MASTER_PREV_NEXT_BAR_LOCATION == '3') ) ) {


?>


<table border="0" width="100%" cellspacing="0" cellpadding="2">
 <tr>
   <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
   <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
 </tr>
</table>
<?php
 }


 
 $list_box_contents = array();

 for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
   switch ($column_list[$col]) {
     case 'MASTER_LIST_MODEL':
       $lc_text = TABLE_HEADING_MODEL;
       $lc_align = '';
       break;
     case 'MASTER_LIST_NAME':
       $lc_text = TABLE_HEADING_PRODUCTS;
       $lc_align = '';
       break;
     case 'MASTER_LIST_DESCRIPTION':
       $lc_text = TABLE_HEADING_DESCRIPTION;
       $lc_align = 'center';
       break;
     case 'MASTER_LIST_ATTRIBUTES':
       $lc_text = TABLE_HEADING_ATTRIBUTES;
       $lc_align = 'center';
       break;                
     case 'MASTER_LIST_MANUFACTURER':
       $lc_text = TABLE_HEADING_MANUFACTURER;
       $lc_align = '';
       break;
     case 'MASTER_LIST_PRICE':
       $lc_text = TABLE_HEADING_PRICE;
       $lc_align = 'right';
       break;
     case 'MASTER_LIST_QUANTITY':
       $lc_text = TABLE_HEADING_QUANTITY;
       $lc_align = 'right';
       break;
     case 'MASTER_LIST_WEIGHT':
       $lc_text = TABLE_HEADING_WEIGHT;
       $lc_align = 'right';
       break;
     case 'MASTER_LIST_IMAGE':
       $lc_text = TABLE_HEADING_IMAGE;
       $lc_align = 'center';
       break;
     case 'MASTER_LIST_BUY_NOW':
       $lc_text = TABLE_HEADING_BUY_NOW;
       $lc_align = 'center';
       break;
   }

   if ( ($column_list[$col] != 'MASTER_LIST_BUY_NOW') && ($column_list[$col] != 'MASTER_LIST_IMAGE' && ($column_list[$col] != 'MASTER_LIST_MULTIPLE' && ($column_list[$col] != 'MASTER_LIST_DESCRIPTION'))) ) {
     $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');

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'];
} 
// next part is a debug feature, when uncommented it will print the info that this module receives

/*   echo '<pre>';
  print_r($listing);
  echo '</pre>'; */
 
 $select_list_of_prdct_ids = "products_id = '".$list_of_prdct_ids[0]."' ";
 if ($no_of_listings > 1) {
  for ($n = 1; $n < count($list_of_prdct_ids); $n++) {
  $select_list_of_prdct_ids .= "or products_id = '".$list_of_prdct_ids[$n]."' "; 
  }
}
// to avoid messing with index.php, which is complicated of itself already
// we add another query here to get the price break variables for retail customers
// for other groups we change the $pg_query from the one in SPPC4

  if ($customer_group_id == '0') {
$retail_price_break_query = tep_db_query("select p.products_id, 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_price4_qty, p.products_price5_qty, p.products_price6_qty, p.products_price7_qty, p.products_price8_qty, p.products_qty_blocks from " . TABLE_PRODUCTS . " p where " . $select_list_of_prdct_ids . "");
while ($rp_break = tep_db_fetch_array($retail_price_break_query)) {
 for ($u = 0; $u < $no_of_listings; $u++) {
	 if ($rp_break['products_id'] == $listing[$u]['products_id']) {
   $listing[$u]['products_price1'] = $rp_break['products_price1'];
   $listing[$u]['products_price2'] = $rp_break['products_price2'];
   $listing[$u]['products_price3'] = $rp_break['products_price3'];
   $listing[$u]['products_price4'] = $rp_break['products_price4'];
   $listing[$u]['products_price5'] = $rp_break['products_price5'];
   $listing[$u]['products_price6'] = $rp_break['products_price6'];
   $listing[$u]['products_price7'] = $rp_break['products_price7'];
   $listing[$u]['products_price8'] = $rp_break['products_price8'];
   $listing[$u]['products_price1_qty'] = $rp_break['products_price1_qty'];
   $listing[$u]['products_price2_qty'] = $rp_break['products_price2_qty'];
   $listing[$u]['products_price3_qty'] = $rp_break['products_price3_qty'];
   $listing[$u]['products_price4_qty'] = $rp_break['products_price4_qty'];
   $listing[$u]['products_price5_qty'] = $rp_break['products_price5_qty'];
   $listing[$u]['products_price6_qty'] = $rp_break['products_price6_qty'];
   $listing[$u]['products_price7_qty'] = $rp_break['products_price7_qty'];
   $listing[$u]['products_price8_qty'] = $rp_break['products_price8_qty'];
   $listing[$u]['products_qty_blocks'] = $rp_break['products_qty_blocks'];
	 } // end if ($rp_break['products_id'] == $listing[$u]['products_id'])
} // end for ($u = 0; $u < $no_of_listings; $u++)
} // end while ($rp_break = tep_db_fetch_array($retail_price_break_query)
  } // end if ($customer_group_id == '0')
  
// get all product 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, pg.products_price1, pg.products_price2, pg.products_price3, pg.products_price4, pg.products_price5, pg.products_price6, pg.products_price7, pg.products_price8, pg.products_price1_qty, pg.products_price2_qty, pg.products_price3_qty, pg.products_price4_qty, pg.products_price5_qty, pg.products_price6_qty, pg.products_price7_qty, pg.products_price8_qty, pg.products_qty_blocks from " . TABLE_PRODUCTS_GROUPS . " pg where (".$select_list_of_prdct_ids.") and pg.customers_group_id = '".$customer_group_id."' ");
//   $no_of_pg_products = tep_db_num_rows($pg_query);
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' => '', 'final_price' => $pg_array['price'], 'products_price1' => $pg_array['products_price1'], 'products_price2' => $pg_array['products_price2'], 'products_price3' => $pg_array['products_price3'], 'products_price4' => $pg_array['products_price4'], 'products_price5' => $pg_array['products_price5'], 'products_price6' => $pg_array['products_price6'], 'products_price7' => $pg_array['products_price7'], 'products_price8' => $pg_array['products_price8'], 'products_price1_qty' => $pg_array['products_price1_qty'], 'products_price2_qty' => $pg_array['products_price2_qty'], 'products_price3_qty' => $pg_array['products_price3_qty'], 'products_price4_qty' => $pg_array['products_price4_qty'], 'products_price5_qty' => $pg_array['products_price5_qty'], 'products_price6_qty' => $pg_array['products_price6_qty'], 'products_price7_qty' => $pg_array['products_price7_qty'], 'products_price8_qty' => $pg_array['products_price8_qty'], 'products_qty_blocks' => $pg_array['products_qty_blocks']);
}
  for ($x = 0; $x < $no_of_listings; $x++) {
// replace products prices with those from customers_group table
     if(!empty($new_prices)) {
        for ($i = 0; $i < count($new_prices); $i++) {
    if( $listing[$x]['products_id'] == $new_prices[$i]['products_id'] ) {
 $listing[$x]['products_price'] = $new_prices[$i]['products_price'];
 $listing[$x]['final_price'] = $new_prices[$i]['final_price'];
 $listing[$x]['products_price1'] = $new_prices[$i]['products_price1'];
 $listing[$x]['products_price2'] = $new_prices[$i]['products_price2'];
 $listing[$x]['products_price3'] = $new_prices[$i]['products_price3'];
 $listing[$x]['products_price4'] = $new_prices[$i]['products_price4'];
 $listing[$x]['products_price5'] = $new_prices[$i]['products_price5'];
 $listing[$x]['products_price6'] = $new_prices[$i]['products_price6'];
 $listing[$x]['products_price7'] = $new_prices[$i]['products_price7'];
 $listing[$x]['products_price8'] = $new_prices[$i]['products_price8'];
 $listing[$x]['products_price1_qty'] = $new_prices[$i]['products_price1_qty'];
 $listing[$x]['products_price2_qty'] = $new_prices[$i]['products_price2_qty'];
 $listing[$x]['products_price3_qty'] = $new_prices[$i]['products_price3_qty'];
 $listing[$x]['products_price4_qty'] = $new_prices[$i]['products_price4_qty'];
 $listing[$x]['products_price5_qty'] = $new_prices[$i]['products_price5_qty'];
 $listing[$x]['products_price6_qty'] = $new_prices[$i]['products_price6_qty'];
 $listing[$x]['products_price7_qty'] = $new_prices[$i]['products_price7_qty'];
 $listing[$x]['products_price8_qty'] = $new_prices[$i]['products_price8_qty'];
 $listing[$x]['products_qty_blocks'] = $new_prices[$i]['products_qty_blocks'];
 }
    }
} // end if(!empty($new_prices)
$listing[$x]['specials_new_products_price'] = ''; // makes sure that a retail specials price doesn't carry over to another customer group
$listing[$x]['final_price'] = $listing[$x]['products_price']; // final price should not be the retail special price
  } // end for ($x = 0; $x < $no_of_listings; $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 (".$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++)
   
//    while ($listing = tep_db_fetch_array($listing_query)) { (was original code)
for ($x = 0; $x < $no_of_listings; $x++) {

     $rows++;

     if (($rows/2) == floor($rows/2)) {
       $list_box_contents[] = array('params' => 'class="productListing-even"');
     } else {
       $list_box_contents[] = array('params' => 'class="productListing-odd"');
     }

     $cur_row = sizeof($list_box_contents) - 1;

     for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
       $lc_align = '';
       $lc_params = '';

       switch ($column_list[$col]) {
         case 'MASTER_LIST_MODEL':
           $lc_align = '';
           $lc_text = ' ' . $listing[$x]['products_model'] . ' ';
           break;
         case 'MASTER_LIST_NAME':
           $lc_align = '';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>';
           } else {
             $lc_text = ' ' . $listing[$x]['products_name'] . '</a> ';
           }
           break;
         case 'MASTER_LIST_DESCRIPTION':
           $lc_align = '';
           $lc_text = ' ' . osc_trunc_string(strip_tags($listing[$x]['products_description'], '<a><b><em><font><i><s><span><strong><sub><sup><u>'), MASTER_LIST_DESCRIPTION_LENGTH) . ' ';

           break;            
         case 'MASTER_LIST_MANUFACTURER':
           $lc_align = '';
           $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a> ';
           break;
         case 'MASTER_LIST_PRICE':
           $lc_align = 'right';
/*  removed for price break modification
             if (tep_not_null($listing[$x]['specials_new_products_price'])) {
             $lc_text = ' <s>' .  $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</s>  <span class="productSpecialPrice">' . $currencies->display_price($listing[$x]['specials_new_products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . '</span> ';
           } else {
             $lc_text = ' ' . $currencies->display_price($listing[$x]['products_price'], tep_get_tax_rate($listing[$x]['products_tax_class_id'])) . ' ';
           } end removed for price break modification, see next two lines for replacement code */

           $pf->parse($listing[$x]);
           $lc_text = $pf->getPriceStringShort();
           break;
         case 'MASTER_LIST_QUANTITY':
           $lc_align = 'right';
           $lc_text = ' ' . $listing[$x]['products_quantity'] . ' ';
           break;
         case 'MASTER_LIST_WEIGHT':
           $lc_align = 'right';
           $lc_text = ' ' . $listing[$x]['products_weight'] . ' ';
           break;
         case 'MASTER_LIST_IMAGE':
           $lc_align = 'center';
           if (isset($HTTP_GET_VARS['manufacturers_id'])) {
             $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
           } else {
             $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing[$x]['products_image'], $listing[$x]['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
           }
           break;

         case 'MASTER_LIST_BUY_NOW': 

           $lc_align = 'center'; 
           $lc_valign = 'top';
           if ((STOCK_CHECK == 'true')&&(tep_get_products_stock($listing[$x]['products_id']) < 1)) { 
           $lc_text = TEXT_STOCK;
         } elseif ((STOCK_CHECK == 'false')&&(tep_get_products_stock($listing[$x]['products_id']) < 1)) {
           $qty_array = array();
           for ($i=0; $ns = 20, $i <= $ns; $i++) {
           $qty_array[] = array('id' => $i, 'text' => $i); 
            
           $lc_text = tep_draw_pull_down_menu('Qty_ProdId_' . $listing[$x]['products_id'], $qty_array);
                       
           }
         } else {
           $quantity = tep_get_products_stock($listing[$x]['products_id']);  
           $qty_array = array();
           for ($i=0; $ns = (($quantity < 20) ? $quantity : 20), $i <= $ns; $i++) {
           $qty_array[] = array('id' => $i, 'text' => $i); 
            
           $lc_text = tep_draw_pull_down_menu('Qty_ProdId_' . $listing[$x]['products_id'], $qty_array);
                       
           } 
       }
          break;
       }
       $list_box_contents[$cur_row][] = array('align' => $lc_align,
                                              'valign' => $lc_valign,
                                              'params' => 'class="productListing-data"',
                                              'text'  => $lc_text);
     }
   }

   new productListingBox($list_box_contents);
 } else {
   $list_box_contents = array();

   $list_box_contents[0] = array('params' => 'class="productListing-odd"');
   $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                  'text' => TEXT_NO_PRODUCTS);

   new productListingBox($list_box_contents);
 }
?>
    <table border="0" width="100%" cellspacing="0" cellpadding="2">
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
    </table>
<?php
 if ( ($listing_split->number_of_rows > 0) && ((MASTER_PREV_NEXT_BAR_LOCATION == '2') || (MASTER_PREV_NEXT_BAR_LOCATION == '3')) ) {
?>     
    <table border="0" width="100%" cellspacing="0" cellpadding="2">          
    <tr>
       <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
       <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
    </tr>
   </table>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>

<?php
 }
?>

 

greetz john

Link to comment
Share on other sites

I installed the newest version and imported the sql file but I get a strange error!

My table name is "products_xsell"

but I get this error...

 

1146 - Table 'shop.table_products_xsell' doesn't exist

 

select distinct p.products_id, p.products_image, pd.products_name, p.products_tax_class_id, products_price from TABLE_PRODUCTS_XSELL xp, products p, products_description pd where xp.products_id = '1' and xp.xsell_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '4' and p.products_status = '1' order by sort_order asc limit 6

 

[TEP STOP]

 

 

Please advice

?,???`???,?? God must love stupid people, he made so many ??,???`???,?

Link to comment
Share on other sites

I installed the newest version
of the XSELL contribution? This is the thread on SPPC...

 

My table name is "products_xsell"

but I get this error...

 

1146 - Table 'shop.table_products_xsell' doesn't exist

My guess is that you either didn't define the table products_xsell or in the wrong place (this is from a or the xsell contribution you installed):

STEP 3
ReplaceAdd to catalog/includes/database_tables.php
// Added for Xsell Products Mod
define('TABLE_PRODUCTS_XSELL', 'products_xsell');

Link to comment
Share on other sites

Argh!!! I've spent 3 hours implementing this contribution, and it won't work! I get this error message:

 

Parse error: syntax error, unexpected T_RETURN, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/users/dafiks/www/includes/classes/shopping_cart.php on line 393

 

This is my Shopping_cart.php:

 

<?php
/*
 $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class shoppingCart {
   var $contents, $total, $weight, $cartID, $content_type;

   function shoppingCart() {
     $this->reset();
   }

   function restore_contents() {
     global $customer_id;

     if (!tep_session_is_registered('customer_id')) return false;

// insert current cart contents in database
     if (is_array($this->contents)) {
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
         $qty = $this->contents[$products_id]['qty'];
// BOF Separate Pricing Per Customer
// global variable (session) $sppc_customer_group_id -> class variable cg_id
 global $sppc_customer_group_id;

 if(!tep_session_is_registered('sppc_customer_group_id')) {
 $this->cg_id = '0';
 } else {
  $this->cg_id = $sppc_customer_group_id;
 }
// EOF Separate Pricing Per Customer
         $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
         if (!tep_db_num_rows($product_query)) {
           tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
           if (isset($this->contents[$products_id]['attributes'])) {
             reset($this->contents[$products_id]['attributes']);
             while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
               tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
             }
           }
         } else {
           tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
         }
       }
     }

// reset per-session cart contents, but not the database contents
     $this->reset(false);

     $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
     while ($products = tep_db_fetch_array($products_query)) {
       $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);
// attributes
       $attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
       while ($attributes = tep_db_fetch_array($attributes_query)) {
         $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
       }
     }

     $this->cleanup();
   }

   function reset($reset_database = false) {
     global $customer_id;

     $this->contents = array();
     $this->total = 0;
     $this->weight = 0;
     $this->content_type = false;

     if (tep_session_is_registered('customer_id') && ($reset_database == true)) {
       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
     }

     unset($this->cartID);
     if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');
   }

   function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
     global $new_products_id_in_cart, $customer_id;

     $products_id = tep_get_uprid($products_id, $attributes);
     if ($notify == true) {
       $new_products_id_in_cart = $products_id;
       tep_session_register('new_products_id_in_cart');
     }

     if ($this->in_cart($products_id)) {
       $this->update_quantity($products_id, $qty, $attributes);
     } else {
       $this->contents[] = array($products_id);
       $this->contents[$products_id] = array('qty' => $qty);
// insert into database
       if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

       if (is_array($attributes)) {
         reset($attributes);
         while (list($option, $value) = each($attributes)) {
           $this->contents[$products_id]['attributes'][$option] = $value;
// insert into database
           if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
         }
       }
     }
     $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
     $this->cartID = $this->generate_cart_id();
   }

   function update_quantity($products_id, $quantity = '', $attributes = '') {
     global $customer_id;

     if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

     $this->contents[$products_id] = array('qty' => $quantity);
// update database
     if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

     if (is_array($attributes)) {
       reset($attributes);
       while (list($option, $value) = each($attributes)) {
         $this->contents[$products_id]['attributes'][$option] = $value;
// update database
         if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");
       }
     }
   }

   function cleanup() {
     global $customer_id;

     reset($this->contents);
     while (list($key,) = each($this->contents)) {
       if ($this->contents[$key]['qty'] < 1) {
         unset($this->contents[$key]);
// remove from database
         if (tep_session_is_registered('customer_id')) {
           tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
           tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
         }
       }
     }
   }

   function count_contents() {  // get total number of items in cart 
     $total_items = 0;
     if (is_array($this->contents)) {
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
         $total_items += $this->get_quantity($products_id);
       }
     }

     return $total_items;
   }

   function get_quantity($products_id) {
     if (isset($this->contents[$products_id])) {
       return $this->contents[$products_id]['qty'];
     } else {
       return 0;
     }
   }

   function in_cart($products_id) {
     if (isset($this->contents[$products_id])) {
       return true;
     } else {
       return false;
     }
   }

   function remove($products_id) {
     global $customer_id;

     unset($this->contents[$products_id]);
// remove from database
     if (tep_session_is_registered('customer_id')) {
       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
     }

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
     $this->cartID = $this->generate_cart_id();
   }

   function remove_all() {
     $this->reset();
   }

   function get_product_id_list() {
     $product_id_list = '';
     if (is_array($this->contents)) {
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
         $product_id_list .= ', ' . $products_id;
       }
     }

     return substr($product_id_list, 2);
   }

   function calculate() {
     $this->total = 0;
     $this->weight = 0;
     if (!is_array($this->contents)) return 0;

     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
       $qty = $this->contents[$products_id]['qty'];

// products price
       $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
       if ($product = tep_db_fetch_array($product_query)) {
         $prid = $product['products_id'];
         $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
         $products_price = $product['products_price'];
         $products_weight = $product['products_weight'];
 
      //CustomerDiscount start
      global $customer_id;
         $query = tep_db_query("select customers_discount from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");
         $query_result = tep_db_fetch_array($query);
         $customer_discount = $query_result['customers_discount'];
   if (strstr($customer_discount, "+") != null) {
      $products_price = $products_price + $products_price * abs($customer_discount) / 100;
      } else {
      $products_price = $products_price - $products_price * abs($customer_discount) / 100;
      }
         //CustomerDiscount end

         // BOF Separate Pricing Per Customer
/*         $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");

         if (tep_db_num_rows ($specials_query)) {
           $specials = tep_db_fetch_array($specials_query);
           $products_price = $specials['specials_new_products_price'];
         } */
  $specials_price = tep_get_products_special_price((int)$prid);
     if (tep_not_null($specials_price)) {
 $products_price = $specials_price;
     } elseif ($this->cg_id != 0){
       $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$prid . "' and customers_group_id =  '" . $this->cg_id . "'");
       if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
       $products_price = $customer_group_price['customers_group_price'];
       }
     }
// EOF Separate Pricing Per Customer
 
         $this->total += tep_add_tax($products_price, $products_tax) * $qty;
         $this->weight += ($qty * $products_weight);
       }

// attributes price
       if (isset($this->contents[$products_id]['attributes'])) {
         reset($this->contents[$products_id]['attributes']);
         while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
           $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
           $attribute_price = tep_db_fetch_array($attribute_price_query);

      //CustomerDiscount start
      global $customer_id;
         $query = tep_db_query("select customers_discount from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");
         $query_result = tep_db_fetch_array($query);
         $customer_discount = $query_result['customers_discount'];
   if (strstr($customer_discount, "+") != null) {
      $attribute_price['options_values_price'] = $attribute_price['options_values_price'] + $attribute_price['options_values_price'] * abs($customer_discount) / 100;
      } else {
      $attribute_price['options_values_price'] = $attribute_price['options_values_price'] - $attribute_price['options_values_price'] * abs($customer_discount) / 100;
      }
         //CustomerDiscount end

           if ($attribute_price['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
         }
       }
     }
   }

   function attributes_price($products_id) {
     $attributes_price = 0;

     if (isset($this->contents[$products_id]['attributes'])) {
       reset($this->contents[$products_id]['attributes']);
       while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
         $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
         $attribute_price = tep_db_fetch_array($attribute_price_query);

   //CustomerDiscount start
      global $customer_id;
         $query = tep_db_query("select customers_discount from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");
         $query_result = tep_db_fetch_array($query);
         $customer_discount = $query_result['customers_discount'];
   if (strstr($customer_discount, "+") != null) {
      $attribute_price['options_values_price'] = $attribute_price['options_values_price'] + $attribute_price['options_values_price'] * abs($customer_discount) / 100;
      } else {
      $attribute_price['options_values_price'] = $attribute_price['options_values_price'] - $attribute_price['options_values_price'] * abs($customer_discount) / 100;
      }
         //CustomerDiscount end

         if ($attribute_price['price_prefix'] == '+') {
           $attributes_price += $attribute_price['options_values_price'];
         } else {
           $attributes_price -= $attribute_price['options_values_price'];
         }
       }
     }

     return $attributes_price;
   }

   function get_products() {
     global $languages_id;
// BOF Separate Pricing Per Customer
// global variable (session) $sppc_customer_group_id -> class variable cg_id
 global $sppc_customer_group_id;

 if(!tep_session_is_registered('sppc_customer_group_id')) {
 $this->cg_id = '0';
 } else {
  $this->cg_id = $sppc_customer_group_id;
 }
// EOF Separate Pricing Per Customer

     if (!is_array($this->contents)) return false;

     $products_array = array();
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
       $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
       if ($products = tep_db_fetch_array($products_query)) {
         $prid = $products['products_id'];
         $products_price = $products['products_price'];

      //CustomerDiscount start
      global $customer_id;
         $query = tep_db_query("select customers_discount from " . TABLE_CUSTOMERS . " where customers_id =  '" . $customer_id . "'");
         $query_result = tep_db_fetch_array($query);
         $customer_discount = $query_result['customers_discount'];
   if (strstr($customer_discount, "+") != null) {
      $products_price = $products_price + $products_price * abs($customer_discount) / 100;
      } else {
      $products_price = $products_price - $products_price * abs($customer_discount) / 100;
      }
         //CustomerDiscount end

         // BOF Separate Pricing Per Customer
/*          $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");

         if (tep_db_num_rows($specials_query)) {
           $specials = tep_db_fetch_array($specials_query);
           $products_price = $specials['specials_new_products_price'];
         } */
  $specials_price = tep_get_products_special_price($prid);
 if (tep_not_null($specials_price)) {
 $products_price = $specials_price;
     } elseif ($this->cg_id != 0){
       $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$prid . "' and customers_group_id =  '" . $this->cg_id . "'");
       if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) {
       $products_price = $customer_group_price['customers_group_price'];
       }
 }
// EOF Separate Pricing Per Customer

         }

         $products_array[] = array('id' => $products_id,
                                   'name' => $products['products_name'],
                                   'model' => $products['products_model'],
                                   'image' => $products['products_image'],
                                   'price' => $products_price,
                                   'quantity' => $this->contents[$products_id]['qty'],
                                   'weight' => $products['products_weight'],
                                   'final_price' => ($products_price + $this->attributes_price($products_id)),
                                   'tax_class_id' => $products['products_tax_class_id'],
                                   'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
       }
     }

     return $products_array;
   }

   function show_total() {
     $this->calculate();

     return $this->total;
   }

   function show_weight() {
     $this->calculate();

     return $this->weight;
   }

   function generate_cart_id($length = 5) {
     return tep_create_random_value($length, 'digits');
   }

   function get_content_type() {
     $this->content_type = false;

     if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
         if (isset($this->contents[$products_id]['attributes'])) {
           reset($this->contents[$products_id]['attributes']);
           while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
             $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");
             $virtual_check = tep_db_fetch_array($virtual_check_query);

             if ($virtual_check['total'] > 0) {
               switch ($this->content_type) {
                 case 'physical':
                   $this->content_type = 'mixed';

                   return $this->content_type;
                   break;
                 default:
                   $this->content_type = 'virtual';
                   break;
               }
             } else {
               switch ($this->content_type) {
                 case 'virtual':
                   $this->content_type = 'mixed';

                   return $this->content_type;
                   break;
                 default:
                   $this->content_type = 'physical';
                   break;
               }
             }
           }
         } else {
           switch ($this->content_type) {
             case 'virtual':
               $this->content_type = 'mixed';

               return $this->content_type;
               break;
             default:
               $this->content_type = 'physical';
               break;
           }
         }
       }
     } else {
       $this->content_type = 'physical';
     }

     return $this->content_type;
   }

   function unserialize($broken) {
     for(reset($broken);$kv=each($broken);) {
       $key=$kv['key'];
       if (gettype($this->$key)!="user function")
       $this->$key=$kv['value'];
     }
   }

 }
?>

 

I hope someone can help me!! Please!

Link to comment
Share on other sites

Argh!!! I've spent 3 hours implementing this contribution, and it won't work! I get this error message:

 

Parse error: syntax error, unexpected T_RETURN, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/users/dafiks/www/includes/classes/shopping_cart.php on line 393

A quick look makes me think you have a } too much somewhere around line 378 (80% down the file):

// EOF Separate Pricing Per Customer

? ? ? ? ?} // => looks like one } too many

? ? ? ? ?$products_array[] = array('id' => $products_id,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'name' => $products['products_name'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'model' => $products['products_model'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'image' => $products['products_image'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'price' => $products_price,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'quantity' => $this->contents[$products_id]['qty'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'weight' => $products['products_weight'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'final_price' => ($products_price + $this->attributes_price($products_id)),
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'tax_class_id' => $products['products_tax_class_id'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
? ? ? ?}
? ? ?}

? ? ?return $products_array;
? ?}

? ?function show_total() {

Link to comment
Share on other sites

I need a little help from the great guru's of this fabulouse contribution....I've got SPPC 4.1.1 installed and working fine. I've also got the Price Break mod installed and it works also...however it's not quite what I want.

 

I need the QPB to be independent of attributes. I have a small but blooming custom candle business. And I want to offer my customers quantity discounts but want them to be fragrant independent. For example:

 

Product A = $6.00 for 1, $5.00 for 2 or more. Fragrances are in a drop down attribute box. So if a customer orders 1 of Product A, Fragrance A...and 1 of Product A, Fragrance B they would get the price break. Currently if they order the above they would still get charged $6.00 each. The price break mod works fine if they order quantity of the same product and fragrance.

 

I know the solution lies in the shopping cart class but I just can't seem to get it to work correctly.

 

Any ideas or help????

 

Many thanks,

Greg

I only do what my Rice Krispies tell me to do!

Link to comment
Share on other sites

I need the QPB to be independent of attributes. I have a small but blooming custom candle business. And I want to offer my customers quantity discounts but want them to be fragrant independent. For example:

 

Product A = $6.00 for 1, $5.00 for 2 or more. Fragrances are in a drop down attribute box. So if a customer orders 1 of Product A, Fragrance A...and 1 of Product A, Fragrance B they would get the price break. Currently if they order the above they would still get charged $6.00 each. The price break mod works fine if they order quantity of the same product and fragrance.

 

I know the solution lies in the shopping cart class but I just can't seem to get it to work correctly.

 

Any ideas or help????

 

Many thanks,

Greg

there is a code fix, in this thread i believe (or at best one of the sppc threads), that tallies the price break on the cart quantity, not the product quantity. i might be able to dig it out of my heavily modified code for you if you can't find it. my cart gives wholesaler group a price break based on what's in the cart.

try a few different forum searches, the answer is on the forums somewhere.

Link to comment
Share on other sites

there is a code fix, in this thread i believe (or at best one of the sppc threads), that tallies the price break on the cart quantity, not the product quantity. i might be able to dig it out of my heavily modified code for you if you can't find it. my cart gives wholesaler group a price break based on what's in the cart.

try a few different forum searches, the answer is on the forums somewhere.

 

 

Yes...I did see that..believe it or not..I actually waded through the 40+ pages of this forum since the intro of 4.1. (What a chore.....LMAO!!)

 

Correct me if I'm wrong please..but doesn't that base the discounts on the TOTAL cart quantity..i.e. Product A + Product B etc..?? What I'm searching for is: Product A: Attribute A + Product A: Attribute B = Quantity discount for Product A. I guess simplified....Quantity discounts based on mixed attributes, not mixed products.

 

Many thanks!!

I only do what my Rice Krispies tell me to do!

Link to comment
Share on other sites

there is a code fix, in this thread i believe (or at best one of the sppc threads), that tallies the price break on the cart quantity, not the product quantity. i might be able to dig it out of my heavily modified code for you if you can't find it. my cart gives wholesaler group a price break based on what's in the cart.

I wrote install instructions for that modification today and added those to the Quantity Price Breaks for SPPC contribution as version 1.02.

 

Michael/ArtRat is right, to enable price breaks for a "base product_id" very similar code is needed, so that is why I wrote up this modification now.

Link to comment
Share on other sites

Correct me if I'm wrong please..but doesn't that base the discounts on the TOTAL cart quantity..i.e. Product A + Product B etc..?? What I'm searching for is: Product A: Attribute A + Product A: Attribute B = Quantity discount for Product A. I guess simplified....Quantity discounts based on mixed attributes, not mixed products.

Greg,

 

This seems to work for your "special" case:

catalog/includes/classes/shopping_cart.php

Line 4

**AFTER** 
 adapted for Separate Pricing Per Customer v4 and Price Break 1.11.3 2005/03/12
 
**ADD**
 adapted for price break per "base products_id" 2005/09/03
  
Line 50-51

**REPLACE**
     while ($products = tep_db_fetch_array($products_query)) {
       $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']);

**WITH**

// BOF Price Break for SPPC mod, price break per per base products_id
     while ($products = tep_db_fetch_array($products_query)) {
       $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity'], 'base_pid' => (int)$products['products_id']);
// EOF Price Break for SPPC mod, price break per base products_id

Line 83-85

**AFTER**
     $pf = new PriceFormatter;
     $pf->loadProduct($products_id, $languages_id);
     $qty = $pf->adjustQty($qty);
     
**ADD**
     $base_pid = $pf->get_base_pid();
     
Line 94-98

**REPLACE**

     if ($this->in_cart($products_id)) {
       $this->update_quantity($products_id, $qty, $attributes);
     } else {
       $this->contents[] = array($products_id);
       $this->contents[$products_id] = array('qty' => $qty);

**WITH**

// BOF Price Break for SPPC mod, price break per base products_id
     if ($this->in_cart($products_id)) {
       $this->update_quantity($products_id, $qty, $attributes, $base_pid); //added base products_id
     } else {
       $this->contents[] = array($products_id);
       $this->contents[$products_id] = array('qty' => $qty, 'base_pid' => $base_pid); //added base products_id
// EOF Price Break for SPPC mod, price break per base products_id

Line 117-122

**REPLACE**
   function update_quantity($products_id, $quantity = '', $attributes = '') {
     global $customer_id;

     if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

     $this->contents[$products_id] = array('qty' => $quantity);
     
**WITH**
// BOF Price Break for SPPC mod, price break per base products_id
   function update_quantity($products_id, $quantity = '', $attributes = '', $base_pid = '') { //added base products_id
     global $customer_id;

     if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

     $this->contents[$products_id] = array('qty' => $quantity, 'base_pid' => $base_pid); //added base products_id

Line 210-216

**REPLACE**

   function calculate() {
     $this->total = 0;
     $this->weight = 0;
     if (!is_array($this->contents)) return 0;
// BOF Separate Pricing Per Customer, Price Break 1.11.3 mod
  global $languages_id;
  $pf = new PriceFormatter;
  
**WITH**

   function calculate() {
     $this->total = 0;
     $this->weight = 0;
     // BOF Price Break for SPPC mod, price break per base products_id
     global $languages_id;
     if (!is_array($this->contents)) return 0;
 $base_pid_quantity = array(); // calculates no of items per category in shopping basket
 // note that the function adjustQty has not been called yet (invoked by $pf->computePrice), 
 // so this may not be the correct number of items yet
     foreach ($this->contents as $products_id => $contents_array) {
      if (!isset($base_pid_quantity[$contents_array['base_pid']])) {
  $base_pid_quantity[$contents_array['base_pid']] = $contents_array['qty'];
      } else {
  $base_pid_quantity[$contents_array['base_pid']] += $contents_array['qty'];
      }
     } // end foreach

  $pf = new PriceFormatter;
//   EOF Price Break for SPPC mod, price break per base products_id

Line 219-220

**AFTER**
     while (list($products_id, ) = each($this->contents)) {
       $qty = $this->contents[$products_id]['qty'];
     
**ADD**

$number_of_items_in_cart_same_base_pid = $base_pid_quantity[$this->contents[$products_id]['base_pid']];
$no_of_other_items_in_cart_with_same_base_pid = $number_of_items_in_cart_same_base_pid - $qty;

Line 230

**REPLACE**
         $products_price = $pf->computePrice($qty);
  
**WITH**
        $products_price = $pf->computePrice($qty, $no_of_other_items_in_cart_with_same_base_pid);
 
Line 274-276

**REPLACE**
// BOF Separate Pricing Per Customer v4, Price Break 1.11.3 modification
     if (!is_array($this->contents)) return false;
      $pf = new PriceFormatter;
     
**WITH**
// BOF Separate Pricing Per Customer v4, Price Break 1.11.3 modification
     if (!is_array($this->contents)) return false;
//   BOF Price Break for SPPC mod, price break per base products_id    
     $base_pid_quantity = array();
     foreach ($this->contents as $products_id => $contents_array) {
      if (!isset($base_pid_quantity[$contents_array['base_pid']])) {
  $base_pid_quantity[$contents_array['base_pid']] = $contents_array['qty'];
      } else {
  $base_pid_quantity[$contents_array['base_pid']] += $contents_array['qty'];
      }
     } // end foreach
     
     $pf = new PriceFormatter;
//   EOF Price Break for SPPC mod, price break per base products_id

Line 292-293

**REPLACE**
       if ($products = $pf->loadProduct($products_id, $languages_id)) {
         $products_price = $pf->computePrice($this->contents[$products_id]['qty']);
**WITH**
  if ($products = $pf->loadProduct($products_id, $languages_id)) {
   $qty = $this->contents[$products_id]['qty'];
$number_of_items_in_cart_same_base_pid = $base_pid_quantity[$this->contents[$products_id]['base_pid']];
$no_of_other_items_in_cart_with_same_base_pid = $number_of_items_in_cart_same_base_pid - $qty;

        $products_price = $pf->computePrice($this->contents[$products_id]['qty'], $no_of_other_items_in_cart_with_same_base_pid);

Line 295-298

**AFTER**
         $products_array[] = array('id' => $products_id,
                                   'name' => $products['products_name'],
                                   'model' => $products['products_model'],
                                   'image' => $products['products_image'],
**ADD**
//   BOF Price Break for SPPC mod, price break per base products_id
       'base_pid' => $this->contents[$products_id]['base_pid'],
//   EOF Price Break for SPPC mod, price break per base products_id

------------------------------------------
catalog/includes/classes/PriceFormatter.php

Line 4

**AFTER**
 adapted for Separate Pricing Per Customer v4 2005/03/20
 
**ADD**
 adapted for price break per base products_id 2005/09/03

Line 27-28

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

**ADD**
//   BOF Price Break for SPPC mod, price break per base products_id
   $this->base_pid = '';
//   EOF Price Break for SPPC mod, price break per base products_id

Line 104-105

**AFTER**
 function parse($prices) {
   $this->productsID = $prices['products_id'];

**ADD**
//   BOF Price Break for SPPC mod, price break per base products_id
   $this->base_pid = (int)$prices['products_id'];
//   EOF Price Break for SPPC mod, price break per base products_id

Line 258-260

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

**WITH**	
    function computePrice($qty, $no_of_other_items_in_cart_with_same_base_pid = 0)
 {
$qty = $this->adjustQty($qty);
$qty += $no_of_other_items_in_cart_with_same_base_pid;
  
Line 289-291
    **AFTER**
 function getQtyBlocks() {
   return $this->qtyBlocks;
 }
 
**ADD**
//   BOF Price Break for SPPC mod, price break per base products_id
 function get_base_pid() {
   return $this->base_pid;
 }
//   EOF Price Break for SPPC mod, price break per base products_id

Link to comment
Share on other sites

Greg,

 

This seems to work for your "special" case:

 

Jan....You are a god...thanks. The shopping cart is showing the correct pricing independent of the attributes...this is perfect...however..upon reaching the checkout confirmation screen, all the prices went to $0.00. Is there changes that need to be made in the order class..or did I just mess things up somewhere.

 

I'm actually running a loaded system (Linda McGrath's SEC) so some of the changes aren't completely straight forward, so sometimes I change a stock install and then compare that to my modded install. I'm gonna triple check things again just to be sure I've got all my i's dotted and t's crossed, but we're definitely going down the track I desparetly need!!!

 

Many, Many Thanks Again,

Greg ;)

I only do what my Rice Krispies tell me to do!

Link to comment
Share on other sites

The shopping cart is showing the correct pricing independent of the attributes...this is perfect...however..upon reaching the checkout confirmation screen, all the prices went to $0.00. Is there changes that need to be made in the order class..or did I just mess things up somewhere.

Actually, the order class gets its information from the shopping_cart class by calling the function get_products.php from that class. Check your version with the complete shopping_cart class below, especially get_products (starts around line 294).

<?php
/*
 $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $
 adapted for Separate Pricing Per Customer v4 and Price Break 1.11.3 2005/03/12
 adapted for price break per "base products_id" 2005/09/03

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 class shoppingCart {
   var $contents, $total, $weight, $cartID, $content_type;

   function shoppingCart() {
     $this->reset();
   }

   function restore_contents() {
     global $customer_id;

     if (!tep_session_is_registered('customer_id')) return false;

// insert current cart contents in database
     if (is_array($this->contents)) {
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
         $qty = $this->contents[$products_id]['qty'];
         $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
         if (!tep_db_num_rows($product_query)) {
           tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");
           if (isset($this->contents[$products_id]['attributes'])) {
             reset($this->contents[$products_id]['attributes']);
             while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
               tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
             }
           }
         } else {
           tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
         }
       }
     }

// reset per-session cart contents, but not the database contents
     $this->reset(false);

     $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
// BOF Price Break for SPPC mod, price break per base products_id
     while ($products = tep_db_fetch_array($products_query)) {
       $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity'], 'base_pid' => (int)$products['products_id']);
// EOF Price Break for SPPC mod, price break per base products_id
// attributes
       $attributes_query = tep_db_query("select products_options_id, products_options_value_id from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'");
       while ($attributes = tep_db_fetch_array($attributes_query)) {
         $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id'];
       }
     }

     $this->cleanup();
   }

   function reset($reset_database = false) {
     global $customer_id;

     $this->contents = array();
     $this->total = 0;
     $this->weight = 0;
     $this->content_type = false;

     if (tep_session_is_registered('customer_id') && ($reset_database == true)) {
       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'");
       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'");
     }

     unset($this->cartID);
     if (tep_session_is_registered('cartID')) tep_session_unregister('cartID');
   }

   function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) {
     // BOF Separate Pricing Per Customer, Price Break 1.11.3 modification
     global $new_products_id_in_cart, $customer_id, $languages_id;

     $pf = new PriceFormatter;
     $pf->loadProduct($products_id, $languages_id);
     $qty = $pf->adjustQty($qty);
     $base_pid = $pf->get_base_pid();
     
     // EOF Separate Pricing Per Customer, Price Break 1.11.3 modification
     $products_id = tep_get_uprid($products_id, $attributes);
     if ($notify == true) {
       $new_products_id_in_cart = $products_id;
       tep_session_register('new_products_id_in_cart');
     }

// BOF Price Break for SPPC mod, price break per base products_id
     if ($this->in_cart($products_id)) {
       $this->update_quantity($products_id, $qty, $attributes, $base_pid); //added base products_id
     } else {
       $this->contents[] = array($products_id);
       $this->contents[$products_id] = array('qty' => $qty, 'base_pid' => $base_pid); //added base products_id
// EOF Price Break for SPPC mod, price break per base products_id
// insert into database
       if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')");

       if (is_array($attributes)) {
         reset($attributes);
         while (list($option, $value) = each($attributes)) {
           $this->contents[$products_id]['attributes'][$option] = $value;
// insert into database
           if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "')");
         }
       }
     }
     $this->cleanup();

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
     $this->cartID = $this->generate_cart_id();
   }

// BOF Price Break for SPPC mod, price break per base products_id
   function update_quantity($products_id, $quantity = '', $attributes = '', $base_pid = '') { //added base products_id
     global $customer_id;

     if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true..

     $this->contents[$products_id] = array('qty' => $quantity, 'base_pid' => $base_pid); //added base products_id
// EOF Price Break for SPPC mod, price break per base products_id
// update database
     if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");

     if (is_array($attributes)) {
       reset($attributes);
       while (list($option, $value) = each($attributes)) {
         $this->contents[$products_id]['attributes'][$option] = $value;
// update database
         if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'");
       }
     }
   }

   function cleanup() {
     global $customer_id;

     reset($this->contents);
     while (list($key,) = each($this->contents)) {
       if ($this->contents[$key]['qty'] < 1) {
         unset($this->contents[$key]);
// remove from database
         if (tep_session_is_registered('customer_id')) {
           tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
           tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'");
         }
       }
     }
   }

   function count_contents() {  // get total number of items in cart 
     $total_items = 0;
     if (is_array($this->contents)) {
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
         $total_items += $this->get_quantity($products_id);
       }
     }

     return $total_items;
   }

   function get_quantity($products_id) {
     if (isset($this->contents[$products_id])) {
       return $this->contents[$products_id]['qty'];
     } else {
       return 0;
     }
   }

   function in_cart($products_id) {
     if (isset($this->contents[$products_id])) {
       return true;
     } else {
       return false;
     }
   }

   function remove($products_id) {
     global $customer_id;

     unset($this->contents[$products_id]);
// remove from database
     if (tep_session_is_registered('customer_id')) {
       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
       tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'");
     }

// assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure
     $this->cartID = $this->generate_cart_id();
   }

   function remove_all() {
     $this->reset();
   }

   function get_product_id_list() {
     $product_id_list = '';
     if (is_array($this->contents)) {
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
         $product_id_list .= ', ' . $products_id;
       }
     }

     return substr($product_id_list, 2);
   }

   function calculate() {
     $this->total = 0;
     $this->weight = 0;
     // BOF Price Break for SPPC mod, price break per base products_id
     global $languages_id;
     if (!is_array($this->contents)) return 0;
 $base_pid_quantity = array(); // calculates no of items per category in shopping basket
 // note that the function adjustQty has not been called yet (invoked by $pf->computePrice), 
 // so this may not be the correct number of items yet
     foreach ($this->contents as $products_id => $contents_array) {
      if (!isset($base_pid_quantity[$contents_array['base_pid']])) {
  $base_pid_quantity[$contents_array['base_pid']] = $contents_array['qty'];
      } else {
  $base_pid_quantity[$contents_array['base_pid']] += $contents_array['qty'];
      }
     } // end foreach

  $pf = new PriceFormatter;
//   EOF Price Break for SPPC mod, price break per base products_id

     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
       $qty = $this->contents[$products_id]['qty'];
$number_of_items_in_cart_same_base_pid = $base_pid_quantity[$this->contents[$products_id]['base_pid']];
$no_of_other_items_in_cart_with_same_base_pid = $number_of_items_in_cart_same_base_pid - $qty;

// products price
   //    $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");

   //    if ($product = tep_db_fetch_array($product_query)) {
       if ($product = $pf->loadProduct($products_id, $languages_id)){     
         $prid = $product['products_id'];
        $products_tax = tep_get_tax_rate($product['products_tax_class_id']);
 //        $products_price = $product['products_price'];
        $products_price = $pf->computePrice($qty, $no_of_other_items_in_cart_with_same_base_pid);
         $products_weight = $product['products_weight'];
// EOF Separate Pricing Per Customer, Price Break 1.11.3 mod
         $this->total += tep_add_tax($products_price, $products_tax) * $qty;
         $this->weight += ($qty * $products_weight);
       }

// attributes price
       if (isset($this->contents[$products_id]['attributes'])) {
         reset($this->contents[$products_id]['attributes']);
         while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
           $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
           $attribute_price = tep_db_fetch_array($attribute_price_query);
           if ($attribute_price['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
         }
       }
     }
   }

   function attributes_price($products_id) {
     $attributes_price = 0;

     if (isset($this->contents[$products_id]['attributes'])) {
       reset($this->contents[$products_id]['attributes']);
       while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
         $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
         $attribute_price = tep_db_fetch_array($attribute_price_query);
         if ($attribute_price['price_prefix'] == '+') {
           $attributes_price += $attribute_price['options_values_price'];
         } else {
           $attributes_price -= $attribute_price['options_values_price'];
         }
       }
     }

     return $attributes_price;
   }

   function get_products() {
    global $languages_id;
// BOF Separate Pricing Per Customer v4, Price Break 1.11.3 modification
     if (!is_array($this->contents)) return false;
//   BOF Price Break for SPPC mod, price break per base products_id    
     $base_pid_quantity = array();
     foreach ($this->contents as $products_id => $contents_array) {
      if (!isset($base_pid_quantity[$contents_array['base_pid']])) {
  $base_pid_quantity[$contents_array['base_pid']] = $contents_array['qty'];
      } else {
  $base_pid_quantity[$contents_array['base_pid']] += $contents_array['qty'];
      }
     } // end foreach
     
     $pf = new PriceFormatter;
//   EOF Price Break for SPPC mod, price break per base products_id
     
     $products_array = array();
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
/*        $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
       if ($products = tep_db_fetch_array($products_query)) {
         $prid = $products['products_id'];
         $products_price = $products['products_price'];

         $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");
         if (tep_db_num_rows($specials_query)) {
           $specials = tep_db_fetch_array($specials_query);
           $products_price = $specials['specials_new_products_price'];
         } */

  if ($products = $pf->loadProduct($products_id, $languages_id)) {
   $qty = $this->contents[$products_id]['qty'];
$number_of_items_in_cart_same_base_pid = $base_pid_quantity[$this->contents[$products_id]['base_pid']];
$no_of_other_items_in_cart_with_same_base_pid = $number_of_items_in_cart_same_base_pid - $qty;

        $products_price = $pf->computePrice($this->contents[$products_id]['qty'], $no_of_other_items_in_cart_with_same_base_pid);
// EOF Separate Pricing Per Customer v4, Price Break 1.11.3 modification   
         $products_array[] = array('id' => $products_id,
                                   'name' => $products['products_name'],
                                   'model' => $products['products_model'],
                                   'image' => $products['products_image'],
//   BOF Price Break for SPPC mod, price break per base products_id
       'base_pid' => $this->contents[$products_id]['base_pid'],
//   EOF Price Break for SPPC mod, price break per base products_id
                                   'price' => $products_price,
                                   'quantity' => $this->contents[$products_id]['qty'],
                                   'weight' => $products['products_weight'],
                                   'final_price' => ($products_price + $this->attributes_price($products_id)),
                                   'tax_class_id' => $products['products_tax_class_id'],
                                   'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
       }
     }

     return $products_array;
   }

   function show_total() {
     $this->calculate();

     return $this->total;
   }

   function show_weight() {
     $this->calculate();

     return $this->weight;
   }

   function generate_cart_id($length = 5) {
     return tep_create_random_value($length, 'digits');
   }

   function get_content_type() {
     $this->content_type = false;

     if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) {
       reset($this->contents);
       while (list($products_id, ) = each($this->contents)) {
         if (isset($this->contents[$products_id]['attributes'])) {
           reset($this->contents[$products_id]['attributes']);
           while (list(, $value) = each($this->contents[$products_id]['attributes'])) {
             $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id");
             $virtual_check = tep_db_fetch_array($virtual_check_query);

             if ($virtual_check['total'] > 0) {
               switch ($this->content_type) {
                 case 'physical':
                   $this->content_type = 'mixed';

                   return $this->content_type;
                   break;
                 default:
                   $this->content_type = 'virtual';
                   break;
               }
             } else {
               switch ($this->content_type) {
                 case 'virtual':
                   $this->content_type = 'mixed';

                   return $this->content_type;
                   break;
                 default:
                   $this->content_type = 'physical';
                   break;
               }
             }
           }
         } else {
           switch ($this->content_type) {
             case 'virtual':
               $this->content_type = 'mixed';

               return $this->content_type;
               break;
             default:
               $this->content_type = 'physical';
               break;
           }
         }
       }
     } else {
       $this->content_type = 'physical';
     }

     return $this->content_type;
   }

   function unserialize($broken) {
     for(reset($broken);$kv=each($broken);) {
       $key=$kv['key'];
       if (gettype($this->$key)!="user function")
       $this->$key=$kv['value'];
     }
   }

 }
?>

Link to comment
Share on other sites

Hello,

 

I installed this nice mod and i have a problem with the bestseller contrib. The problem is the sppc contrib work in Bestsellers box.

I need help with to include the sppc in the besstellers box.

 

http://www.oscommerce.com/community/contri...eller+Box+image

 

<?php
/*
 $Id: best_sellers.php,v 1.19 2002/06/05 20:59:08 dgw_ Exp $

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

 Copyright (c) 2001 osCommerce

 Released under the GNU General Public License

 Bestsellers Images v.1

 Edit by V. Meurink - [email protected]
*/
?>
<!-- best_sellers //-->
<?php
 if ($cPath) {
   $best_sellers_query = tep_db_query("select distinct p.products_id, p.products_image, pd.products_name, p.products_ordered 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 = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and (c.categories_id = '" . $current_category_id . "' OR c.parent_id = '" . $current_category_id . "') order by p.products_ordered DESC, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
 } else {
   $best_sellers_query = tep_db_query("select p.products_id, p.products_image, pd.products_name, p.products_ordered 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 = '" . $languages_id . "' order by p.products_ordered DESC, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
 }

 if (tep_db_num_rows($best_sellers_query) >= MIN_DISPLAY_BESTSELLERS) {
?>
         <tr>
           <td>
<?php
   $info_box_contents = array();
   $info_box_contents[] = array('align' => 'left',
                                'text'  => BOX_HEADING_BESTSELLERS
                               );
   new infoBoxHeading($info_box_contents, false, false);

   $rows = 0;
   $info_box_contents = array();
   while ($best_sellers = tep_db_fetch_array($best_sellers_query)) {
     $rows++;
     $info_box_contents[] = array('align' => 'center',
                                  'text'  => '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers["products_id"], 'NONSSL') . '">' . tep_image(DIR_WS_IMAGES . $best_sellers['products_image'], $best_sellers['products_name'], BESTSELLER_IMAGE_WIDTH, BESTSELLER_IMAGE_HEIGHT) . '</a></td><td>' . tep_row_number_format($rows) .  '. <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id'], 'NONSSL') . '">' . $best_sellers['products_name'] . '</a>');
   }

   new infoBox($info_box_contents);
?>
           </td>
         </tr>
<?php
 }
?>
<!-- best_sellers_eof //-->

Link to comment
Share on other sites

Debbie,

 

It looks like you haven't defined the EMAIL_SUBJECT and EMAIL_WELCOME3 in the correct file (a file that will be included when this page is loaded). You should do a define of those in admin/includes/languages/english/customers.php

You used the correct syntax, but too late in the code to be included in the tep_db_perform above.

 

If you rearrange things a bit, it should work.

$old_customers_group_id = $_POST['old_customers_group_id'];
if ($old_customers_group_id <= 2 && $customers_group_id >= 3) {
     $sql_data_array['customers_group_ra'] = '0'; //trying to turn off RA light
} end if ($old_customers_group_id <= 2 && $customers_group_id >= 3)

       tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");

if ($old_customers_group_id <= 2 && $customers_group_id >= 3) {
$name = $customers_firstname . $customers_lastname;
// perhaps email_text should start with greeting: Dear mr./mrs " . $customers_lastname . ",\n\n
$email_text = EMAIL_WELCOME3;
tep_mail($name, $customers_email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
} // end if ($old_customers_group_id <= 2 && $customers_group_id >= 3)

 

Jan I found small typo in this..

 

$old_customers_group_id = $_POST['old_customers_group_id'];
if ($old_customers_group_id <= 2 && $customers_group_id >= 3) {
     $sql_data_array['customers_group_ra'] = '0'; //trying to turn off RA light
} end if ($old_customers_group_id <= 2 && $customers_group_id >= 3)

should have // in front of "end if ($old_customer..." making it look like:

 

$old_customers_group_id = $_POST['old_customers_group_id'];
if ($old_customers_group_id <= 2 && $customers_group_id >= 3) {
     $sql_data_array['customers_group_ra'] = '0'; //trying to turn off RA light
} // end if ($old_customers_group_id <= 2 && $customers_group_id >= 3)

 

Without that fix I could not see the customer list..

 

Now that I fixed that I went in to approve a wholesale customer and have another issue.

I went into edit this new wholesale customer. I turned off the alert and set to wholesale then clicked update and got:

1054 - Unknown column 'customers_group_ra' in 'field list'

 

update address_book set entry_firstname = 'dist2', entry_lastname = 'doerr', entry_street_address = '1843 avenue', entry_postcode = '11000', entry_city = 'new york', entry_country_id = '223', entry_company = 'dist2', entry_company_tax_id = '3', entry_suburb = '', entry_zone_id = '43', entry_state = '', customers_group_ra = '0' where customers_id = '20' and address_book_id = '20'

[TEP STOP]

 

The alert did turn off.. the wholesale price is shown in the cart after this error was received and the customer info was updated when I went back in the admin to look. The welcome email was received before the wholesale person was activated The "you have been activated" mail was NOT sent.

 

I'm not sure where to look to fix this one I think it is this last fix you gave me to send the wholesale people a "you have been activated" mail

http://www.oscommerce.com/forums/index.php?sho...=53436&st=1260#

quoted above

 

FYI I purchasesd a template for the site now and started from scratch reintegrating SPPC 1/2 by hand 1/2 automatically.. the files that SPPC had no connection to the template I just sent over, the ones they had in common I hand edited

 

I'm sooo close now :)

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

Debbie,

I'm not sure where to look to fix this one I think it is this last fix you gave me to send the wholesale people a "you have been activated" mail

I see what goes wrong here: that particular field is indeed not found in the table address book, but is only found in the table customers. It needs a separate database update e.g. like this:

$old_customers_group_id = $_POST['old_customers_group_id'];
if ($old_customers_group_id <= 2 && $customers_group_id >= 3) {
    $sql_data_array_cg_ra = array('customers_group_ra' => '0'); //trying to turn off RA light
           tep_db_perform(TABLE_CUSTOMERS, $sql_data_array_cg_ra, 'update', "customers_id = '" . (int)$customers_id . "'");
} // end if ($old_customers_group_id <= 2 && $customers_group_id >= 3)

      tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");

Link to comment
Share on other sites

Sorry, i have this contribution extended/modified.

 

This is my bestsellers file:

 

<?php
/*
 $Id: best_sellers.php,v 1.19 2002/06/05 20:59:08 dgw_ Exp $
 osCommerce, Open Source E-Commerce Solutions
 [url=http://www.oscommerce.com]http://www.oscommerce.com[/url]
 Copyright ? 2001 osCommerce
 Released under the GNU General Public License
*/
?>
<?php /* <!-- best_sellers //--> */ ?>
<?php
 if ($cPath) {
 $best_sellers_query = tep_db_query("select distinct p.products_id, p.products_image, pd.products_name, p.products_price, p.products_tax_class_id, p.products_ordered 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 = '" . $languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and (c.categories_id = '" . $current_category_id . "' OR c.parent_id = '" . $current_category_id . "') order by p.products_ordered DESC, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
 } else {
 $best_sellers_query = tep_db_query("select p.products_id, p.products_image, pd.products_name, p.products_price, p.products_tax_class_id, p.products_ordered 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 = '" . $languages_id . "' order by p.products_ordered DESC, pd.products_name limit " . MAX_DISPLAY_BESTSELLERS);
 }
 if (tep_db_num_rows($best_sellers_query) >= MIN_DISPLAY_BESTSELLERS) {
?>
<tr>
<td>
<?php
 $info_box_contents = array();
 $info_box_contents[] = array('text' => BOX_HEADING_BESTSELLERS);
 new infoBoxHeadingBoxen($info_box_contents, false, true);
 $rows = 0;
 $bestsellers_list = '<table border="0" width="100%" cellspacing="0" cellpadding="1">';
 while ($best_sellers = tep_db_fetch_array($best_sellers_query)) {
 $rows++;
 $bestsellers_list .= '<tr><td class="infoBoxContents" valign="top">' . tep_row_number_format($rows) . '.</td><td class="infoBoxContents"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $best_sellers['products_id']) . '">' . $best_sellers['products_name'] . '</a><b><br>' . $currencies->display_price($best_sellers['products_price'], tep_get_tax_rate($best_sellers['products_tax_class_id'] . '</b></td></tr>'));
 }
 $bestsellers_list .= '</table>';
 $info_box_contents = array();
 $info_box_contents[] = array('text' => $bestsellers_list);
 new infoBox($info_box_contents);
?>
</td>
</tr>
<?php } ?>
<?php /* <!-- best_sellers_eof //--> */ ?>

Edited by Fallout
Link to comment
Share on other sites

Debbie,

I see what goes wrong here: that particular field is indeed not found in the table address book, but is only found in the table customers. It needs a separate database update e.g. like this:

$old_customers_group_id = $_POST['old_customers_group_id'];
if ($old_customers_group_id <= 2 && $customers_group_id >= 3) {
? ? $sql_data_array_cg_ra = array('customers_group_ra' => '0'); //trying to turn off RA light
? ? ? ? ? ?tep_db_perform(TABLE_CUSTOMERS, $sql_data_array_cg_ra, 'update', "customers_id = '" . (int)$customers_id . "'");
} // end if ($old_customers_group_id <= 2 && $customers_group_id >= 3)

? ? ? tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array, 'update', "customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$default_address_id . "'");

 

 

Jan thanks that did the trick.. I;m not getting the mail sent to the wholesale people when I approve them.. was that not going to happen??? Can it happen??

 

Another thing I have a urgent question about..

 

I have over 2000 products, most of them can be sold ONLY to professionals, some to both professionals and consumers (maybe 25% to both.. of course at their own pricing)

 

Obviously retail is the 1st group, professional pricing at group 2 & 3 then wholesale is the 4th

 

When I set the pricing at:

retail prof1 prof2 wholesale

0 3.99 3.99 1.99

 

the proper pricing comes up for all but I can't allow the consumer to purchase the items they should not get their hands on (chemicals in my case for nail and hair professionals) When I do not log in and go to the products with zero or blank for retail pricing it shows the product but with a $0.00 cost!! That of course is not a good situation :)

 

Do I need to segregate these items in a partiular group(s) and use Hide Products from customer groups for SPPC

 

thanks

Debbie D
Franklin County, VA "Moonshine Capitol of the World"
osCmax Mobile Template oscmaxtemplates.com

Link to comment
Share on other sites

Actually, the order class gets its information from the shopping_cart class by calling the function get_products.php from that class. Check your version with the complete shopping_cart class below, especially get_products (starts around line 294).

 

Well Jan...I've looked at this code for a couple of days now and just can't find the error. This class of mine is just soooo heavily modded that I can't seem to pinpoint the difficulty. <_<

 

If you wouldn't mind taking a look at it I would be very grateful. I'd be more than happy to pay you for your services...just pm me and I'll send ya the file

 

Thanks,

Greg

I only do what my Rice Krispies tell me to do!

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.
Note: Your post will require moderator approval before it will be visible.

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