Guest Posted December 14, 2005 Share Posted December 14, 2005 Yes, they work 100% with one another. Hi, I installed the easy-populate contribution. I am in process of editing the downloaded complete product file for my first product line upload. Since I also install the SPPC 4.1.1( and it works fine), how can I add price columns for those "wholesale" and "Volume Account" groups I created in the downloaded tab-limited file? Thanks Spencer Quote Link to comment Share on other sites More sharing options...
John-Peter Posted December 15, 2005 Share Posted December 15, 2005 (edited) Hi, I installed the easy-populate contribution. I am in process of editing the downloaded complete product file for my first product line upload. Since I also install the SPPC 4.1.1( and it works fine), how can I add price columns for those "wholesale" and "Volume Account" groups I created in the downloaded tab-limited file? Thanks Spencer Spencer, You have to modify EasyPopulate for working with the group price you have, here what you have to do, just folows the instructions and you gonna have fun with EasyPopulate : Open admin/easypopulate.php and search the following lines : // uncomment the customer_price and customer_group to support multi-price per product contrib $filelayout = array( 'v_products_model' => $iii++, 'v_products_price' => $iii++, 'v_products_quantity' => $iii++, 'v_customer_price_1' => $iii++, 'v_customer_group_id_1' => $iii++, 'v_customer_price_2' => $iii++, 'v_customer_group_id_2' => $iii++, 'v_customer_price_3' => $iii++, 'v_customer_group_id_3' => $iii++, 'v_customer_price_4' => $iii++, 'v_customer_group_id_4' => $iii++, These line will be commented out. For each customer group you have, uncomment one of the lines... If you have normal prices, and two another price like me, uncomment group id #1 and #2 and #3. After that, a little lower, you can find the text file about sql data. It looks like this : // and insert the new record if ($v_customer_price_1 != ''){ $result = tep_db_query(' INSERT INTO '.TABLE_PRODUCTS_GROUPS.' VALUES ( ' . $v_customer_group_id_1 . ', ' . $v_customer_price_1 . ', ' . $v_products_id . ', ' . $v_products_price .' )' ); } if ($v_customer_price_2 != ''){ $result = tep_db_query(' INSERT INTO '.TABLE_PRODUCTS_GROUPS.' VALUES ( ' . $v_customer_group_id_2 . ', ' . $v_customer_price_2 . ', ' . $v_products_id . ', ' . $v_products_price . ' )' ); } if ($v_customer_price_3 != ''){ $result = tep_db_query(' INSERT INTO '.TABLE_PRODUCTS_GROUPS.' VALUES ( ' . $v_customer_group_id_3 . ', ' . $v_customer_price_3 . ', ' . $v_products_id . ', ' . $v_products_price . ' )' ); } if ($v_customer_price_4 != ''){ $result = tep_db_query(' INSERT INTO '.TABLE_PRODUCTS_GROUPS.' VALUES ( ' . $v_customer_group_id_4 . ', ' . $v_customer_price_4 . ', ' . $v_products_id . ', ' . $v_products_price . ' )' ); } } The line ' . $v_products_price . ' is not needed. Erase that whole line. I don't know why commenting the line won't work...but it won't. Anyway, the line above the one you just erased has a comma at the end of it. Erase the comma so that sql knows to start another line. That's it and it work like a charm. Just upload your excel file in admin panel via Easy Populate. Asta la vista !!!! :thumbsup: Edited December 15, 2005 by Jeep_ice Quote John -------------------- osCommerce 2.3.4 Bootstrap Edge Link to comment Share on other sites More sharing options...
Guest Posted December 15, 2005 Share Posted December 15, 2005 Spencer, You have to modify EasyPopulate for working with the group price you have, here what you have to do, just folows the instructions and you gonna have fun with EasyPopulate : Open admin/easypopulate.php and search the following lines : // uncomment the customer_price and customer_group to support multi-price per product contrib $filelayout = array( 'v_products_model' => $iii++, 'v_products_price' => $iii++, 'v_products_quantity' => $iii++, 'v_customer_price_1' => $iii++, 'v_customer_group_id_1' => $iii++, 'v_customer_price_2' => $iii++, 'v_customer_group_id_2' => $iii++, 'v_customer_price_3' => $iii++, 'v_customer_group_id_3' => $iii++, 'v_customer_price_4' => $iii++, 'v_customer_group_id_4' => $iii++, These line will be commented out. For each customer group you have, uncomment one of the lines... If you have normal prices, and two another price like me, uncomment group id #1 and #2 and #3. After that, a little lower, you can find the text file about sql data. It looks like this : // and insert the new record if ($v_customer_price_1 != ''){ $result = tep_db_query(' INSERT INTO '.TABLE_PRODUCTS_GROUPS.' VALUES ( ' . $v_customer_group_id_1 . ', ' . $v_customer_price_1 . ', ' . $v_products_id . ', ' . $v_products_price .' )' ); } if ($v_customer_price_2 != ''){ $result = tep_db_query(' INSERT INTO '.TABLE_PRODUCTS_GROUPS.' VALUES ( ' . $v_customer_group_id_2 . ', ' . $v_customer_price_2 . ', ' . $v_products_id . ', ' . $v_products_price . ' )' ); } if ($v_customer_price_3 != ''){ $result = tep_db_query(' INSERT INTO '.TABLE_PRODUCTS_GROUPS.' VALUES ( ' . $v_customer_group_id_3 . ', ' . $v_customer_price_3 . ', ' . $v_products_id . ', ' . $v_products_price . ' )' ); } if ($v_customer_price_4 != ''){ $result = tep_db_query(' INSERT INTO '.TABLE_PRODUCTS_GROUPS.' VALUES ( ' . $v_customer_group_id_4 . ', ' . $v_customer_price_4 . ', ' . $v_products_id . ', ' . $v_products_price . ' )' ); } } The line ' . $v_products_price . ' is not needed. Erase that whole line. I don't know why commenting the line won't work...but it won't. Anyway, the line above the one you just erased has a comma at the end of it. Erase the comma so that sql knows to start another line. That's it and it work like a charm. Just upload your excel file in admin panel via Easy Populate. Asta la vista !!!! :thumbsup: Hi, Jeep: Thanks for the tips. I got that resolved as you instruct last night by reading other threads. It works. My next challange is to have tier prices for each groups(wholesale and volume account). Any ideas ? Thanks again. Spencer Quote Link to comment Share on other sites More sharing options...
John-Peter Posted December 15, 2005 Share Posted December 15, 2005 Hi, Jeep: Thanks for the tips. I got that resolved as you instruct last night by reading other threads. It works. My next challange is to have tier prices for each groups(wholesale and volume account). Any ideas ? Thanks again. Spencer What do you mean ??? Quote John -------------------- osCommerce 2.3.4 Bootstrap Edge Link to comment Share on other sites More sharing options...
Guest Posted December 15, 2005 Share Posted December 15, 2005 What do you mean ??? Hi, Jeep: Here is details: The version of easypopulate.php I use is $Id: easypopulate.php,v 2.75 2005/04/05 AL In the program, I can't find those codes you quoted( you must use early version). // uncomment the customer_price and customer_group to support multi-price per product contrib$filelayout = array( 'v_products_model' => $iii++, 'v_products_price' => $iii++, 'v_products_quantity' => $iii++, 'v_customer_price_1' => $iii++, 'v_customer_group_id_1' => $iii++, 'v_customer_price_2' => $iii++, 'v_customer_group_id_2' => $iii++, 'v_customer_price_3' => $iii++, 'v_customer_group_id_3' => $iii++, 'v_customer_price_4' => $iii++, 'v_customer_group_id_4' => $iii++, What I have here after adding 4 lines for customer_group and customer_price. // uncomment the customer_price and customer_group to support multi-price per product contrib // VJ product attribs begin $header_array = array( 'v_products_price' => $iii++, 'v_customer_price_1' => $iii++, 'v_customer_group_id_1' => $iii++, 'v_customer_price_2' => $iii++, 'v_customer_group_id_2' => $iii++, 'v_products_weight' => $iii++, 'v_date_avail' => $iii++, 'v_date_added' => $iii++, 'v_products_quantity' => $iii++, ); And I read a thread about deleteing those v_product_price lines to avoid error meaasge after uploading. Exactly like you states. Then everything went smoothly. Do you know any solutions for setting up some kind of tier-price (like q'ty=1 $12.00 Q'ty=5+ $10.00 etc.) for the wholesale group and volume account group respectively. One other question: Do you know which php this statement located? It shows at the bottom of individual product page. I like to get ride of it. " This product was added to our catalog on Thursday 08 December, 2005. " TIA Spencer Quote Link to comment Share on other sites More sharing options...
John-Peter Posted December 15, 2005 Share Posted December 15, 2005 Hi, Jeep: Here is details: The version of easypopulate.php I use is $Id: easypopulate.php,v 2.75 2005/04/05 AL In the program, I can't find those codes you quoted( you must use early version). What I have here after adding 4 lines for customer_group and customer_price. And I read a thread about deleteing those v_product_price lines to avoid error meaasge after uploading. Exactly like you states. Then everything went smoothly. Do you know any solutions for setting up some kind of tier-price (like q'ty=1 $12.00 Q'ty=5+ $10.00 etc.) for the wholesale group and volume account group respectively. One other question: Do you know which php this statement located? It shows at the bottom of individual product page. I like to get ride of it. " This product was added to our catalog on Thursday 08 December, 2005. " TIA Spencer Ok, I understand now, I use version 2.74-MS2 of EasyPopulate. For adding quantity break, I don't know how to do it with EasyPopulate, I would like it if somebody know. I add it in the panel admin because I don't have a big number of product but if somebody have a lot of product in quantity break, it's gonna be a pain. To work with EasyPopulate, we have to modify again the file and add the info. Too complicated for me. Sorry to not help you for this, I'm in the same boat of you. :( Quote John -------------------- osCommerce 2.3.4 Bootstrap Edge Link to comment Share on other sites More sharing options...
OGN Posted December 16, 2005 Share Posted December 16, 2005 Hello Gentlemen... This is my first post , and i will admit up front I am all at sea with PHP but am learning fast :).. I have just installed the new SPPC version into a near clean-skin shop (had only added a few boxes) and all went relitively smoothly, I have 2 slight issues which is the reason for this call for help.. a) I can make groups in the admin panel , no problems at all , however I cannot find an area to enter any additional discount to this group.. and B) the display of product attributes is tottaly haywire... and badly segmented on the screen... now a question first off, I am assuming the if I make 3 groups, Retail, Disc1 Disc2 that i may or should be able to set various levels of discount, for example retail is full RRP, Disc1 is RRP less x amount and Disc2 group is RRP less xx amount, I am hopeing that the ammount is in percentage... ergo 0$ retail , Disc1 5% retail and lastly disc2 get %10... Is this indeed the manner in which this module works??, we have in excess of 9500 stock items, so indivually pricing is not an option.. I have again found where to create groups but not where to set attributes for that group(s) could anyone please enlighten me.. Thanks kindly.. Mike http://osshop.ogn.com.au Quote Link to comment Share on other sites More sharing options...
curt Posted December 16, 2005 Share Posted December 16, 2005 Jan and Marvin ---- thank you.... Everything works great. I have SPPC (716), SPPC price break w/ mod for catagories (3039), more category boxes (3327), category descriptions (1373), big images (614), header tags controller (207), all products (1501) and will probably add a few more. I have over two dozen store fronts that are being redeveloped with oscommerce from another cart solution and this has saved me weeks and weeks of time, not to mention I didn't even need much asprin. To anyone other than Jan and Marvin installing this mod, save yourself some time and trouble and install this one first, preferably with a default MS2 install and copy (or rar) the files in. Thanks Again. <Curt Larson Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted December 17, 2005 Share Posted December 17, 2005 Mike, a) I can make groups in the admin panel , no problems at all , however I cannot find an area to enter any additional discount to this group.. now a question first off, I am assuming the if I make 3 groups, Retail, Disc1 Disc2 that i may or should be able to set various levels of discount, for example retail is full RRP, Disc1 is RRP less x amount and Disc2 group is RRP less xx amount, I am hopeing that the ammount is in percentage... ergo 0$ retail , Disc1 5% retail and lastly disc2 get %10... SPPC doesn't work with fixed percentages. Instead the prices are entered per product. However, there are things to automate. For example if you already have all your retail prices you can do an sql-statement to calculate and insert all new prices for the groups (four positions after the dot/comma). See for example this post on page 85 (#1681). This post also references Javascript you could add to admin/categories to do the calculation for you when you have fixed percentages and enter the retail price. Of course using the EasyPopulate contribution makes it possible to use Excel and then export and upload the whole price structure. Personally, I'm totally unfamiliar with it so I can't give any help with that. B) the display of product attributes is tottaly haywire... and badly segmented on the screen... This is a page not touched by SPPC. Attributes are a difficult part of osC. If we have the same page in mind, yes that page is ... interesting. Actually, for product attributes the code for the catalog side is already in this thread, but the code for the admin part is not written yet (where to fit? Pop-up window from a button?). So you could use it, but you would have to add the products_attributes_id, customers_group_id, options_values_price, and products_id with phpMyAdmin in the table needed for that. Quote Link to comment Share on other sites More sharing options...
OGN Posted December 17, 2005 Share Posted December 17, 2005 Thank you most graciously JanZ I am absolutly useless with PHP, I have however spent many years programming in basic.. please dont laugh too hard!!, this however has given me a ver good grasp of multi-dimensional arrays and tables, which the new guys now call Mysql LOL. I belive that although SPPC dosent allow for this, it is so close, so very close to being able to have this feature it may be able to be included easily. SPPC already does all the hard work of tracking which group a user/member/customer belongs in, and also has the code to add or remove customers from group to group that it would surely be a simple task to add this in? My humble thought is if 3 seperate DB fields were added each one a percentage of the RRP cost there would only be the need for a line of code that says if your this group, use this price column. As SPPC aready does this to a degree, it may be worth the addition, then not ONLY will do a one on one specific setting but groups aswell. Our shop which opens tommorow has 9337 stock items, and if we had 3000 people shop there the individual setting would be impossible to cover in man hours, However, for the select customer SPPC could still do the one on one specials.. Creating 2 extra SQL fields and doing the price changes would be simple (new price= rrp*.90) , but I would have no idea were in OSC the price display lines were, to direct to the correct DB price column. Do you think this would be a feasable addition? Mike Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted December 17, 2005 Share Posted December 17, 2005 I am absolutly useless with PHP, I have however spent many years programming in basic.. please dont laugh too hard!!, this however has given me a ver good grasp of multi-dimensional arrays and tables, which the new guys now call Mysql LOL. PHP to me is what (little) I have seen of Basic in the 70's. Easy to learn, just more powerful. Read a book on PHP and you should be on your way to coding yourself in hours.Our shop which opens tommorow has 9337 stock items, and if we had 3000 people shop there the individual setting would be impossible to cover in man hours, However, for the select customer SPPC could still do the one on one specials.. What is wrong with: insert into products_groups select '1' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p; insert into products_groups select '2' as customers_group_id, (0.9 * p.products_price) as customers_group_price, p.products_id from products p; Your shop could open in minutes ;) Creating 2 extra SQL fields and doing the price changes would be simple (new price= rrp*.90) , but I would have no idea were in OSC the price display lines were, to direct to the correct DB price column. Do you think this would be a feasable addition? No, I don't think so. I guess it could be made, but you have to go through a lot of files to code for this. At this moment, the code falls back on the retail price if there is none for the groups price. As an aside, I think you would only need one new field, in customers_groups. Quote Link to comment Share on other sites More sharing options...
Guest Posted December 17, 2005 Share Posted December 17, 2005 I am very frustrated, I installed Version 4.0 and then 4.1 upgrade, and now whenever I use the "buy it now" button from my product listing page, NOTHING shows up in the cart. Does anyone know why this is happening? Here is my product_listing page, if someone could help me I would appreciate it! <?php /* $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id'); if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (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 } if (PRODUCT_LISTING_DISPLAY_STYLE == 'list') { $list_box_contents = array(); for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $lc_text = TABLE_HEADING_MODEL; $lc_width = '100'; break; case 'PRODUCT_LIST_NAME': $lc_text = TABLE_HEADING_PRODUCTS; $lc_width = '200'; break; case 'PRODUCT_LIST_INFO': $lc_text = TABLE_HEADING_INFO; $lc_width = '200'; break; case 'PRODUCT_LIST_MANUFACTURER': $lc_text = TABLE_HEADING_MANUFACTURER; break; case 'PRODUCT_LIST_PRICE': $lc_text = TABLE_HEADING_PRICE; $lc_align = 'right'; $lc_width = '100'; break; case 'PRODUCT_LIST_QUANTITY': $lc_text = TABLE_HEADING_QUANTITY; $lc_align = 'right'; $lc_width = '100'; break; case 'PRODUCT_LIST_INFO': $lc_text = 'More Info'; $lc_align = 'center'; break; case 'PRODUCT_LIST_WEIGHT': $lc_text = TABLE_HEADING_WEIGHT; $lc_align = 'right'; $lc_width = '100'; break; case 'PRODUCT_LIST_BUY_NOW': $lc_text = TABLE_HEADING_BUY_NOW; $lc_align = 'center'; $lc_width = '100'; break; case 'PRODUCT_LIST_IMAGE': $lc_text = TABLE_HEADING_IMAGE; $lc_align = 'center'; $lc_width = '100'; break; } //sort order if ($column_list[$col] == 'PRODUCT_LIST_SORT_ORDER'){break;} if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') && ($column_list[$col] != 'PRODUCT_LIST_MULTIPLE')) { // if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) { //end sort order $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text); } $list_box_contents[0][] = array('align' => $lc_align, 'width' => $lc_width, '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 $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; } while ($_listing = tep_db_fetch_array($listing_query)) { $listing[] = $_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]."' "; } } // 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 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']); } 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']; } } } // 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++) { //sort order if ($column_list[$col] == 'PRODUCT_LIST_SORT_ORDER'){break;} //end sort order switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $lc_text = ' ' . $listing[$x]['products_model'] . ' '; break; case 'PRODUCT_LIST_NAME': 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 = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a> '; } break; case 'PRODUCT_LIST_INFO': $lc_text = $listing['products_info'] . ' '; break; case 'PRODUCT_LIST_MANUFACTURER': $lc_text = ' <a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a> '; break; case 'PRODUCT_LIST_PRICE': $lc_align = 'right'; 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'])) . ' '; } break; case 'PRODUCT_LIST_QUANTITY': $lc_align = 'right'; $lc_text = ' ' . $listing[$x]['products_quantity'] . ' '; break; case 'PRODUCT_LIST_INFO': break; case 'PRODUCT_LIST_WEIGHT': $lc_align = 'right'; $lc_text = ' ' . $listing[$x]['products_weight'] . ' '; break; case 'PRODUCT_LIST_BUY_NOW': $lc_align = 'center'; $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a> '; break; } case 'PRODUCT_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,' class="shadow1" ') . '</a> ' . '<br>'.' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . 'Click for More Info' . '</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,' class="shadow1" ') . '</a> ' . '<br>'.' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . '<font color="#006600">Click for More Info</font>' . '</a> '; } break; } $list_box_contents[$cur_row][] = array('align' => $lc_align, '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); } } elseif (PRODUCT_LISTING_DISPLAY_STYLE == 'columns') { $info_box_contents = array(); if ($listing_split->number_of_rows > 0) { $row = 0; $col = 0; $listing_query = tep_db_query($listing_split->sql_query); while ($listing = tep_db_fetch_array($listing_query)) { $listing['products_name'] = tep_get_products_name($listing['products_id']); if (PRODUCT_LIST_IMAGE > 0) { $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a><br>'; } if (PRODUCT_LIST_NAME > 0) { $lc_text .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a><br>'; } if (PRODUCT_LIST_MODEL > 0) { $lc_text .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing['products_id']) . '">' . $listing['products_model'] . '</a><br>'; } if (PRODUCT_LIST_MANUFACTURER > 0) { $lc_text .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing['manufacturers_id']) . '">' . $listing['manufacturers_name'] . '</a><br>'; } if (PRODUCT_LIST_PRICE > 0) { if (tep_not_null($listing['specials_new_products_price'])) { $lc_text .= '<s>' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . '</span>'; } else { $lc_text .= ' ' . $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id'])) . ' '; } } if (PRODUCT_LIST_BUY_NOW) { $lc_text .= '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing_values['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing_values['products_name'] . TEXT_NOW) . '</a>'; } $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"', 'text' => $lc_text); $col ++; if ($col > PRODUCT_LIST_COL_NUM-1) { $col = 0; $row ++; } } new contentBox($info_box_contents); } else { $info_box_contents = array(); $info_box_contents[0] = array('params' => 'class="productListing-odd"'); $info_box_contents[0][] = array('params' => 'class="productListing-data"', 'text' => TEXT_NO_PRODUCTS); new contentBox($info_box_contents); } } if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (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 } ?> Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted December 17, 2005 Share Posted December 17, 2005 I am very frustrated, I installed Version 4.0 and then 4.1 upgrade, and now whenever I use the "buy it now" button from my product listing page, NOTHING shows up in the cart. Does anyone know why this is happening? Mistakes, more than a few. Probably you had an [$x] missing with a listing['products'id] but there was a lot more wrong (see comments). <?php /* $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright ? 2003 osCommerce Released under the GNU General Public License */ // define('PRODUCT_LISTING_DISPLAY_STYLE', 'columns'); // define('PRODUCT_LIST_COL_NUM', '3'); $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id'); if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (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 } if (PRODUCT_LISTING_DISPLAY_STYLE == 'list') { $list_box_contents = array(); for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $lc_text = TABLE_HEADING_MODEL; $lc_width = '100'; break; case 'PRODUCT_LIST_NAME': $lc_text = TABLE_HEADING_PRODUCTS; $lc_width = '200'; break; case 'PRODUCT_LIST_INFO': $lc_text = TABLE_HEADING_INFO; $lc_width = '200'; break; case 'PRODUCT_LIST_MANUFACTURER': $lc_text = TABLE_HEADING_MANUFACTURER; break; case 'PRODUCT_LIST_PRICE': $lc_text = TABLE_HEADING_PRICE; $lc_align = 'right'; $lc_width = '100'; break; case 'PRODUCT_LIST_QUANTITY': $lc_text = TABLE_HEADING_QUANTITY; $lc_align = 'right'; $lc_width = '100'; break; case 'PRODUCT_LIST_INFO': $lc_text = 'More Info'; $lc_align = 'center'; break; case 'PRODUCT_LIST_WEIGHT': $lc_text = TABLE_HEADING_WEIGHT; $lc_align = 'right'; $lc_width = '100'; break; case 'PRODUCT_LIST_BUY_NOW': $lc_text = TABLE_HEADING_BUY_NOW; $lc_align = 'center'; $lc_width = '100'; break; case 'PRODUCT_LIST_IMAGE': $lc_text = TABLE_HEADING_IMAGE; $lc_align = 'center'; $lc_width = '100'; break; } //sort order if ($column_list[$col] == 'PRODUCT_LIST_SORT_ORDER'){ break; } if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') && ($column_list[$col] != 'PRODUCT_LIST_MULTIPLE')) { // if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) { //end sort order $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text); } $list_box_contents[0][] = array('align' => $lc_align, 'width' => $lc_width, '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 $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; } while ($_listing = tep_db_fetch_array($listing_query)) { $listing[] = $_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]."' "; } } // 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 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']); } 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']; } } } // 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++) { //sort order if ($column_list[$col] == 'PRODUCT_LIST_SORT_ORDER') { break; } //end sort order switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $lc_text = '?' . $listing[$x]['products_model'] . '?'; break; case 'PRODUCT_LIST_NAME': 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 = '?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>?'; } break; case 'PRODUCT_LIST_INFO': // next line missing [$x] $lc_text = $listing[$x]['products_info'] . '?'; break; case 'PRODUCT_LIST_MANUFACTURER': // next line missing [$x] twice $lc_text = '?<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a>?'; break; case 'PRODUCT_LIST_PRICE': $lc_align = 'right'; 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'])) . '?'; } break; case 'PRODUCT_LIST_QUANTITY': $lc_align = 'right'; $lc_text = '?' . $listing[$x]['products_quantity'] . '?'; break; case 'PRODUCT_LIST_INFO': break; case 'PRODUCT_LIST_WEIGHT': $lc_align = 'right'; $lc_text = '?' . $listing[$x]['products_weight'] . '?'; break; case 'PRODUCT_LIST_BUY_NOW': $lc_align = 'center'; // next line missing [$x] $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>?'; break; // incorrect brace } // end switch ($column_list[$col]) case 'PRODUCT_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,' class="shadow1" ') . '</a>?' . '<br>'.'?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . 'Click for More Info' . '</a>?'; } else { // next line missing [$x]: $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,' class="shadow1" ') . '</a>?' . '<br>'.'?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . '<font color="#006600">Click for More Info</font>' . '</a>?'; } break; } $list_box_contents[$cur_row][] = array('align' => $lc_align, 'params' => 'class="productListing-data"', 'text' => $lc_text); } // end for ($col=0, $n=sizeof($column_list); $col<$n; $col++) } // end for ($x = 0; $x < $no_of_listings; $x++) 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); } } elseif (PRODUCT_LISTING_DISPLAY_STYLE == 'columns') { $info_box_contents = array(); if ($listing_split->number_of_rows > 0) { $row = 0; $col = 0; $listing_query = tep_db_query($listing_split->sql_query); // BOF Separate Pricing per Customer $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; } while ($_listing = tep_db_fetch_array($listing_query)) { $listing[] = $_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]."' "; } } // 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 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']); } 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']; } } } // 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++) { // next line original, but why needed? products_name should be available already // $listing['products_name'] = tep_get_products_name($listing['products_id']); // all $listing['field'] exchange with $listing[$x]['field'] if (PRODUCT_LIST_IMAGE > 0) { $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, '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><br>'; } if (PRODUCT_LIST_NAME > 0) { $lc_text .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a><br>'; } if (PRODUCT_LIST_MODEL > 0) { $lc_text .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_model'] . '</a><br>'; } if (PRODUCT_LIST_MANUFACTURER > 0) { $lc_text .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a><br>'; } if (PRODUCT_LIST_PRICE > 0) { 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'])) . '?'; } } if (PRODUCT_LIST_BUY_NOW) { // next line $listing_values['field'] exhanged with $listing[$x]['field'] $lc_text .= '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW) . '</a>'; } $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"', 'text' => $lc_text); $col++; if ($col > PRODUCT_LIST_COL_NUM-1) { $col = 0; $row++; } } new contentBox($info_box_contents); } else { $info_box_contents = array(); $info_box_contents[0] = array('params' => 'class="productListing-odd"'); $info_box_contents[0][] = array('params' => 'class="productListing-data"', 'text' => TEXT_NO_PRODUCTS); new contentBox($info_box_contents); } } // end elseif (PRODUCT_LISTING_DISPLAY_STYLE == 'columns') if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (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 } ?> Quote Link to comment Share on other sites More sharing options...
Guest Posted December 18, 2005 Share Posted December 18, 2005 Mistakes, more than a few. Probably you had an [$x] missing with a listing['products'id] but there was a lot more wrong (see comments). <?php /* $Id: product_listing.php,v 1.44 2003/06/09 22:49:59 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright ? 2003 osCommerce Released under the GNU General Public License */ // define('PRODUCT_LISTING_DISPLAY_STYLE', 'columns'); // define('PRODUCT_LIST_COL_NUM', '3'); $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_SEARCH_RESULTS, 'p.products_id'); if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (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 } if (PRODUCT_LISTING_DISPLAY_STYLE == 'list') { $list_box_contents = array(); for ($col=0, $n=sizeof($column_list); $col<$n; $col++) { switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $lc_text = TABLE_HEADING_MODEL; $lc_width = '100'; break; case 'PRODUCT_LIST_NAME': $lc_text = TABLE_HEADING_PRODUCTS; $lc_width = '200'; break; case 'PRODUCT_LIST_INFO': $lc_text = TABLE_HEADING_INFO; $lc_width = '200'; break; case 'PRODUCT_LIST_MANUFACTURER': $lc_text = TABLE_HEADING_MANUFACTURER; break; case 'PRODUCT_LIST_PRICE': $lc_text = TABLE_HEADING_PRICE; $lc_align = 'right'; $lc_width = '100'; break; case 'PRODUCT_LIST_QUANTITY': $lc_text = TABLE_HEADING_QUANTITY; $lc_align = 'right'; $lc_width = '100'; break; case 'PRODUCT_LIST_INFO': $lc_text = 'More Info'; $lc_align = 'center'; break; case 'PRODUCT_LIST_WEIGHT': $lc_text = TABLE_HEADING_WEIGHT; $lc_align = 'right'; $lc_width = '100'; break; case 'PRODUCT_LIST_BUY_NOW': $lc_text = TABLE_HEADING_BUY_NOW; $lc_align = 'center'; $lc_width = '100'; break; case 'PRODUCT_LIST_IMAGE': $lc_text = TABLE_HEADING_IMAGE; $lc_align = 'center'; $lc_width = '100'; break; } //sort order if ($column_list[$col] == 'PRODUCT_LIST_SORT_ORDER'){ break; } if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') && ($column_list[$col] != 'PRODUCT_LIST_MULTIPLE')) { // if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) { //end sort order $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text); } $list_box_contents[0][] = array('align' => $lc_align, 'width' => $lc_width, '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 $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; } while ($_listing = tep_db_fetch_array($listing_query)) { $listing[] = $_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]."' "; } } // 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 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']); } 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']; } } } // 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++) { //sort order if ($column_list[$col] == 'PRODUCT_LIST_SORT_ORDER') { break; } //end sort order switch ($column_list[$col]) { case 'PRODUCT_LIST_MODEL': $lc_text = '?' . $listing[$x]['products_model'] . '?'; break; case 'PRODUCT_LIST_NAME': 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 = '?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a>?'; } break; case 'PRODUCT_LIST_INFO': // next line missing [$x] $lc_text = $listing[$x]['products_info'] . '?'; break; case 'PRODUCT_LIST_MANUFACTURER': // next line missing [$x] twice $lc_text = '?<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a>?'; break; case 'PRODUCT_LIST_PRICE': $lc_align = 'right'; 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'])) . '?'; } break; case 'PRODUCT_LIST_QUANTITY': $lc_align = 'right'; $lc_text = '?' . $listing[$x]['products_quantity'] . '?'; break; case 'PRODUCT_LIST_INFO': break; case 'PRODUCT_LIST_WEIGHT': $lc_align = 'right'; $lc_text = '?' . $listing[$x]['products_weight'] . '?'; break; case 'PRODUCT_LIST_BUY_NOW': $lc_align = 'center'; // next line missing [$x] $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id']) . '">' . tep_image_button('button_buy_now.gif', IMAGE_BUTTON_BUY_NOW) . '</a>?'; break; // incorrect brace } // end switch ($column_list[$col]) case 'PRODUCT_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,' class="shadow1" ') . '</a>?' . '<br>'.'?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . 'Click for More Info' . '</a>?'; } else { // next line missing [$x]: $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,' class="shadow1" ') . '</a>?' . '<br>'.'?<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing[$x]['products_id']) . '">' . '<font color="#006600">Click for More Info</font>' . '</a>?'; } break; } $list_box_contents[$cur_row][] = array('align' => $lc_align, 'params' => 'class="productListing-data"', 'text' => $lc_text); } // end for ($col=0, $n=sizeof($column_list); $col<$n; $col++) } // end for ($x = 0; $x < $no_of_listings; $x++) 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); } } elseif (PRODUCT_LISTING_DISPLAY_STYLE == 'columns') { $info_box_contents = array(); if ($listing_split->number_of_rows > 0) { $row = 0; $col = 0; $listing_query = tep_db_query($listing_split->sql_query); // BOF Separate Pricing per Customer $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; } while ($_listing = tep_db_fetch_array($listing_query)) { $listing[] = $_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]."' "; } } // 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 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']); } 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']; } } } // 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++) { // next line original, but why needed? products_name should be available already // $listing['products_name'] = tep_get_products_name($listing['products_id']); // all $listing['field'] exchange with $listing[$x]['field'] if (PRODUCT_LIST_IMAGE > 0) { $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, '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><br>'; } if (PRODUCT_LIST_NAME > 0) { $lc_text .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_name'] . '</a><br>'; } if (PRODUCT_LIST_MODEL > 0) { $lc_text .= '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $listing[$x]['products_id']) . '">' . $listing[$x]['products_model'] . '</a><br>'; } if (PRODUCT_LIST_MANUFACTURER > 0) { $lc_text .= '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $listing[$x]['manufacturers_id']) . '">' . $listing[$x]['manufacturers_name'] . '</a><br>'; } if (PRODUCT_LIST_PRICE > 0) { 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'])) . '?'; } } if (PRODUCT_LIST_BUY_NOW) { // next line $listing_values['field'] exhanged with $listing[$x]['field'] $lc_text .= '<br><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $listing[$x]['products_id'], 'NONSSL') . '">' . tep_image_button('button_buy_now.gif', TEXT_BUY . $listing[$x]['products_name'] . TEXT_NOW) . '</a>'; } $info_box_contents[$row][$col] = array('align' => 'center', 'params' => 'class="smallText" width="33%" valign="top"', 'text' => $lc_text); $col++; if ($col > PRODUCT_LIST_COL_NUM-1) { $col = 0; $row++; } } new contentBox($info_box_contents); } else { $info_box_contents = array(); $info_box_contents[0] = array('params' => 'class="productListing-odd"'); $info_box_contents[0][] = array('params' => 'class="productListing-data"', 'text' => TEXT_NO_PRODUCTS); new contentBox($info_box_contents); } } // end elseif (PRODUCT_LISTING_DISPLAY_STYLE == 'columns') if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (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 } ?> thank you so much, i will check, thanks so much! Quote Link to comment Share on other sites More sharing options...
Guest Posted December 18, 2005 Share Posted December 18, 2005 Jan, Ok i did what you said and I want to thank you SO MUCH! It works now! you are amazing, and so smart! I am so new at this and a little ditzy at it! thank you so much again! Jennifer Quote Link to comment Share on other sites More sharing options...
Guest Posted December 18, 2005 Share Posted December 18, 2005 I just installed the contribution : Quantity Price Breaks for Separate Pricing Per Customer and it calculates fine BUT when i view the shopping cart, the SUBTOTAL is wrong; the subtotal shows the price as if there were no price breaks, yet the line where the item is is correct. I have read in some places that its because the includes/classes/order.php was not changed properly, but ive looked over and over and there is no instructions to even edit that page. can someone help? Here is my order page if it helps, (not even sure if that is the page im supposed to edit, its the catalog/shopping_cart.php page that is the page the subtotal shows up wrong on. here is my includes/classes/order.php page <?php /* $Id: order.php,v 1.33 2003/06/09 22:25:35 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2003 osCommerce Released under the GNU General Public License */ class order { var $info, $totals, $products, $customer, $delivery, $content_type; function order($order_id = '') { $this->info = array(); $this->totals = array(); $this->products = array(); $this->customer = array(); $this->shipping = array(); $this->delivery = array(); if (tep_not_null($order_id)) { $this->query($order_id); } else { $this->cart(); } } function query($order_id) { global $languages_id; $order_id = tep_db_prepare_input($order_id); $order_query = tep_db_query("select customers_id, customers_name, customers_company, customers_street_address, customers_street_address2, customers_suburb, customers_city, customers_postcode, customers_state, customers_country, customers_telephone, customers_email_address, customers_address_format_id, delivery_name, delivery_company, delivery_street_address, delivery_street_address2, delivery_suburb, delivery_city, delivery_postcode, delivery_state, delivery_country, delivery_address_format_id, billing_name, billing_company, billing_street_address, billing_street_address2, billing_suburb, billing_city, billing_postcode, billing_state, billing_country, billing_address_format_id, payment_method, cc_type, cc_owner, cc_number, cc_expires, currency, currency_value, date_purchased, orders_status, last_modified, ship_date, tracking_no, delivery_date from " . TABLE_ORDERS . " where orders_id = '" . (int)$order_id . "'"); $order = tep_db_fetch_array($order_query); $totals_query = tep_db_query("select title, text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' order by sort_order"); while ($totals = tep_db_fetch_array($totals_query)) { $this->totals[] = array('title' => $totals['title'], 'text' => $totals['text']); } $order_total_query = tep_db_query("select text from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_total'"); $order_total = tep_db_fetch_array($order_total_query); $shipping_method_query = tep_db_query("select title from " . TABLE_ORDERS_TOTAL . " where orders_id = '" . (int)$order_id . "' and class = 'ot_shipping'"); $shipping_method = tep_db_fetch_array($shipping_method_query); $order_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . $order['orders_status'] . "' and language_id = '" . (int)$languages_id . "'"); $order_status = tep_db_fetch_array($order_status_query); $this->info = array('currency' => $order['currency'], 'currency_value' => $order['currency_value'], 'payment_method' => $order['payment_method'], 'cc_type' => $order['cc_type'], 'cc_owner' => $order['cc_owner'], 'cc_number' => $order['cc_number'], 'cc_expires' => $order['cc_expires'], 'date_purchased' => $order['date_purchased'], 'orders_status' => $order_status['orders_status_name'], 'last_modified' => $order['last_modified'], 'total' => strip_tags($order_total['text']), 'shipping_method' => ((substr($shipping_method['title'], -1) == ':') ? substr(strip_tags($shipping_method['title']), 0, -1) : strip_tags($shipping_method['title']))); $this->customer = array('id' => $order['customers_id'], 'name' => $order['customers_name'], 'company' => $order['customers_company'], 'street_address' => $order['customers_street_address'], 'street_address2' => $order['customers_street_address2'], 'suburb' => $order['customers_suburb'], 'city' => $order['customers_city'], 'postcode' => $order['customers_postcode'], 'state' => $order['customers_state'], 'country' => $order['customers_country'], 'format_id' => $order['customers_address_format_id'], 'telephone' => $order['customers_telephone'], 'email_address' => $order['customers_email_address']); $this->shipping = array('ship_date' => $order['ship_date'], 'tracking_no' => $order['tracking_no'], 'delivery_date' => $order['delivery_date']); $this->delivery = array('name' => $order['delivery_name'], 'company' => $order['delivery_company'], 'street_address' => $order['delivery_street_address'], 'street_address2' => $order['delivery_street_address2'], 'suburb' => $order['delivery_suburb'], 'city' => $order['delivery_city'], 'postcode' => $order['delivery_postcode'], 'state' => $order['delivery_state'], 'country' => $order['delivery_country'], 'format_id' => $order['delivery_address_format_id']); if (empty($this->delivery['name']) && empty($this->delivery['street_address'])) { $this->delivery = false; } $this->billing = array('name' => $order['billing_name'], 'company' => $order['billing_company'], 'street_address' => $order['billing_street_address'], 'street_address2' => $order['billing_street_address2'], 'suburb' => $order['billing_suburb'], 'city' => $order['billing_city'], 'postcode' => $order['billing_postcode'], 'state' => $order['billing_state'], 'country' => $order['billing_country'], 'format_id' => $order['billing_address_format_id']); $index = 0; $orders_products_query = tep_db_query("select orders_products_id, products_id, products_name, products_model, products_price, products_tax, products_quantity, final_price from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'"); while ($orders_products = tep_db_fetch_array($orders_products_query)) { $this->products[$index] = array('qty' => $orders_products['products_quantity'], 'id' => $orders_products['products_id'], 'name' => $orders_products['products_name'], 'model' => $orders_products['products_model'], 'tax' => $orders_products['products_tax'], 'price' => $orders_products['products_price'], 'final_price' => $orders_products['final_price']); // BOF Separate Pricing Per Customer if(!tep_session_is_registered('sppc_customer_group_id')) { $customer_group_id = '0'; } else { $customer_group_id = $sppc_customer_group_id; } if ($customer_group_id != '0'){ $orders_customers_price = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '". $customer_group_id . "' and products_id = '" . $products[$i]['id'] . "'"); if ($orders_customers = tep_db_fetch_array($orders_customers_price)){ $this->products[$index] = array('price' => $orders_customers['customers_group_price'], 'final_price' => $orders_customers['customers_group_price']); } } // EOF Separate Pricing Per Customer $subindex = 0; $attributes_query = tep_db_query("select products_options, products_options_values, options_values_price, price_prefix from " . TABLE_ORDERS_PRODUCTS_ATTRIBUTES . " where orders_id = '" . (int)$order_id . "' and orders_products_id = '" . (int)$orders_products['orders_products_id'] . "'"); if (tep_db_num_rows($attributes_query)) { while ($attributes = tep_db_fetch_array($attributes_query)) { $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options'], 'value' => $attributes['products_options_values'], 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price']); $subindex++; } } $this->info['tax_groups']["{$this->products[$index]['tax']}"] = '1'; $index++; } } function cart() { global $customer_id, $sendto, $billto, $cart, $languages_id, $currency, $currencies, $shipping, $payment; $this->content_type = $cart->get_content_type(); $customer_address_query = tep_db_query("select c.customers_firstname, c.customers_lastname, c.customers_telephone, c.customers_email_address, ab.entry_company, ab.entry_street_address, ab.entry_street_address2, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, co.countries_id, co.countries_name, co.countries_iso_code_2, co.countries_iso_code_3, co.address_format_id, ab.entry_state from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id) where c.customers_id = '" . (int)$customer_id . "' and ab.customers_id = '" . (int)$customer_id . "' and c.customers_default_address_id = ab.address_book_id"); $customer_address = tep_db_fetch_array($customer_address_query); $shipping_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_street_address2, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$sendto . "'"); $shipping_address = tep_db_fetch_array($shipping_address_query); $billing_address_query = tep_db_query("select ab.entry_firstname, ab.entry_lastname, ab.entry_company, ab.entry_street_address, ab.entry_street_address2, ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id, ab.entry_state from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)$billto . "'"); $billing_address = tep_db_fetch_array($billing_address_query); $tax_address_query = tep_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)($this->content_type == 'virtual' ? $billto : $sendto) . "'"); $tax_address = tep_db_fetch_array($tax_address_query); $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID, 'currency' => $currency, 'currency_value' => $currencies->currencies[$currency]['value'], 'payment_method' => $payment, 'cc_type' => (isset($GLOBALS['cc_type']) ? $GLOBALS['cc_type'] : ''), 'cc_owner' => (isset($GLOBALS['cc_owner']) ? $GLOBALS['cc_owner'] : ''), 'cc_number' => (isset($GLOBALS['cc_number']) ? $GLOBALS['cc_number'] : ''), 'cc_expires' => (isset($GLOBALS['cc_expires']) ? $GLOBALS['cc_expires'] : ''), 'shipping_method' => $shipping_title, //individual ship 'shipping_cost' => $shipping['cost'], 'subtotal' => 0, 'tax' => 0, 'tax_groups' => array(), 'comments' => (isset($GLOBALS['comments']) ? $GLOBALS['comments'] : '')); if (isset($GLOBALS[$payment]) && is_object($GLOBALS[$payment])) { $this->info['payment_method'] = $GLOBALS[$payment]->title; if ( isset($GLOBALS[$payment]->order_status) && is_numeric($GLOBALS[$payment]->order_status) && ($GLOBALS[$payment]->order_status > 0) ) { $this->info['order_status'] = $GLOBALS[$payment]->order_status; } } $this->customer = array('firstname' => $customer_address['customers_firstname'], 'lastname' => $customer_address['customers_lastname'], 'company' => $customer_address['entry_company'], 'street_address' => $customer_address['entry_street_address'], 'street_address2' => $customer_address['entry_street_address2'], 'suburb' => $customer_address['entry_suburb'], 'city' => $customer_address['entry_city'], 'postcode' => $customer_address['entry_postcode'], 'state' => ((tep_not_null($customer_address['entry_state'])) ? $customer_address['entry_state'] : $customer_address['zone_name']), 'zone_id' => $customer_address['entry_zone_id'], 'country' => array('id' => $customer_address['countries_id'], 'title' => $customer_address['countries_name'], 'iso_code_2' => $customer_address['countries_iso_code_2'], 'iso_code_3' => $customer_address['countries_iso_code_3']), 'format_id' => $customer_address['address_format_id'], 'telephone' => $customer_address['customers_telephone'], 'email_address' => $customer_address['customers_email_address']); $this->delivery = array('firstname' => $shipping_address['entry_firstname'], 'lastname' => $shipping_address['entry_lastname'], 'company' => $shipping_address['entry_company'], 'street_address' => $shipping_address['entry_street_address'], 'street_address2' => $shipping_address['entry_street_address2'], 'suburb' => $shipping_address['entry_suburb'], 'city' => $shipping_address['entry_city'], 'postcode' => $shipping_address['entry_postcode'], 'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_name']), 'zone_id' => $shipping_address['entry_zone_id'], 'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']), 'country_id' => $shipping_address['entry_country_id'], 'format_id' => $shipping_address['address_format_id']); $this->billing = array('firstname' => $billing_address['entry_firstname'], 'lastname' => $billing_address['entry_lastname'], 'company' => $billing_address['entry_company'], 'street_address' => $billing_address['entry_street_address'], 'street_address2' => $billing_address['entry_street_address2'], 'suburb' => $billing_address['entry_suburb'], 'city' => $billing_address['entry_city'], 'postcode' => $billing_address['entry_postcode'], 'state' => ((tep_not_null($billing_address['entry_state'])) ? $billing_address['entry_state'] : $billing_address['zone_name']), 'zone_id' => $billing_address['entry_zone_id'], 'country' => array('id' => $billing_address['countries_id'], 'title' => $billing_address['countries_name'], 'iso_code_2' => $billing_address['countries_iso_code_2'], 'iso_code_3' => $billing_address['countries_iso_code_3']), 'country_id' => $billing_address['entry_country_id'], 'format_id' => $billing_address['address_format_id']); $index = 0; $products = $cart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'tax' => tep_get_tax_rate($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'tax_description' => tep_get_tax_description($products[$i]['tax_class_id'], $tax_address['entry_country_id'], $tax_address['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']), 'weight' => $products[$i]['weight'], 'id' => $products[$i]['id']); // BOF Separate Pricing Per Customer if(!tep_session_is_registered('sppc_customer_group_id')) { $customer_group_id = '0'; } else { $customer_group_id = $sppc_customer_group_id; } if ($customer_group_id != '0'){ $orders_customers_price = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where customers_group_id = '". $customer_group_id . "' and products_id = '" . $products[$i]['id'] . "'"); $orders_customers = tep_db_fetch_array($orders_customers_price); if ($orders_customers = tep_db_fetch_array($orders_customers_price)) { $this->products[$index] = array('price' => $orders_customers['customers_group_price'], 'final_price' => $orders_customers['customers_group_price'] + $cart->attributes_price($products[$i]['id'])); } } // EOF Separate Pricing Per Customer if ($products[$i]['attributes']) { $subindex = 0; reset($products[$i]['attributes']); while (list($option, $value) = each($products[$i]['attributes'])) { //++++ QT Pro: Begin Changed code $attributes_query = tep_db_query("select popt.products_options_name, popt.products_options_track_stock, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int)$value . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'"); //++++ QT Pro: End Changed Code $attributes = tep_db_fetch_array($attributes_query); //++++ QT Pro: Begin Changed code //clr 030714 Determine if attribute is a text attribute and change products array if it is. if ($value == PRODUCTS_OPTIONS_VALUE_TEXT_ID){ $attr_value = $products[$i]['attributes_values'][$option]; } else { $attr_value = $attributes['products_options_values_name']; } $this->products[$index]['attributes'][$subindex] = array('option' => $attributes['products_options_name'], 'value' => $attributes['products_options_values_name'], 'option_id' => $option, 'value_id' => $value, 'prefix' => $attributes['price_prefix'], 'price' => $attributes['options_values_price'], 'track_stock' => $attributes['products_options_track_stock']); //++++ QT Pro: End Changed Code $subindex++; } } $shown_price = tep_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty']; $this->info['subtotal'] += $shown_price; $products_tax = $this->products[$index]['tax']; $products_tax_description = $this->products[$index]['tax_description']; // BOF Separate Pricing Per Customer, show_tax modification // next line was original code // if (DISPLAY_PRICE_WITH_TAX == 'true') { global $sppc_customer_group_show_tax; if(!tep_session_is_registered('sppc_customer_group_show_tax')) { $customer_group_show_tax = '1'; } else { $customer_group_show_tax = $sppc_customer_group_show_tax; } if (DISPLAY_PRICE_WITH_TAX == 'true' && $customer_group_show_tax == '1') { // EOF Separate Pricing Per Customer, show_tax modification $this->info['tax'] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); if (isset($this->info['tax_groups']["$products_tax_description"])) { $this->info['tax_groups']["$products_tax_description"] += $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); } else { $this->info['tax_groups']["$products_tax_description"] = $shown_price - ($shown_price / (($products_tax < 10) ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax))); } } else { $this->info['tax'] += ($products_tax / 100) * $shown_price; if (isset($this->info['tax_groups']["$products_tax_description"])) { $this->info['tax_groups']["$products_tax_description"] += ($products_tax / 100) * $shown_price; } else { $this->info['tax_groups']["$products_tax_description"] = ($products_tax / 100) * $shown_price; } } $index++; } // BOF Separate Pricing Per Customer, show_tax modification // next line was original code // if (DISPLAY_PRICE_WITH_TAX == 'true') { global $sppc_customer_group_show_tax; if(!tep_session_is_registered('sppc_customer_group_show_tax')) { $customer_group_show_tax = '1'; } else { $customer_group_show_tax = $sppc_customer_group_show_tax; } if (DISPLAY_PRICE_WITH_TAX == 'true' && $customer_group_show_tax == '1') { // EOF Separate Pricing Per Customer, show_tax modification $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost']; } else { $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost']; } } } ?> i would appreciate any help! Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted December 18, 2005 Share Posted December 18, 2005 I just installed the contribution : Quantity Price Breaks for Separate Pricing Per Customerand it calculates fine BUT when i view the shopping cart, the SUBTOTAL is wrong; the subtotal shows the price as if there were no price breaks, yet the line where the item is is correct. Actually, the shopping_cart.php page and the box shopping cart all get their information from catalog/includes/classes/shopping_cart.php. If you haven't added any other contributions to this file I would suggest uploading the one from the package.To check whether the class has all the correct information, you can change the footer on catalog/shopping_cart.php to: <!-- footer //--> <?php require(DIR_WS_INCLUDES . 'footer.php'); ?> <?php echo '<pre>'; print_r($cart); ?> <!-- footer_eof //--> You will then see something like: shoppingcart Object ( [contents] => Array ( [4] => Array ( [qty] => 1 ) ) [total] => 41.2 [weight] => 23 [cartID] => 42647 [content_type] => ) printed at the bottom of the page. That will give an idea what information it holds. Quote Link to comment Share on other sites More sharing options...
Guest Posted December 18, 2005 Share Posted December 18, 2005 Jan you are so smart, lol thanks so much but i am still not sure how to fix it? I have a lot of contributions installed so im afraid to just upload the new one. i have the coupon code ccgv installed which took me a whole day almost lol so i dont want to mess that up. but you are saying its the shopping cart page that is probably messed up? here that my includes/classes/shopping cart below if you can help me? <?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 © 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() { //ICW replace line global $customer_id, $gv_id, $REMOTE_ADDR; // 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'])) { //clr 031714 udate query to include attribute value. This is needed for text attributes. $attr_value = $this->contents[$products_id]['attributes_values'][$option]; tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_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) . "'"); } } //ICW ADDDED FOR CREDIT CLASS GV - START if (tep_session_is_registered('gv_id')) { $gv_query = tep_db_query("insert into " . TABLE_COUPON_REDEEM_TRACK . " (coupon_id, customer_id, redeem_date, redeem_ip) values ('" . $gv_id . "', '" . (int)$customer_id . "', now(),'" . $REMOTE_ADDR . "')"); $gv_update = tep_db_query("update " . TABLE_COUPONS . " set coupon_active = 'N' where coupon_id = '" . $gv_id . "'"); tep_gv_account_update($customer_id, $gv_id); tep_session_unregister('gv_id'); } //ICW ADDDED FOR CREDIT CLASS GV - END } // 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 //CLR 020606 update query to pull attribute value_text. This is needed for text attributes. $attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text 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']; //CLR 020606 if text attribute, then set additional information if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) { $this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text']; } } } $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); // 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'); } 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)) { //CLR 020606 check if input was from text box. If so, store additional attribute information //CLR 020708 check if text input is blank, if so do not add to attribute lists //CLR 030228 add htmlspecialchars processing. This handles quotes and other special chars in the user input. $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { if (trim($value) == NULL) { $blank_value = TRUE; } else { $option = substr($option, strlen(TEXT_PREFIX)); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { $this->contents[$products_id]['attributes'][$option] = $value; // insert into database //CLR 020606 update db insert to include attribute value_text. This is needed for text attributes. //CLR 030228 add tep_db_input() processing 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, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_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 ($quantity==0) $this->remove($products_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)) { //CLR 020606 check if input was from text box. If so, store additional attribute information //CLR 030108 check if text input is blank, if so do not update attribute lists //CLR 030228 add htmlspecialchars processing. This handles quotes and other special chars in the user input. $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { if (trim($value) == NULL) { $blank_value = TRUE; } else { $option = substr($option, strlen(TEXT_PREFIX)); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { $this->contents[$products_id]['attributes'][$option] = $value; // update database //CLR 020606 update db insert to include attribute value_text. This is needed for text attributes. //CLR 030228 add tep_db_input() processing if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_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; //CLR 030228 add call tep_get_uprid to correctly format product ids containing quotes $products_id = tep_get_uprid($products_id, $attributes); 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_virtual = 0; // ICW Gift Voucher System $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']; // 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 // 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)) { // ICW ORDER TOTAL CREDIT CLASS Start Amendment $no_count = 1; $gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $gv_result = tep_db_fetch_array($gv_query); if (ereg('^GIFT', $gv_result['products_model'])) { $no_count = 0; } // ICW ORDER TOTAL CREDIT CLASS End Amendment $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']; // 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_virtual += tep_add_tax($products_price, $products_tax) * $qty * $no_count;// ICW CREDIT CLASS; $this->weight_virtual += ($qty * $products_weight) * $no_count;// ICW CREDIT CLASS; $this->total += tep_add_tax($products_price, $products_tax) * $qty; $this->weight += ($qty * $products_weight); } ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // BOF - AAP V1.0 - updated to account for no price prefix to equal actual price // 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); $price_prefix = $attribute_price['price_prefix']; $option_price = $attribute_price['options_values_price']; $products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $products_stuff = tep_db_fetch_array($products_query); $products_price = $products_stuff['products_price']; if ($price_prefix == '+') { $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } if ($price_prefix == '-') { $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } if ($price_prefix == '') { $this->total += $qty * tep_add_tax(tep_adjust_price($option_price, $products_price), $product_tax); } } } } } // subtotal function for attributes price 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); $price_prefix = $attribute_price['price_prefix']; $option_price = $attribute_price['options_values_price']; $products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $products_stuff = tep_db_fetch_array($products_query); $products_price = $products_stuff['products_price']; if ($price_prefix == '+') { $attributes_price += $option_price; } if ($price_prefix == '-') { $attributes_price -= $option_price; } if ($price_prefix == '') { $attributes_price += tep_adjust_price($option_price, $products_price); } } } return $attributes_price; } // EOF - AAP V1.0 ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// 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; $pf = new PriceFormatter; $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)) { $products_price = $pf->computePrice($this->contents[$products_id]['qty']); // 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'], '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; } // CREDIT CLASS Start Amendment function show_total_virtual() { $this->calculate(); return $this->total_virtual; } function show_weight_virtual() { $this->calculate(); return $this->weight_virtual; } // CREDIT CLASS End Amendment 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; } } } // ICW ADDED CREDIT CLASS - Begin } elseif ($this->show_weight() == 0) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $virtual_check_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['products_weight'] == 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; } } } // ICW ADDED CREDIT CLASS - End } 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']; } } // ------------------------ ICW CREDIT CLASS Gift Voucher Addittion-------------------------------Start // amend count_contents to show nil contents for shipping // as we don't want to quote for 'virtual' item // GLOBAL CONSTANTS if NO_COUNT_ZERO_WEIGHT is true then we don't count any product with a weight // which is less than or equal to MINIMUM_WEIGHT // otherwise we just don't count gift certificates function count_contents_virtual() { // get total number of items in cart disregard gift vouchers $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $no_count = false; $gv_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $gv_result = tep_db_fetch_array($gv_query); if (ereg('^GIFT', $gv_result['products_model'])) { $no_count=true; } if (NO_COUNT_ZERO_WEIGHT == 1) { $gv_query = tep_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . tep_get_prid($products_id) . "'"); $gv_result=tep_db_fetch_array($gv_query); if ($gv_result['products_weight']<=MINIMUM_WEIGHT) { $no_count=true; } } if (!$no_count) $total_items += $this->get_quantity($products_id); } } return $total_items; } // ------------------------ ICW CREDIT CLASS Gift Voucher Addittion-------------------------------End } /* ### Class wishlist ### */ class wishlist_class { var $contents, $total, $weight, $cartID, $content_type; function wishlist_class() { $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_WISHLIST . " 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_WISHLIST . " (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_WISHLIST_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_WISHLIST . " 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_WISHLIST . " 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_WISHLIST_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_WISHLIST . " where customers_id = '" . (int)$customer_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_WISHLIST_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_wishlist, $customer_id; $products_id = tep_get_uprid($products_id, $attributes); if ($notify == true) { $new_products_id_in_wishlist = $products_id; tep_session_register('new_products_id_in_wishlist'); } 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_WISHLIST . " (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_WISHLIST_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_WISHLIST . " 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_WISHLIST_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_WISHLIST . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_WISHLIST_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_WISHLIST . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_WISHLIST_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; // BOF Separate Pricing Per Customer, Price Break 1.11.3 mod global $languages_id; $pf = new PriceFormatter; 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)) { 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); $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; $pf = new PriceFormatter; $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)) { $products_price = $pf->computePrice($this->contents[$products_id]['qty']); // 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'], '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'] : ''), 'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : '')); } } 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']; } } } ?> Quote Link to comment Share on other sites More sharing options...
rmowles Posted December 18, 2005 Share Posted December 18, 2005 I couldn't see this covered but may have missed it... my store operates in Ontario. I'm using SPPC to set up dealer pricing, but for taxes in Canada, everyone has to pay 7% GST. So I'd like to have the tax exempt flag leave the 7% GST alone, but remove the 8% Ontario PST. Thanks in advance for any help you can provide! Regards, Robert Quote Aartech Canada Home Automation, CCTV Camera & DVR, Security Store Link to comment Share on other sites More sharing options...
Jan Zonjee Posted December 19, 2005 Share Posted December 19, 2005 Robert, for taxes in Canada, everyone has to pay 7% GST. So I'd like to have the tax exempt flag leave the 7% GST alone, but remove the 8% Ontario PST. You are the second one who says he needed that for Canada (Marvin was the first). It has been coded, but supposed to be in the next version of SPPC. That hasn't been released yet. I will see what I have. Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted December 19, 2005 Share Posted December 19, 2005 Jennifer, but you are saying its the shopping cart page that is probably messed up? here that my includes/classes/shopping cart below if you can help me? I got confused, you have two classes in there: one cart and one wish_list. The function calculate in the first one was not adapted correctly to the Price Break contribution. Try this one (note that for code to be able to cut and paste without getting line breaks in there you should embrace that in between [ code ] and [ /code ] tags (without the spaces that I put in to prevent it from being parsed): function calculate() { $this->total_virtual = 0; // ICW Gift Voucher System $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; 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)) { */ if ($product = $pf->loadProduct($products_id, $languages_id)) { // ICW ORDER TOTAL CREDIT CLASS Start Amendment $no_count = 1; if (ereg('^GIFT', $product['products_model'])) { $no_count = 0; } // ICW ORDER TOTAL CREDIT CLASS End Amendment $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $pf->computePrice($qty); $products_weight = $product['products_weight']; $this->total_virtual += tep_add_tax($products_price, $products_tax) * $qty * $no_count;// ICW CREDIT CLASS; $this->weight_virtual += ($qty * $products_weight) * $no_count;// ICW CREDIT CLASS; $this->total += tep_add_tax($products_price, $products_tax) * $qty; $this->weight += ($qty * $products_weight); } // end ($product = $pf->loadProduct($products_id, $languages_id)) ///////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// // BOF - AAP V1.0 - updated to account for no price prefix to equal actual price // 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); $price_prefix = $attribute_price['price_prefix']; $option_price = $attribute_price['options_values_price']; /* BOF why get the price again? // the price is already calculated by PriceFormatter $products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $products_stuff = tep_db_fetch_array($products_query); $products_price = $products_stuff['products_price']; EOF why get the price again? */ if ($price_prefix == '+') { $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } if ($price_prefix == '-') { $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } if ($price_prefix == '') { $this->total += $qty * tep_add_tax(tep_adjust_price($option_price, $products_price), $product_tax); } } } } } Quote Link to comment Share on other sites More sharing options...
SuperSewist Posted December 19, 2005 Share Posted December 19, 2005 hey all CGGV and SPPC users: Too many contributions to pick from, and I'm getting confused on which will do what. Please read my desires and advise which contribution(s) will be good to use, and what if any new/custom modules/files/parts might need to be required to pull this all off. I figure those of you who are using these MODS daily are the best folk to say if it will do what I want. I have also posted this in CGGV support forum, as I may need both of these MODS or maybe one or the other is the better choice. I know y'all will set me straight! I want to have 3 customer type/groups. group A is regular retail. they will get standard price, but also I want to offer price breaks on a per-product basis for example order 4 each and price is lower per each. Also this group will see the category I have set up under bundled products "kits and sets" which have discounts built into the bundled price. Also this group can be bumped into group B or C if their order is sufficiently large. This part could get tricky as if this happens, all bundled products will have to be split into their components and placed back into the cart separately as customers do not get to double-dip discounts. Now groups B and C are two levels of wholesale discount, 25% and 50%. This discount can be applied at the end onto the order total. It doesn't matter if the discounted price shows for each product as they are shopping, but if it does, I would want both retail and discount price, after they are logged in of course. They do not get to see bundled products category "kits and set" again due to no double-dipping allowed, and they will not get quantity price breaks per product/item. Just the straight % off retail at the end. Also for group C, I cannot do 50% on some items (mostly sewing notions that I don't manufacture), so those items need to be capped at 25%. I would like to add products in the future that would only be available to this group. And to have a certain level of annual sales to stay in this group. And while we're dreaming, let's have a monthly check to see who needs an email reminding them to order $$$ by [date] to stay in the group. Coupons per product or order, or gift certificates, would be gravy but has not yet been a big part of my marketing and distribution efforts. Just for future thought, after this MOD, I will be working on a "dangling carrot" MOD effect of freebies as the order grows, so I will want to be sure they work together. One carrot could be a coupon for a future purchase! Of course the carrots will be different for each of the three groups. HAHAHAHA I know it's possible, osC can do Anything!! Well OK except maybe it can't wash dishes. Darn. I'm willing to get my hands dirty in the database and php, so offer up what you think might be an ideal combo. I am not expecting an out-of-the-box solution, but if one exists, WOO-HOO!! I don't really understand classes (yet) but I can follow the logic and cut-n-paste with relish, sometimes have even made stuff up and it worked! Plus all my MODS so far have required at least some tweaking and I really like my new cart system and adjusting it to meet my needs. It is cool how osC can be twisted and molded to match so many different types of stores and businesses and languages and etc etc etc. As always, TIA Quote Toward Continued Success - - > Carol Hawkey - - > KidsLearnToSew.com - - > Wyoming, USA Mods Installed - - > Authnet AIM2 - Bundled Products 1.4 - Fancier Invoice 6.1 - Email_HTML_Order_Link_Fixed - Header Tags Controller - Login aLa Amazon - JustOneAttribute - Article Manager - SPPC w/PB - spiders.txt - Dangling Carrot/Olive - Printable Catalog - CCGV(trad) Planned Mods - - > Purchase Without Account - USPS Label - Ultimate SEO Link to comment Share on other sites More sharing options...
OGN Posted December 21, 2005 Share Posted December 21, 2005 What is wrong with:insert into products_groups select '1' as customers_group_id, (0.95 * p.products_price) as customers_group_price, p.products_id from products p; Sounds promising... where would I insert this... (with out being rude LOL) Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted December 21, 2005 Share Posted December 21, 2005 Sounds promising... where would I insert this... (with out being rude LOL) That's an sql command. Most hosting companies provide access to your MySql database with phpMyAdmin, there you should run it (or, but that is a bit silly for a one line command, copy it to a file and then "run" the sql file as you ran the sql file for SPPC). Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted December 21, 2005 Share Posted December 21, 2005 I want to have 3 customer type/groups. group A is regular retail. they will get standard price, but also I want to offer price breaks on a per-product basis for example order 4 each and price is lower per each. Also this group will see the category I have set up under bundled products "kits and sets" which have discounts built into the bundled price. I don't know the bundled products contribution but it sounds you are going to have a conflict with Quantity Price Breaks here.Also this group can be bumped into group B or C if their order is sufficiently large. This part could get tricky as if this happens, all bundled products will have to be split into their components and placed back into the cart separately as customers do not get to double-dip discounts. Tricky indeed, what if the threshold is reached, you dynamically bump them in a group with higher discont (haven't seen this coded yet) and then with the higher discount get below the threshold (infinite loop!). Now groups B and C are two levels of wholesale discount, 25% and 50%. This discount can be applied at the end onto the order total. Doesn't work like that with SPPC.They do not get to see bundled products category "kits and set" again due to no double-dipping allowed, and they will not get quantity price breaks per product/item. Just the straight % off retail at the end. You can hide products for customer groups (a separate contribution) so that shouldn't be too difficult. And to have a certain level of annual sales to stay in this group. And while we're dreaming, let's have a monthly check to see who needs an email reminding them to order $$$ by [date] to stay in the group. Haven't seen a contribution for that yet.Just for future thought, after this MOD, I will be working on a "dangling carrot" MOD effect of freebies as the order grows, so I will want to be sure they work together. One carrot could be a coupon for a future purchase! Of course the carrots will be different for each of the three groups. Don't know that contribution, so I wouldn't know. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.