lcontreras27 Posted January 15, 2010 Share Posted January 15, 2010 OK i found my bug. It was a problem in the order.php. Now i had a new problem. I use the wishlist-contrib. In the wishlist, the options are not displayed. But when i put a article from the wishlist to the shopping-cart, the options are correct transmit to it. I think, its only a display-problem in the wishlist, but i can´t find the bug. Can somebody help me please?! I have the exact same problem, everything works fine, but when I review the orders, invoices, or any post-sale control. The CUSTOMER-INPUT text substitutes the text entered by the customer. Please HELP!!!, it will be very much appreciated. Thanks. Hey!, I'm sorry if I'm beeing so insistent but I really need help, if someone has the answer to my problem please tell me, help will be even more appreciated than yesterday ;) Thanks. Quote Link to comment Share on other sites More sharing options...
rosemaryann Posted January 15, 2010 Share Posted January 15, 2010 I have the exact same problem, everything works fine, but when I review the orders, invoices, or any post-sale control. The CUSTOMER-INPUT text substitutes the text entered by the customer. Please HELP!!!, it will be very much appreciated. Thanks. Hey!, I'm sorry if I'm beeing so insistent but I really need help, if someone has the answer to my problem please tell me, help will be even more appreciated than yesterday ;) Thanks. Hey - probably you need to check and make sure you have added the file: includes/modules/option_types.php in the correct location. The other thing I would suggest is to go through /includes/classes/shopping_cart.php and make sure all the modifications are entered correctly. Though if you have another contribution(s) installed it may effect it differently. Quote Link to comment Share on other sites More sharing options...
Zappo Posted January 15, 2010 Author Share Posted January 15, 2010 Though if you have another contribution(s) installed it may effect it differently. That does seem to be the main problem for most users at this moment. Like my signature says, it never hurts to help, but I'm no miracle worker... As far as I can tell, the contribution works (almost?) flawlessly "out of the box", and any problems with it come from merging with other contributions, or not correctly merging all the provided files. For the people who have problems with CUSTOMER-INPUT after logging in, I suggest re-checking the file catalog/includes/classes/shopping_cart.php The "temporary cart" get's converted (and put in the Database) from there... Quote Like Eek said... It never hurts to help!---------------------------------------- Link to comment Share on other sites More sharing options...
lcontreras27 Posted January 15, 2010 Share Posted January 15, 2010 Hey - probably you need to check and make sure you have added the file: includes/modules/option_types.php in the correct location. The other thing I would suggest is to go through /includes/classes/shopping_cart.php and make sure all the modifications are entered correctly. Though if you have another contribution(s) installed it may effect it differently. That does seem to be the main problem for most users at this moment. Like my signature says, it never hurts to help, but I'm no miracle worker... As far as I can tell, the contribution works (almost?) flawlessly "out of the box", and any problems with it come from merging with other contributions, or not correctly merging all the provided files. For the people who have problems with CUSTOMER-INPUT after logging in, I suggest re-checking the file catalog/includes/classes/shopping_cart.php The "temporary cart" get's converted (and put in the Database) from there... Thanks so much both, but I have no other contribution installed, actually it is the only mod that I need for the store so that shouldn't be a problem, I'm checking the files you mention and hope it works. I was trying to see if someone knew about the "bug" that other person wrote about that seem to solve the issue, but your help is well appreciated. Best regards. Quote Link to comment Share on other sites More sharing options...
multimixer Posted January 16, 2010 Share Posted January 16, 2010 Hi people. There are news about merging SPPC and Option Types v2. I have it working !. I will post my results here in the hope that somebody will take a look at them and make something more "sophisticated" of it:). I did following changes: 1) in file modules/option_types.php 1.1) After $ProdOpt_Length = $products_options_name['products_options_length']; I placed // BOF SPPC multimixer 13 1 10 $aid = tep_db_query("select pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)tep_db_input($product_info['products_id']) . "' and pa.options_id = '" . $ProdOpt_ID . "'"); $aid_result = tep_db_fetch_array($aid); $ProdAtr_ID = $aid_result['products_attributes_id']; // SPPC // EOF SPPC multimixer 13 1 10 so I have the attributes id available for a particular product/option combination 1.2) After $products_attribs_query = tep_db_query("select distinct options_values_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . (int)tep_db_input($product_info['products_id']) . "' and options_id = '" . $ProdOpt_ID . "' order by products_options_sort_order"); I placed // BOF SPPC multimixer 13 1 10 // forum http://www.oscommerce.com/forums/topic/338661-contribution-option-types-v2/page__view__findpost__p__1473708 if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail // check if something in table attributes groups for this product/customer group/ attributes id $cid_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_id = '" . (int)tep_db_input($product_info['products_id']) . "' and customers_group_id = '" . $customer_group_id . "' and products_attributes_id = '" . $ProdAtr_ID . "'"); $cid_result = tep_db_fetch_array($cid_query); if ($cid_result['total'] > 0) { // if there is something, use this table (importand attribute id) $products_attribs_query = tep_db_query("select distinct pa.options_values_id, pag.options_values_price, pag.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag where pa.products_attributes_id = '" . $ProdAtr_ID . "' and pa.products_attributes_id = pag.products_attributes_id and pag.customers_group_id = '" . $customer_group_id . "' and pag.products_id='" . (int)tep_db_input($product_info['products_id']) . "' order by products_options_sort_order"); } // end if ($cid_result['total'] > 0) } // end if ($customer_group_id > 0) // EOF SPPC multimixer 13 1 10 so I'm getting the data for customer groups in case they exist and they have defined options. This cover all option cases exept of drop down (covered by product info) and radio/images see below 1.3) In both cases (OPTIONS_TYPE_RADIO and OPTIONS_TYPE_IMAGE) I replaced this $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$product_info['products_id'] . "' and pa.options_id = '" . $ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' order by pa.products_options_sort_order"); by this // BOF SPPC multimixer 13 1 10 // forum http://www.oscommerce.com/forums/topic/338661-contribution-option-types-v2/page__view__findpost__p__1473708 if ($customer_group_id > 0) { // only need to check products_groups if customer is not retail // check if something in table attributes groups for this product/customer group/ $cid_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_id = '" . (int)$product_info['products_id'] . "' and customers_group_id = '" . $customer_group_id . "'"); $cid_result = tep_db_fetch_array($cid_query); if ($cid_result['total'] > 0) { // if there is something, use this table (importand attribute id) $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pag.options_values_price, pag.price_prefix, pag.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag where pa.products_id = '" . (int)$product_info['products_id'] . "' and pa.options_id = '" . $ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and pa.products_attributes_id = pag.products_attributes_id and pag.customers_group_id = '" . $customer_group_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.products_options_sort_order"); } else { //if ($cid_result['total'] > 0) // reqular query $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$product_info['products_id'] . "' and pa.options_id = '" . $ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.products_options_sort_order"); } // end if ($cid_result['total'] > 0) } else { //if ($customer_group_id > 0) // reqular query $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$product_info['products_id'] . "' and pa.options_id = '" . $ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . $languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.products_options_sort_order"); } // end if ($customer_group_id > 0) // EOF SPPC multimixer 13 1 10 I know this looks not elegant at all, but I just didn't succeed to get the "replacement" logic of SPPC, like it is done in product_info.php into this file here. Anyway, it works at least 2) in shopping_cart.php (the main file, not the /classes/ one) I replaced this $attributes = tep_db_query("select popt.products_options_name, 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 . "'"); by this // BOF SPPC multimixer 13 1 09 if ($customer_group_id > 0) { // only need to check if customer is not retail // mm get the attributes_id $aid = tep_db_query("select pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_values_id = '" . (int)$value . "'"); $aid_result = tep_db_fetch_array($aid); // check if something in table attributes groups for this product/customer group $cid_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pag.products_id = '" . (int)$products[$i]['id'] . "' and pag.customers_group_id = '" . $customer_group_id . "' and pag.products_attributes_id = '" . $aid_result['products_attributes_id'] . "' and pa.options_values_id = '" . (int)$value . "'"); $cid_result = tep_db_fetch_array($cid_query); if ($cid_result['total'] > 0) { // if there is something, use this table (importand attribute id and option value id) $attributes = tep_db_query("select popt.products_options_name, poval.products_options_values_name, pag.options_values_price, pag.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag, " . 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 pag.customers_group_id = '" .(int)$customer_group_id . "' and pa.products_attributes_id = pag.products_attributes_id and popt.language_id = '" . (int)$languages_id . "' and poval.language_id = '" . (int)$languages_id . "'"); } else {// if ($cid_result['total'] > 0) // if nohing use reqular query $attributes = tep_db_query("select popt.products_options_name, 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 . "'"); } // end if ($cid_result['total'] > 0) } else { //if ($customer_group_id > 0) // reqular query // BOF original Zappo - Option Types v2 $attributes = tep_db_query("select popt.products_options_name, 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 . "'"); // EOF original Zappo - Option Types v2 } // end if ($customer_group_id > 0) // EOF SPPC multimixer 13 1 09 Again: not very elegant maybe, but it works Thats all ! Preposition is of course a correct merging of the other files, valid for both contributions (SPPC and Option Types v2). There could be a confusion in files product_info.php and classes/shopping cart.php, so, here are some tips about how I did it 3) File product_info.php I will post the 3 queries related to product attributes as they look after the merging $products_attributes_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$HTTP_GET_VARS['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 "); $products_options_name_query = tep_db_query("select distinct popt.products_options_id, popt.products_options_name, popt.products_options_type, popt.products_options_length, popt.products_options_comment from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_ATTRIBUTES . " patrib where patrib.products_id='" . (int)$product_info['products_id'] . "' and patrib.options_id = popt.products_options_id and popt.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by popt.products_options_order, popt.products_options_name"); $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix, pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pa.options_id = '" . (int)$ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' and find_in_set('".$customer_group_id."', attributes_hide_from_groups) = 0 order by pa.products_options_sort_order"); 4) File classes/shopping_cart.php There is nothing that could cause a problem except of one thing that is resulting to text and image options not to be added to the cart properly. In the SPPC instructions it says to replace this $check_product_query = tep_db_query("select products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); $check_product = tep_db_fetch_array($check_product_query); if (($check_product !== false) && ($check_product['products_status'] == '1')) { by this // BOF SPPC attribute hide check, original query expanded to include attributes $check_product_query = tep_db_query("select p.products_status, options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_ATTRIBUTES . " using(products_id) where p.products_id = '" . (int)$products_id . "'"); while ($_check_product = tep_db_fetch_array($check_product_query)) { $check_product[] = $_check_product; } // end while ($_check_product = tep_db_fetch_array($check_product_query)) $no_of_check_product = count($check_product); if (is_array($attributes)) { foreach($attributes as $attr_option => $attr_option_value) { $valid_option = '0'; for ($x = 0; $x < $no_of_check_product ; $x++) { if ($attr_option == $check_product[$x]['options_id'] && $attr_option_value == $check_product[$x]['options_values_id']) { $valid_option = '1'; if ($check_product[$x]['hide_attr_status'] == '1') { // delete hidden attributes from array attributes unset($attributes[$attr_option]); } } // end if ($attr_option == $check_product[$x]['options_id'].... } // end for ($x = 0; $x < $no_of_check_product ; $x++) if ($valid_option == '0') { // after having gone through the options for this product and not having found a matching one // we can conclude that apparently this is not a valid option for this product so remove it unset($attributes[$attr_option]); } } // end foreach($attributes as $attr_option => $attr_option_value) } // end if (is_array($attributes)) // now attributes have been checked and hidden and invalid ones deleted make the $products_id_string again $products_id_string = tep_get_uprid($products_id, $attributes); if ((isset($check_product) && tep_not_null($check_product)) && ($check_product[0]['products_status'] == '1')) { // EOF SPPC attribute hide check If you leave the original code in place, then everything works fine. Would be great ofcourse if somebody could help in transforming the SPPC part to be option types compatible ---------------- Thats all people, it works, everything gets displayed and calculated correctly. As I said, I posting this in the hope that somebody will put an eye on it and make all necessary corrections. Quote My community profile | Template system for osCommerce - New: Responsive | Feedback channel Link to comment Share on other sites More sharing options...
Zappo Posted January 16, 2010 Author Share Posted January 16, 2010 (edited) Hi people. There are news about merging SPPC and Option Types v2. I have it working! Great work MultiMixer! :thumbsup: When I can find the time, I'll clean up your code (make it more elegant) and create a sub-release for OptionTypes v2 (as a lot of people will want to use both contributions, including myself) Again, Nicely done! Edited January 16, 2010 by Zappo Quote Like Eek said... It never hurts to help!---------------------------------------- Link to comment Share on other sites More sharing options...
lcontreras27 Posted January 18, 2010 Share Posted January 18, 2010 Hey!, I'm sorry if I'm beeing so insistent but I really need help, if someone has the answer to my problem please tell me, help will be even more appreciated than yesterday ;) Thanks. Ok, I found my problem, it was in the paypal_standard module, thanks for your help. Quote Link to comment Share on other sites More sharing options...
Guest Posted January 19, 2010 Share Posted January 19, 2010 For the people who have problems with CUSTOMER-INPUT after logging in, I suggest re-checking the file catalog/includes/classes/shopping_cart.php The "temporary cart" get's converted (and put in the Database) from there... I have this issue and have looked and relooked the shopping cart class. Anyone want to take a stab at it? <?php /* $Id: shopping_cart.php 1739 2007-12-20 00:52:16Z hpdl $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class shoppingCart { var $contents, $total, $weight, $cartID, $content_type; function shoppingCart() { $this->reset(); } function restore_contents() { global $customer_id; if (!tep_session_is_registered('customer_id')) return false; // insert current cart contents in database if (is_array($this->contents)) { reset($this->contents); // BOF SPPC attribute hide/invalid check: loop through the shopping cart and check the attributes if they // are hidden for the now logged-in customer $this->cg_id = $this->get_customer_group_id(); while (list($products_id, ) = each($this->contents)) { // only check attributes if they are set for the product in the cart if (isset($this->contents[$products_id]['attributes'])) { $check_attributes_query = tep_db_query("select options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . tep_get_prid($products_id) . "'"); while ($_check_attributes = tep_db_fetch_array($check_attributes_query)) { $check_attributes[] = $_check_attributes; } // end while ($_check_attributes = tep_db_fetch_array($check_attributes_query)) $no_of_check_attributes = count($check_attributes); $change_products_id = '0'; foreach($this->contents[$products_id]['attributes'] as $attr_option => $attr_option_value) { $valid_option = '0'; for ($x = 0; $x < $no_of_check_attributes ; $x++) { if ($attr_option == $check_attributes[$x]['options_id'] && $attr_option_value == $check_attributes[$x]['options_values_id']) { $valid_option = '1'; if ($check_attributes[$x]['hide_attr_status'] == '1') { // delete hidden attributes from array attributes, change products_id accordingly later $change_products_id = '1'; unset($this->contents[$products_id]['attributes'][$attr_option]); } } // end if ($attr_option == $check_attributes[$x]['options_id'].... } // end for ($x = 0; $x < $no_of_check_attributes ; $x++) if ($valid_option == '0') { // after having gone through the options for this product and not having found a matching one // we can conclude that apparently this is not a valid option for this product so remove it unset($this->contents[$products_id]['attributes'][$attr_option]); // change products_id accordingly later $change_products_id = '1'; } } // end foreach($this->contents[$products_id]['attributes'] as $attr_option => $attr_option_value) if ($change_products_id == '1') { $original_products_id = $products_id; $products_id = tep_get_prid($original_products_id); $products_id = tep_get_uprid($products_id, $this->contents[$original_products_id]['attributes']); // add the product without the hidden attributes to the cart $this->contents[$products_id] = $this->contents[$original_products_id]; // delete the originally added product with the hidden attributes unset($this->contents[$original_products_id]); } } // end if (isset($this->contents[$products_id]['attributes'])) } // end while (list($products_id, ) = each($this->contents)) reset($this->contents); // reset the array otherwise the cart will be emptied // EOF SPPC attribute hide/invalid check while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (!tep_db_num_rows($product_query)) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . tep_db_input($qty) . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { //BOF - Zappo - Option Types v2 - Update query to include attribute value && Check for Uploads from customer and copy to Upload dir $uploads_query = tep_db_query("select files_uploaded_name from " . TABLE_FILES_UPLOADED . " where sesskey = '" . tep_session_id() . "'"); while ($uploads_array = tep_db_fetch_array($uploads_query)) { if (file_exists(TMP_DIR . $uploads_array['files_uploaded_name'])) { // Customer upload found in TMP dir --> Copy to Upload Dir @rename(TMP_DIR . $uploads_array['files_uploaded_name'], UPL_DIR . $uploads_array['files_uploaded_name']); // Set Customer_ID for the files that are found tep_db_query("update " . TABLE_FILES_UPLOADED . " set customers_id = '" . (int)$customer_id . "' where sesskey = '" . tep_session_id() . "' and files_uploaded_name = '" . $uploads_array['files_uploaded_name'] . "'"); } } reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attr_value = $this->contents[$products_id]['attributes_values'][$option]; tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_basket_attributes_id, customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('', '" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); //EOF - Zappo - Option Types v2 - Update query to include attribute value && Check for Uploads from customer and copy to Upload dir } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . tep_db_input($qty) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } } } // reset per-session cart contents, but not the database contents $this->reset(false); $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); while ($products = tep_db_fetch_array($products_query)) { $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']); // attributes //BOF - Zappo - Option Types v2 - 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']; // - Zappo - Option Types v2 - If attribute is Text, set additional information if ($attributes['products_options_value_id'] == OPTIONS_VALUE_TEXT_ID) { $this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text']; } //EOF - Zappo - Option Types v2 - Update query to pull attribute value_text. This is needed for text attributes. } } $this->cleanup(); } function reset($reset_database = false) { global $customer_id; $this->contents = array(); $this->total = 0; $this->weight = 0; $this->content_type = false; if (tep_session_is_registered('customer_id') && ($reset_database == true)) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'"); } unset($this->cartID); if (tep_session_is_registered('cartID')) tep_session_unregister('cartID'); } function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { global $new_products_id_in_cart, $customer_id; // BOF Separate Pricing Per Customer $this->cg_id = $this->get_customer_group_id(); // EOF Separate Pricing Per Customer $products_id_string = tep_get_uprid($products_id, $attributes); $products_id = tep_get_prid($products_id_string); if (defined('MAX_QTY_IN_CART') && (MAX_QTY_IN_CART > 0) && ((int)$qty > MAX_QTY_IN_CART)) { $qty = MAX_QTY_IN_CART; } $attributes_pass_check = true; if (is_numeric($products_id) && is_numeric($qty) && ($attributes_pass_check == true)) { // BOF SPPC attribute hide check, original query expanded to include attributes $check_product_query = tep_db_query("select p.products_status, options_id, options_values_id, IF(find_in_set('" . $this->cg_id . "', attributes_hide_from_groups) = 0, '0', '1') as hide_attr_status from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_ATTRIBUTES . " using(products_id) where p.products_id = '" . (int)$products_id . "'"); while ($_check_product = tep_db_fetch_array($check_product_query)) { $check_product[] = $_check_product; } // end while ($_check_product = tep_db_fetch_array($check_product_query)) $no_of_check_product = count($check_product); if (is_array($attributes)) { foreach($attributes as $attr_option => $attr_option_value) { $valid_option = '0'; for ($x = 0; $x < $no_of_check_product ; $x++) { if ($attr_option == $check_product[$x]['options_id'] && $attr_option_value == $check_product[$x]['options_values_id']) { $valid_option = '1'; if ($check_product[$x]['hide_attr_status'] == '1') { // delete hidden attributes from array attributes unset($attributes[$attr_option]); } } // end if ($attr_option == $check_product[$x]['options_id'].... } // end for ($x = 0; $x < $no_of_check_product ; $x++) if ($valid_option == '0') { // after having gone through the options for this product and not having found a matching one // we can conclude that apparently this is not a valid option for this product so remove it unset($attributes[$attr_option]); } } // end foreach($attributes as $attr_option => $attr_option_value) } // end if (is_array($attributes)) // now attributes have been checked and hidden and invalid ones deleted make the $products_id_string again $products_id_string = tep_get_uprid($products_id, $attributes); if ((isset($check_product) && tep_not_null($check_product)) && ($check_product[0]['products_status'] == '1')) { // EOF SPPC attribute hide check if ($notify == true) { $new_products_id_in_cart = $products_id; tep_session_register('new_products_id_in_cart'); } if ($this->in_cart($products_id_string)) { $this->update_quantity($products_id_string, $qty, $attributes); } else { $this->contents[$products_id_string] = array('qty' => (int)$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_string) . "', '" . (int)$qty . "', '" . date('Ymd') . "')"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { //BOF - Zappo - Option Types v2 - Check options loop, and add attributes accordingly... $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { //Check for Text and Upload Options if (trim($value) == NULL) { //Check if the Text Option has a value (Or is the value blank?) $blank_value = TRUE; } else { //Value is valid and contains data --> Add Text Option value $option = str_replace(TEXT_PREFIX,'',$option); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id_string]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { // If the Value is valid and Contains Data, add the option to the Cart.... $this->contents[$products_id_string]['attributes'][$option] = $value; // insert into database // - Zappo - Option Types v2 - Added products_options_value_text For saving Text and Upload Option Values 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_string) . "', '" . $option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); } //EOF - Zappo - Option Types v2 - Check options loop, and add attributes accordingly... } } } $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; $products_id_string = tep_get_uprid($products_id, $attributes); $products_id = tep_get_prid($products_id_string); if (defined('MAX_QTY_IN_CART') && (MAX_QTY_IN_CART > 0) && ((int)$quantity > MAX_QTY_IN_CART)) { $quantity = MAX_QTY_IN_CART; } $attributes_pass_check = true; //BOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric! if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { if (!is_numeric($option) || !is_numeric($value)) { $attributes_pass_check = false; break; } } } //EOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric! if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity) && ($attributes_pass_check == true)) { $this->contents[$products_id_string] = array('qty' => (int)$quantity); // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int)$quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id_string) . "'"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { //BOF - Zappo - Option Types v2 - Check options loop for Text & Uploads, and add attributes accordingly... $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { //Check for Text and Upload Options if (trim($value) == NULL) { //Check if the Text Option has a value (Or is the value blank?) $blank_value = TRUE; } else { //Value is valid and contains data --> Prepare for database $option = str_replace(TEXT_PREFIX,'',$option); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id_string]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { $this->contents[$products_id_string]['attributes'][$option] = $value; // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', 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 . "'"); } //EOF - Zappo - Option Types v2 - Check options loop for Text & Uploads, and add attributes accordingly... } } } } 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; //BOF - Zappo - Option Types v2 - ONE LINE - Add call to 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() { global $currencies; $this->total = 0; $this->weight = 0; if (!is_array($this->contents)) return 0; // BOF Separate Pricing Per Customer // global variable (session) $sppc_customer_group_id -> class variable cg_id $this->cg_id = $this->get_customer_group_id(); // EOF Separate Pricing Per Customer reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; // products price $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); if ($product = tep_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $products_weight = $product['products_weight']; // BOF Separate Pricing Per Customer $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 += $currencies->calculate_price($products_price, $products_tax, $qty); $this->weight += ($qty * $products_weight); } /// attributes price // BOF SPPC attributes mod if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); $where = " AND (("; while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $where .= "options_id = '" . (int)$option . "' AND options_values_id = '" . (int)$value . "') OR ("; } $where=substr($where, 0, -5) . ')'; $attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where .""); if (tep_db_num_rows($attribute_price_query)) { $list_of_prdcts_attributes_id = ''; // empty array $attribute_price $attribute_price = array(); while ($attributes_price_array = tep_db_fetch_array($attribute_price_query)) { $attribute_price[] = $attributes_price_array; $list_of_prdcts_attributes_id .= $attributes_price_array['products_attributes_id'].","; } if (tep_not_null($list_of_prdcts_attributes_id) && $this->cg_id != '0') { $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")"; $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $this->cg_id . "'"); while ($pag_array = tep_db_fetch_array($pag_query)) { $cg_attr_prices[] = $pag_array; } // substitute options_values_price and prefix for those for the customer group (if available) if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) { for ($n = 0 ; $n < count($attribute_price); $n++) { for ($i = 0; $i < count($cg_attr_prices) ; $i++) { if ($cg_attr_prices[$i]['products_attributes_id'] == $attribute_price[$n]['products_attributes_id']) { $attribute_price[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix']; $attribute_price[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price']; } } // end for ($i = 0; $i < count($cg_att_prices) ; $i++) } } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices)) } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') // now loop through array $attribute_price to add up/substract attribute prices for ($n = 0 ; $n < count($attribute_price); $n++) { if ($attribute_price[$n]['price_prefix'] == '+') { $this->total += $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty); } else { $this->total -= $currencies->calculate_price($attribute_price[$n]['options_values_price'], $products_tax, $qty); } } // end for ($n = 0 ; $n < count($attribute_price); $n++) } // end if (tep_db_num_rows($attribute_price_query)) } // end if (isset($this->contents[$products_id]['attributes'])) } } // EOF SPPC attributes mod // function attributes_price changed partially according to FalseDawn's post // http://www.oscommerce.com/forums/index.php?showtopic=139587 // changed completely for Separate Pricing Per Customer, attributes mod function attributes_price($products_id) { // global variable (session) $sppc_customer_group_id -> class variable cg_id $this->cg_id = $this->get_customer_group_id(); if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); $where = " AND (("; while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $where .= "options_id = '" . (int)$option . "' AND options_values_id = '" . (int)$value . "') OR ("; } $where=substr($where, 0, -5) . ')'; $attribute_price_query = tep_db_query("SELECT products_attributes_id, options_values_price, price_prefix FROM " . TABLE_PRODUCTS_ATTRIBUTES . " WHERE products_id = '" . (int)$products_id . "'" . $where .""); if (tep_db_num_rows($attribute_price_query)) { $list_of_prdcts_attributes_id = ''; while ($attributes_price_array = tep_db_fetch_array($attribute_price_query)) { $attribute_price[] = $attributes_price_array; $list_of_prdcts_attributes_id .= $attributes_price_array['products_attributes_id'].","; } if (tep_not_null($list_of_prdcts_attributes_id) && $this->cg_id != '0') { $select_list_of_prdcts_attributes_ids = "(" . substr($list_of_prdcts_attributes_id, 0 , -1) . ")"; $pag_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " where products_attributes_id IN " . $select_list_of_prdcts_attributes_ids . " AND customers_group_id = '" . $this->cg_id . "'"); while ($pag_array = tep_db_fetch_array($pag_query)) { $cg_attr_prices[] = $pag_array; } // substitute options_values_price and prefix for those for the customer group (if available) if ($customer_group_id != '0' && tep_not_null($cg_attr_prices)) { for ($n = 0 ; $n < count($attribute_price); $n++) { for ($i = 0; $i < count($cg_attr_prices) ; $i++) { if ($cg_attr_prices[$i]['products_attributes_id'] == $attribute_price[$n]['products_attributes_id']) { $attribute_price[$n]['price_prefix'] = $cg_attr_prices[$i]['price_prefix']; $attribute_price[$n]['options_values_price'] = $cg_attr_prices[$i]['options_values_price']; } } // end for ($i = 0; $i < count($cg_att_prices) ; $i++) } } // end if ($customer_group_id != '0' && (tep_not_null($cg_attr_prices)) } // end if (tep_not_null($list_of_prdcts_attributes_id) && $customer_group_id != '0') // now loop through array $attribute_price to add up/substract attribute prices for ($n = 0 ; $n < count($attribute_price); $n++) { if ($attribute_price[$n]['price_prefix'] == '+') { $attributes_price += $attribute_price[$n]['options_values_price']; } else { $attributes_price -= $attribute_price[$n]['options_values_price']; } } // end for ($n = 0 ; $n < count($attribute_price); $n++) return $attributes_price; } else { // end if (tep_db_num_rows($attribute_price_query)) return 0; } } else { // end if (isset($this->contents[$products_id]['attributes'])) return 0; } } // end of function attributes_price, modified for SPPC with attributes function get_products() { global $languages_id; // BOF Separate Pricing Per Customer $this->cg_id = $this->get_customer_group_id(); // EOF Separate Pricing Per Customer if (!is_array($this->contents)) return false; $products_array = array(); reset($this->contents); while (list($products_id, ) = each($this->contents)) { $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'"); if ($products = tep_db_fetch_array($products_query)) { $prid = $products['products_id']; $products_price = $products['products_price']; // BOF Separate Pricing Per Customer $specials_price = tep_get_products_special_price($prid); if (tep_not_null($specials_price)) { $products_price = $specials_price; } elseif ($this->cg_id != 0){ $customer_group_price_query = tep_db_query("select customers_group_price from " . TABLE_PRODUCTS_GROUPS . " where products_id = '" . (int)$prid . "' and customers_group_id = '" . $this->cg_id . "'"); if ($customer_group_price = tep_db_fetch_array($customer_group_price_query)) { $products_price = $customer_group_price['customers_group_price']; } } // EOF Separate Pricing Per Customer $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], //BOF - Zappo - Option Types v2 - ONE LINE - Include attribute value_text. This is needed for text attributes. 'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''), 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : '')); } } return $products_array; } function show_total() { $this->calculate(); return $this->total; } function show_weight() { $this->calculate(); return $this->weight; } function generate_cart_id($length = 5) { return tep_create_random_value($length, 'digits'); } function get_content_type() { $this->content_type = false; if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list(, $value) = each($this->contents[$products_id]['attributes'])) { $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['total'] > 0) { switch ($this->content_type) { case 'physical': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'virtual'; break; } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { $this->content_type = 'physical'; } return $this->content_type; } function unserialize($broken) { for(reset($broken);$kv=each($broken);) { $key=$kv['key']; if (gettype($this->$key)!="user function") $this->$key=$kv['value']; } } // added for Separate Pricing Per Customer, returns customer_group_id function get_customer_group_id() { if (isset($_SESSION['sppc_customer_group_id']) && $_SESSION['sppc_customer_group_id'] != '0') { $_cg_id = $_SESSION['sppc_customer_group_id']; } else { $_cg_id = 0; } return $_cg_id; } } ?> Quote Link to comment Share on other sites More sharing options...
fan4chevy Posted January 19, 2010 Share Posted January 19, 2010 Are there actual changes to the Ajax Attribute Manager or is it completely the same? The reason I ask is that I had already installed the latest Ajax Attrib prior to finding this mod. I am wondering if I should just leave it completely intact or should I start from scratch here? Thanks, Charles Quote Link to comment Share on other sites More sharing options...
fan4chevy Posted January 19, 2010 Share Posted January 19, 2010 Utoh! Big Stumper here! I have a modified catalog/includes/application_top.php It says to find then replace but this is over my head. Can someone show me how to properly create this page so I don't further mess the cart up? My attempt left me with errors: Modified file prior to Option Types here: <?php /* $Id: application_top.php 1833 2008-01-30 22:03:30Z hpdl $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright © 2008 osCommerce Released under the GNU General Public License */ // start the timer for the page parse time log define('PAGE_PARSE_START_TIME', microtime()); // set the level of error reporting error_reporting(E_ALL & ~E_NOTICE); // check support for register_globals if (function_exists('ini_get') && (ini_get('register_globals') == false) && (PHP_VERSION < 4.3) ) { exit('Server Requirement Error: register_globals is disabled in your PHP configuration. This can be enabled in your php.ini configuration file or in the .htaccess file in your catalog directory. Please use PHP 4.3+ if register_globals cannot be enabled on the server.'); } // Set the local configuration parameters - mainly for developers if (file_exists('includes/local/configure.php')) include('includes/local/configure.php'); // include server parameters require('includes/configure.php'); if (strlen(DB_SERVER) < 1) { if (is_dir('install')) { header('Location: install/index.php'); } } // define the project version define('PROJECT_VERSION', 'osCommerce Online Merchant v2.2 RC2a'); // some code to solve compatibility issues require(DIR_WS_FUNCTIONS . 'compatibility.php'); // set the type of request (secure or not) $request_type = (getenv('HTTPS') == 'on') ? 'SSL' : 'NONSSL';/** * USU5 function to return the base filename */ function usu5_base_filename() { // Probably won't get past SCRIPT_NAME unless this is reporting cgi location $base = new ArrayIterator( array( 'SCRIPT_NAME', 'PHP_SELF', 'REQUEST_URI', 'ORIG_PATH_INFO', 'HTTP_X_ORIGINAL_URL', 'HTTP_X_REWRITE_URL' ) ); while ( $base->valid() ) { if ( array_key_exists( $base->current(), $_SERVER ) && !empty( $_SERVER[$base->current()] ) ) { if ( false !== strpos( $_SERVER[$base->current()], '.php' ) ) { preg_match( '@[a-z0-9_]+\.php@i', $_SERVER[$base->current()], $matches ); if ( is_array( $matches ) && ( array_key_exists( 0, $matches ) ) && ( substr( $matches[0], -4, 4 ) == '.php' ) && ( is_readable( $matches[0] ) || ( false !== strpos( $_SERVER[$base->current()], 'ext/modules/' ) ) ) ) { return $matches[0]; } } } $base->next(); } // Some odd server set ups return / for SCRIPT_NAME and PHP_SELF when accessed as mysite.com (no index.php) where they usually return /index.php if ( ( $_SERVER['SCRIPT_NAME'] == '/' ) || ( $_SERVER['PHP_SELF'] == '/' ) ) { return 'index.php'; } trigger_error( 'USU5 could not find a valid base filename, please inform the developer.', E_USER_WARNING ); } // End function // set php_self in the local scope $PHP_SELF = usu5_base_filename(); if ($request_type == 'NONSSL') { define('DIR_WS_CATALOG', DIR_WS_HTTP_CATALOG); } else { define('DIR_WS_CATALOG', DIR_WS_HTTPS_CATALOG); } // include the list of project filenames require(DIR_WS_INCLUDES . 'filenames.php'); // include the list of project database tables require(DIR_WS_INCLUDES . 'database_tables.php'); // customization for the design layout define('BOX_WIDTH', 125); // how wide the boxes should be in pixels (default: 125) // include the database functions require(DIR_WS_FUNCTIONS . 'database.php'); // start indvship function tep_get_configuration_key_value($lookup) { $configuration_query_raw= tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key='" . $lookup . "'"); $configuration_query= tep_db_fetch_array($configuration_query_raw); $lookup_value= $configuration_query['configuration_value']; return $lookup_value; } // end indvship // make a connection to the database... now tep_db_connect() or die('Unable to connect to database server!'); // set the application parameters $configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION); while ($configuration = tep_db_fetch_array($configuration_query)) { define($configuration['cfgKey'], $configuration['cfgValue']); } // if gzip_compression is enabled, start to buffer the output if ( (GZIP_COMPRESSION == 'true') && ($ext_zlib_loaded = extension_loaded('zlib')) && (PHP_VERSION >= '4') ) { if (($ini_zlib_output_compression = (int)ini_get('zlib.output_compression')) < 1) { if (PHP_VERSION >= '4.0.4') { ob_start('ob_gzhandler'); } else { include(DIR_WS_FUNCTIONS . 'gzip_compression.php'); ob_start(); ob_implicit_flush(); } } else { ini_set('zlib.output_compression_level', GZIP_LEVEL); } } // set the HTTP GET parameters manually if search_engine_friendly_urls is enabled if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') { if (strlen(getenv('PATH_INFO')) > 1) { $GET_array = array(); $PHP_SELF = str_replace(getenv('PATH_INFO'), '', $PHP_SELF); $vars = explode('/', substr(getenv('PATH_INFO'), 1)); for ($i=0, $n=sizeof($vars); $i<$n; $i++) { if (strpos($vars[$i], '[]')) { $GET_array[substr($vars[$i], 0, -2)][] = $vars[$i+1]; } else { $HTTP_GET_VARS[$vars[$i]] = $vars[$i+1]; } $i++; } if (sizeof($GET_array) > 0) { while (list($key, $value) = each($GET_array)) { $HTTP_GET_VARS[$key] = $value; } } } } // define general functions used application-wide require(DIR_WS_FUNCTIONS . 'general.php'); require(DIR_WS_FUNCTIONS . 'html_output.php'); // set the cookie domain $cookie_domain = (($request_type == 'NONSSL') ? HTTP_COOKIE_DOMAIN : HTTPS_COOKIE_DOMAIN); $cookie_path = (($request_type == 'NONSSL') ? HTTP_COOKIE_PATH : HTTPS_COOKIE_PATH); // include cache functions if enabled if (USE_CACHE == 'true') include(DIR_WS_FUNCTIONS . 'cache.php'); // include shopping cart class require(DIR_WS_CLASSES . 'shopping_cart.php'); // include navigation history class require(DIR_WS_CLASSES . 'navigation_history.php'); // check if sessions are supported, otherwise use the php3 compatible session class if (!function_exists('session_start')) { define('PHP_SESSION_NAME', 'osCsid'); define('PHP_SESSION_PATH', $cookie_path); define('PHP_SESSION_DOMAIN', $cookie_domain); define('PHP_SESSION_SAVE_PATH', SESSION_WRITE_DIRECTORY); include(DIR_WS_CLASSES . 'sessions.php'); } // define how the session functions will be used require(DIR_WS_FUNCTIONS . 'sessions.php'); // set the session name and save path tep_session_name('osCsid'); tep_session_save_path(SESSION_WRITE_DIRECTORY); // set the session cookie parameters if (function_exists('session_set_cookie_params')) { session_set_cookie_params(0, $cookie_path, $cookie_domain); } elseif (function_exists('ini_set')) { ini_set('session.cookie_lifetime', '0'); ini_set('session.cookie_path', $cookie_path); ini_set('session.cookie_domain', $cookie_domain); } // set the session ID if it exists if (isset($HTTP_POST_VARS[tep_session_name()])) { tep_session_id($HTTP_POST_VARS[tep_session_name()]); } elseif ( ($request_type == 'SSL') && isset($HTTP_GET_VARS[tep_session_name()]) ) { tep_session_id($HTTP_GET_VARS[tep_session_name()]); } // start the session $session_started = false; if (SESSION_FORCE_COOKIE_USE == 'True') { tep_setcookie('cookie_test', 'please_accept_for_session', time()+60*60*24*30, $cookie_path, $cookie_domain); if (isset($HTTP_COOKIE_VARS['cookie_test'])) { tep_session_start(); $session_started = true; } } elseif (SESSION_BLOCK_SPIDERS == 'True') { $user_agent = strtolower(getenv('HTTP_USER_AGENT')); $spider_flag = false; if (tep_not_null($user_agent)) { $spiders = file(DIR_WS_INCLUDES . 'spiders.txt'); for ($i=0, $n=sizeof($spiders); $i<$n; $i++) { if (tep_not_null($spiders[$i])) { if (is_integer(strpos($user_agent, trim($spiders[$i])))) { $spider_flag = true; break; } } } } if ($spider_flag == false) { tep_session_start(); $session_started = true; } } else { tep_session_start(); $session_started = true; } if ( ($session_started == true) && (PHP_VERSION >= 4.3) && function_exists('ini_get') && (ini_get('register_globals') == false) ) { extract($_SESSION, EXTR_OVERWRITE+EXTR_REFS); } // set SID once, even if empty $SID = (defined('SID') ? SID : ''); // verify the ssl_session_id if the feature is enabled if ( ($request_type == 'SSL') && (SESSION_CHECK_SSL_SESSION_ID == 'True') && (ENABLE_SSL == true) && ($session_started == true) ) { $ssl_session_id = getenv('SSL_SESSION_ID'); if (!tep_session_is_registered('SSL_SESSION_ID')) { $SESSION_SSL_ID = $ssl_session_id; tep_session_register('SESSION_SSL_ID'); } if ($SESSION_SSL_ID != $ssl_session_id) { tep_session_destroy(); tep_redirect(tep_href_link(FILENAME_SSL_CHECK)); } } // verify the browser user agent if the feature is enabled if (SESSION_CHECK_USER_AGENT == 'True') { $http_user_agent = getenv('HTTP_USER_AGENT'); if (!tep_session_is_registered('SESSION_USER_AGENT')) { $SESSION_USER_AGENT = $http_user_agent; tep_session_register('SESSION_USER_AGENT'); } if ($SESSION_USER_AGENT != $http_user_agent) { tep_session_destroy(); tep_redirect(tep_href_link(FILENAME_LOGIN)); } } // verify the IP address if the feature is enabled if (SESSION_CHECK_IP_ADDRESS == 'True') { $ip_address = tep_get_ip_address(); if (!tep_session_is_registered('SESSION_IP_ADDRESS')) { $SESSION_IP_ADDRESS = $ip_address; tep_session_register('SESSION_IP_ADDRESS'); } if ($SESSION_IP_ADDRESS != $ip_address) { tep_session_destroy(); tep_redirect(tep_href_link(FILENAME_LOGIN)); } } // create the shopping cart & fix the cart if necesary if (tep_session_is_registered('cart') && is_object($cart)) { if (PHP_VERSION < 4) { $broken_cart = $cart; $cart = new shoppingCart; $cart->unserialize($broken_cart); } } else { tep_session_register('cart'); $cart = new shoppingCart; } // include currencies class and create an instance require(DIR_WS_CLASSES . 'currencies.php'); $currencies = new currencies(); // include the mail classes require(DIR_WS_CLASSES . 'mime.php'); require(DIR_WS_CLASSES . 'email.php'); // set the language if (!tep_session_is_registered('language') || isset($HTTP_GET_VARS['language'])) { if (!tep_session_is_registered('language')) { tep_session_register('language'); tep_session_register('languages_id'); } include(DIR_WS_CLASSES . 'language.php'); $lng = new language(); if (isset($HTTP_GET_VARS['language']) && tep_not_null($HTTP_GET_VARS['language'])) { $lng->set_language($HTTP_GET_VARS['language']); } else { $lng->get_browser_language(); } $language = $lng->language['directory']; $languages_id = $lng->language['id']; } // include the language translations require(DIR_WS_LANGUAGES . $language . '.php'); // ULTIMATE Seo Urls 5 by FWR Media if ( !isset($seo_urls) || !is_object($seo_urls) ){ include_once DIR_WS_MODULES . 'ultimate_seo_urls5' . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'usu.php'; $seo_urls = new usu($languages_id, $request_type, $session_started, $SID); } $seo_urls->initiate($SID, $languages_id, $language); // currency if (!tep_session_is_registered('currency') || isset($HTTP_GET_VARS['currency']) || ( (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') && (LANGUAGE_CURRENCY != $currency) ) ) { if (!tep_session_is_registered('currency')) tep_session_register('currency'); if (isset($HTTP_GET_VARS['currency']) && $currencies->is_set($HTTP_GET_VARS['currency'])) { $currency = $HTTP_GET_VARS['currency']; } else { $currency = (USE_DEFAULT_LANGUAGE_CURRENCY == 'true') ? LANGUAGE_CURRENCY : DEFAULT_CURRENCY; } } // navigation history if (tep_session_is_registered('navigation')) { if (PHP_VERSION < 4) { $broken_navigation = $navigation; $navigation = new navigationHistory; $navigation->unserialize($broken_navigation); } } else { tep_session_register('navigation'); $navigation = new navigationHistory; } $navigation->add_current_page(); // Shopping cart actions if (isset($HTTP_GET_VARS['action'])) { // redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled if ($session_started == false) { tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE)); } if (DISPLAY_CART == 'true') { $goto = FILENAME_SHOPPING_CART; $parameters = array('action', 'cPath', 'products_id', 'pid'); } else { $goto = basename($PHP_SELF); if ($HTTP_GET_VARS['action'] == 'buy_now') { $parameters = array('action', 'pid', 'products_id'); } else { $parameters = array('action', 'pid'); } } switch ($HTTP_GET_VARS['action']) { // customer wants to update the product quantity in their shopping cart case 'update_product' : for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) { if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) { $cart->remove($HTTP_POST_VARS['products_id'][$i]); } else { if (PHP_VERSION < 4) { // if PHP3, make correction for lack of multidimensional array. reset($HTTP_POST_VARS); while (list($key, $value) = each($HTTP_POST_VARS)) { if (is_array($value)) { while (list($key2, $value2) = each($value)) { if (ereg ("(.*)\]\[(.*)", $key2, $var)) { $id2[$var[1]][$var[2]] = $value2; } } } } $attributes = ($id2[$HTTP_POST_VARS['products_id'][$i]]) ? $id2[$HTTP_POST_VARS['products_id'][$i]] : ''; } else { $attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : ''; } $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; // customer adds a product from the products page case 'add_product' : if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) { if (tep_has_product_attributes($_POST['products_id']) && PRODUCT_LIST_OPTIONS != 'true' && basename($PHP_SELF) != FILENAME_PRODUCT_INFO) tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $_POST['products_id'])); $add_quantity = (isset($_POST['cart_quantity']) ? (int)$_POST['cart_quantity'] : 1); $cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$add_quantity, $_POST['id']); } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; // performed by the 'multi buy now' button in product listings page case 'add_multi': for ($i=0; $i<=sizeof($_POST['products_id']);$i++) { if($_POST['cart_quantity'][$i]) { $px_id = $_POST['products_id'][$i]; $cart->add_cart($px_id, $cart->get_quantity(tep_get_uprid($px_id, $_POST['id'][$px_id]))+($_POST['cart_quantity'][$i]), $_POST['id'][$px_id]); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; // performed by the 'buy now' button in product listings and review page case 'buy_now' : if (isset($HTTP_GET_VARS['products_id'])) { if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) { tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'])); } else { $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; case 'notify' : if (tep_session_is_registered('customer_id')) { if (isset($HTTP_GET_VARS['products_id'])) { $notify = $HTTP_GET_VARS['products_id']; } elseif (isset($HTTP_GET_VARS['notify'])) { $notify = $HTTP_GET_VARS['notify']; } elseif (isset($HTTP_POST_VARS['notify'])) { $notify = $HTTP_POST_VARS['notify']; } else { tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify')))); } if (!is_array($notify)) $notify = array($notify); for ($i=0, $n=sizeof($notify); $i<$n; $i++) { $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'"); $check = tep_db_fetch_array($check_query); if ($check['count'] < 1) { tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())"); } } tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify')))); } else { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } break; case 'notify_remove' : if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) { $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'"); $check = tep_db_fetch_array($check_query); if ($check['count'] > 0) { tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'"); } tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')))); } else { $navigation->set_snapshot(); tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL')); } break; case 'cust_order' : if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) { if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) { tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid'])); } else { $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1); } } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; } } // include the who's online functions require(DIR_WS_FUNCTIONS . 'whos_online.php'); tep_update_whos_online(); // include the password crypto functions require(DIR_WS_FUNCTIONS . 'password_funcs.php'); // include validation functions (right now only email address) require(DIR_WS_FUNCTIONS . 'validations.php'); // split-page-results require(DIR_WS_CLASSES . 'split_page_results.php'); // infobox require(DIR_WS_CLASSES . 'boxes.php'); // auto activate and expire banners require(DIR_WS_FUNCTIONS . 'banner.php'); tep_activate_banners(); tep_expire_banners(); // auto expire special products require(DIR_WS_FUNCTIONS . 'specials.php'); tep_expire_specials(); // calculate category path if (isset($HTTP_GET_VARS['cPath'])) { $cPath = $HTTP_GET_VARS['cPath']; } elseif (isset($HTTP_GET_VARS['products_id']) && !isset($HTTP_GET_VARS['manufacturers_id'])) { $cPath = tep_get_product_path($HTTP_GET_VARS['products_id']); } else { $cPath = ''; } if (tep_not_null($cPath)) { $cPath_array = tep_parse_category_path($cPath); $cPath = implode('_', $cPath_array); $current_category_id = $cPath_array[(sizeof($cPath_array)-1)]; } else { $current_category_id = 0; } // include the breadcrumb class and start the breadcrumb trail require(DIR_WS_CLASSES . 'breadcrumb.php'); $breadcrumb = new breadcrumb; $breadcrumb->add(HEADER_TITLE_TOP, HTTP_SERVER); $breadcrumb->add(HEADER_TITLE_CATALOG, tep_href_link(FILENAME_DEFAULT)); // add category names or the manufacturer name to the breadcrumb trail if (isset($cPath_array)) { for ($i=0, $n=sizeof($cPath_array); $i<$n; $i++) { $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$cPath_array[$i] . "' and language_id = '" . (int)$languages_id . "'"); if (tep_db_num_rows($categories_query) > 0) { $categories = tep_db_fetch_array($categories_query); $breadcrumb->add($categories['categories_name'], tep_href_link(FILENAME_DEFAULT, 'cPath=' . implode('_', array_slice($cPath_array, 0, ($i+1))))); } else { break; } } } elseif (isset($HTTP_GET_VARS['manufacturers_id'])) { $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'"); if (tep_db_num_rows($manufacturers_query)) { $manufacturers = tep_db_fetch_array($manufacturers_query); $breadcrumb->add($manufacturers['manufacturers_name'], tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'])); } } // add the products model to the breadcrumb trail if (isset($HTTP_GET_VARS['products_id'])) { $model_query = tep_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "'"); if (tep_db_num_rows($model_query)) { $model = tep_db_fetch_array($model_query); $breadcrumb->add($model['products_model'], tep_href_link(FILENAME_PRODUCT_INFO, 'cPath=' . $cPath . '&products_id=' . $HTTP_GET_VARS['products_id'])); } } // initialize the message stack for output messages require(DIR_WS_CLASSES . 'message_stack.php'); $messageStack = new messageStack; // set which precautions should be checked define('WARN_INSTALL_EXISTENCE', 'true'); define('WARN_CONFIG_WRITEABLE', 'true'); define('WARN_SESSION_DIRECTORY_NOT_WRITEABLE', 'true'); define('WARN_SESSION_AUTO_START', 'true'); define('WARN_DOWNLOAD_DIRECTORY_NOT_READABLE', 'true'); ?> ------------------------ says to do below:--------------------------- *** FIND *** case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) { $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']); *** REPLACE WITH ***: //BOF - Zappo - Option Types v2 - File uploading: Purge the Temporary Upload Dir $purgeDir = opendir(TMP_DIR) or die ('Could not open '.TMP_DIR); while ($file = readdir($purgeDir)) { if ($file != ('.htaccess') && $file != ('.') && $file != ('..') && filemtime(TMP_DIR . $file) < strtotime(OPTIONS_TYPE_PURGETIME)) { unlink(TMP_DIR . $file); // Delete file from server... tep_db_query("delete from " . TABLE_FILES_UPLOADED . " where files_uploaded_name = '" . $file . "'"); // Remove File's database entry.... } } closedir($purgeDir); //EOF - Zappo - Option Types v2 - File uploading: Purge the Temporary Upload Dir //BOF - Zappo - Option Types v2 - ONE LINE - Set real_ids for processing $real_ids = $HTTP_POST_VARS['id']; //BOF - Zappo - Option Types v2 - File uploading: save uploaded files with unique file names, in the proper folder if ($HTTP_POST_VARS['number_of_uploads'] > 0) { require(DIR_WS_CLASSES . 'upload.php'); for ($i = 1; $i <= $HTTP_POST_VARS['number_of_uploads']; $i++) { $TEMP_FILE = $_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]]; if (tep_not_null($TEMP_FILE) && $TEMP_FILE != 'none') { $products_options_file = new upload('id'); //BOF - Zappo - Option Types v2 - Set Upload directory (Registered customers in Uploads, other in Temporary folder) if (tep_session_is_registered('customer_id')) { // IF the customer is registered, use Upload Dir $products_options_file->set_destination(UPL_DIR); } else { // If the customer is not registered, use Temporary Dir $products_options_file->set_destination(TMP_DIR); } //EOF - Zappo - Option Types v2 - Set Upload directory (Registered customers in Uploads, other in Temporary folder) if ($products_options_file->parse(TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i])) { if (tep_session_is_registered('customer_id')) { tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, customers_id, files_uploaded_name, date) values('" . tep_session_id() . "', '" . $customer_id . "', '" . tep_db_input($products_options_file->filename) . "', '" . date("d-m-y") . "')"); } else { tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name, date) values('" . tep_session_id() . "', '" . tep_db_input($products_options_file->filename) . "', '" . date("d-m-y") . "')"); } //BOF - Zappo - Option Types v2 - Set File Prefix if (OPTIONS_TYPE_FILEPREFIX == 'Database') { // Database ID as File prefix $insert_id = tep_db_insert_id() . '_'; } else { // Date, time or both as File prefix (Change date formatting here) if (OPTIONS_TYPE_FILEPREFIX == 'Date' || OPTIONS_TYPE_FILEPREFIX == 'DateTime') { $insert_id = 'D'.date("d-m-y_"); } $insert_id .= (OPTIONS_TYPE_FILEPREFIX == 'DateTime' || OPTIONS_TYPE_FILEPREFIX == 'Time') ? 'T'.date("H-i_") : ''; } //EOF - Zappo - Option Types v2 - Set File Prefix // Update filename in Database with correct prefix (For comparing database names with real files) tep_db_query("update " . TABLE_FILES_UPLOADED . " set files_uploaded_name = '" . tep_db_input($insert_id . $products_options_file->filename) . "' where sesskey = '" . tep_session_id() . "' and files_uploaded_name = '" . tep_db_input($products_options_file->filename) . "' and date = '" . date("d-m-y") . "'"); $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]] = $insert_id . $products_options_file->filename; $products_options_file->set_filename($insert_id . $products_options_file->filename); if (!($products_options_file->save())) { break 2; } } else { break 2; } } else { // No file uploaded -- use previously uploaded file (From Dropdown) $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]] = $HTTP_POST_VARS[TEXT_PREFIX . UPLOAD_PREFIX . $i]; } } } //EOF - Zappo - Option Types v2 - File uploading: save uploaded files with unique file names, in the proper folder //BOF - Zappo - Option Types v2 - ONE LINE - Replace the posted array with the processed one. $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $real_ids))+1, $real_ids); Your help is deeply appreciated, Charles Quote Link to comment Share on other sites More sharing options...
Zappo Posted January 19, 2010 Author Share Posted January 19, 2010 PLEASE stop posting those giant blocks of code, and entire files here!!! I can't see Anyone reading through all that stuff to find some mistake you made, or solve your problems for you. To fan4chevy (Big Stumper): 1) Post code on this forum using the <code> tags 2) If Find and Replace is over your head, you shouldn't be doing this stuff! Educate yourself! Quote Like Eek said... It never hurts to help!---------------------------------------- Link to comment Share on other sites More sharing options...
Zappo Posted January 19, 2010 Author Share Posted January 19, 2010 I have this issue and have looked and relooked the shopping cart class. Anyone want to take a stab at it? You just proved some of my earlier comments: 1) Problems occur when merging contributions 2) Problems occur by not merging the files correctly 3) You should use a 3-way compare program to compare: Original osC file, Edited file, File to Add (You would have easily picked up the mistake(s) you made) Don't know if this will solve the problem, but below the line: //BOF - Zappo - Option Types v2 - Because of Text and Upload options, $option AND $value don't have to be numeric! You should comment out the entire check! (reason: exactly like the comment says) This stood out when I scrolled down the page, and I did not check for any other mistakes or faults... I recommend using kDiff3 when merging files. That program saved me a lot of headaches! Quote Like Eek said... It never hurts to help!---------------------------------------- Link to comment Share on other sites More sharing options...
Guest Posted January 19, 2010 Share Posted January 19, 2010 I finally have it working! What did it was this post by Multi: http://www.oscommerce.com/forums/topic/338661-contribution-option-types-v2/page__st__360__p__1475336entry1475336 Thanks Zappo, I will check out the merge tool, it probally would have saved me some frustration! Quote Link to comment Share on other sites More sharing options...
lux_interior Posted January 20, 2010 Share Posted January 20, 2010 Love this contrib - so useful! Just wondering if someone could help me out - i want to echo out all product options with prices for anytime a product listing is populated... For instance when i'm displaying a particular category, when i'm looking at new products, etc. Any help would be greatly appreciated! Quote Link to comment Share on other sites More sharing options...
fan4chevy Posted January 20, 2010 Share Posted January 20, 2010 PLEASE stop posting those giant blocks of code, and entire files here!!! I can't see Anyone reading through all that stuff to find some mistake you made, or solve your problems for you. To fan4chevy (Big Stumper): 1) Post code on this forum using the <code> tags 2) If Find and Replace is over your head, you shouldn't be doing this stuff! Educate yourself! Sorry for the large file, did not realize it would be so big. :blush: However, it's not over my head. I have been pasting and doing slight modifications for some time. However, the use of another contrib has already changed the file(s) completely that this contrib says to find and replace. This one is by far the most difficult on that particular file then I have seen. I was hoping to find assistance as this particular one does in deed have me beat. Quote Link to comment Share on other sites More sharing options...
fan4chevy Posted January 20, 2010 Share Posted January 20, 2010 On this contrib, can the text, etc. be turned off or on per product or does it show up for all products? Is there a difference in the attrib manager through this contrib vs the dedicated contrib attrib managner? Thanks again. Quote Link to comment Share on other sites More sharing options...
Zappo Posted January 20, 2010 Author Share Posted January 20, 2010 On this contrib, can the text, etc. be turned off or on per product or does it show up for all products? Is there a difference in the attrib manager through this contrib vs the dedicated contrib attrib managner? Don't know what you mean by "turned off"... They're Options (or Attributes), and can be assigned to products as such... There's no real difference in the Attribute Manager. The code is just adjusted for use with Option Types. Functionality is the same, and it is an optional feature (OptionTypes v2 works perfectly without it) Quote Like Eek said... It never hurts to help!---------------------------------------- Link to comment Share on other sites More sharing options...
fan4chevy Posted January 20, 2010 Share Posted January 20, 2010 Don't know what you mean by "turned off"... They're Options (or Attributes), and can be assigned to products as such... There's no real difference in the Attribute Manager. The code is just adjusted for use with Option Types. Functionality is the same, and it is an optional feature (OptionTypes v2 works perfectly without it) Thanks for your reply. What I mean by turned off, is that if I have a product that needs personalization, that it would have the text boxes, etc. appear for that product in product info. However, if I have lets say a bed that does not need any of the contrib that it is hidden and not showing up in product info. In regards to the attrib manager, I am wondering if I already have it installed prior to this contrib, is it necessary to redo it with this one to make it all come together with this contrib? Thank you much. Quote Link to comment Share on other sites More sharing options...
Zappo Posted January 20, 2010 Author Share Posted January 20, 2010 What I mean by turned off, is that if I have a product that needs personalization, that it would have the text boxes, etc. appear for that product in product info. However, if I have lets say a bed that does not need any of the contrib that it is hidden and not showing up in product info. In regards to the attrib manager, I am wondering if I already have it installed prior to this contrib, is it necessary to redo it with this one to make it all come together with this contrib? You assign the attributes normally (just as osCommerce's normal functionality) Just assign the proper Options (Attributes) to each product. Those will be the only ones that show up... The Attrib manager needs to be adjusted, but if I remember correctly, you can just overwrite the files inside the admin/AttribManager folder, and everything will be in place for OptionTypes v2. The other files are not changed in any way... (I suggest you make a backup of that folder, and just try it out.) Quote Like Eek said... It never hurts to help!---------------------------------------- Link to comment Share on other sites More sharing options...
lux_interior Posted January 21, 2010 Share Posted January 21, 2010 Love this contrib - so useful! Just wondering if someone could help me out - i want to echo out all product options with prices for anytime a product listing is populated... For instance when i'm displaying a particular category, when i'm looking at new products, etc. Any help would be greatly appreciated! Hey... Not sure if anyone read this - but i'd love to hear if anyone has a solution... To re-state the problem - when displaying a category page, under the price column (for example) i would like to display all the options with their price beside them. Is this something that this contrib does, or do i need to go to something like the Master Products contrib? Thanks! Quote Link to comment Share on other sites More sharing options...
Zappo Posted January 21, 2010 Author Share Posted January 21, 2010 Hey... Not sure if anyone read this - but i'd love to hear if anyone has a solution... To re-state the problem - when displaying a category page, under the price column (for example) i would like to display all the options with their price beside them. Is this something that this contrib does, or do i need to go to something like the Master Products contrib? Thanks! Option Types v2 doesn't do that "out of the box" You'll have to get (query) the Option Types from catalog/includes/modules/product_listing.php and echo them from there. I certainly wouldn't use Master Products, as that's a really big contribution, and it doesn't do what you ask (as far as I know) It also doesn't support different Option Types... Quote Like Eek said... It never hurts to help!---------------------------------------- Link to comment Share on other sites More sharing options...
multimixer Posted January 22, 2010 Share Posted January 22, 2010 There are news about merging SPPC and Option Types v2. I have it working !. Hi again people. I'm posting a second version of merging SPPC (separate pricing per customer) and OptionTypesv2. This solution here looks much nicer to me. All code alternations refer to the original files as they come with this contribution (includes/modules/option_types.php) or as they look after merging (shopping_cart.php). If you did the changes as suggested in my previous post, then please take again your "original" files Following steps: ------------------------------------------------------- 1) File includes/modules/option_types.php 1.1) after $ProdOpt_Length = $products_options_name['products_options_length']; I placed // BOF SPPC multimixer 21 1 10 $aid_query = tep_db_query("select distinct pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)tep_db_input($product_info['products_id']) . "' and pa.options_id = '" . $ProdOpt_ID . "' and pag.customers_group_id = '" . $customer_group_id . "'"); while ($aid_result = tep_db_fetch_array($aid_query)) { $ProdAtr_ID = $aid_result['products_attributes_id']; // SPPC $Attr_List .= $aid_result['products_attributes_id']. ","; // SPPC } // EOF SPPC multimixer 21 1 10 1.2) After $products_attribs_array = tep_db_fetch_array($products_attribs_query); I placed // BOF SPPC multimixer 21 1 10 if (tep_not_null($ProdAtr_ID) && $customer_group_id > 0) { // only if not retail and if attribute ID exist $pag_query = tep_db_query("select pag.products_attributes_id, pag.options_values_price, pag.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pag.products_attributes_id = " . $ProdAtr_ID . " AND customers_group_id = '" . $customer_group_id . "' and pa.options_values_id = '". $products_attribs_array['options_values_id'] ."' and pa.products_attributes_id = pag.products_attributes_id and pag.products_id = '" . (int)tep_db_input($product_info['products_id']) . "'"); while ($pag_array = tep_db_fetch_array($pag_query)) { $products_attribs_array['options_values_price'] = $pag_array['options_values_price']; $products_attribs_array['price_prefix'] = $pag_array['price_prefix']; } // end while ($pag_array = tep_db_fetch_array($pag_query)) { } // end if (tep_not_null($ProdAtr_ID) && $customer_group_id > 0) // EOF SPPC multimixer 21 1 10 1.3) After (in case OPTIONS_TYPE_RADIO:) while ($products_options_array = tep_db_fetch_array($products_options_query)) { I placed // BOF SPPC multimixer 21 1 10 if (tep_not_null($Attr_List) && $customer_group_id > 0) { // only if not retail and if attribute ID exist $select_list = "(" . substr($Attr_List, 0, -1 ) . ")"; $pag_query = tep_db_query("select pag.products_attributes_id, pag.options_values_price, pag.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pag.products_attributes_id IN " . $select_list . " AND customers_group_id = '" . $customer_group_id . "' and pa.options_values_id = '". $products_options_array['products_options_values_id'] ."' and pa.products_attributes_id = pag.products_attributes_id and pag.products_id = '" . (int)$product_info['products_id'] . "'"); while ($pag_array = tep_db_fetch_array($pag_query)) { $products_options_array['options_values_price'] = $pag_array['options_values_price']; $products_options_array['price_prefix'] = $pag_array['price_prefix']; } // end while ($pag_array = tep_db_fetch_array($pag_query)) { } // end if (tep_not_null($Attr_List) && $customer_group_id > 0) // EOF SPPC multimixer 21 1 10 1.4) After ( in case OPTIONS_TYPE_IMAGE: ) while ($products_options = tep_db_fetch_array($products_options_query)) { I placed // BOF SPPC multimixer 21 1 10 if (tep_not_null($Attr_List) && $customer_group_id > 0) { // only if not retail and if attribute ID exist $select_list = "(" . substr($Attr_List, 0, -1 ) . ")"; $pag_query = tep_db_query("select pag.products_attributes_id, pag.options_values_price, pag.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pag.products_attributes_id IN " . $select_list . " AND customers_group_id = '" . $customer_group_id . "' and pa.options_values_id = '". $products_options['products_options_values_id'] ."' and pa.products_attributes_id = pag.products_attributes_id and pag.products_id = '" . (int)$product_info['products_id'] . "'"); while ($pag_array = tep_db_fetch_array($pag_query)) { $products_options['options_values_price'] = $pag_array['options_values_price']; $products_options['price_prefix'] = $pag_array['price_prefix']; } // end while ($pag_array = tep_db_fetch_array($pag_query)) { } // end if (tep_not_null($Attr_List) && $customer_group_id > 0) // EOF SPPC multimixer 21 1 10 2) In file shopping_cart.php (main level file) 2.1) After the query $attributes = tep_db_query("select popt.products_options_name, 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 . "'"); I placed // BOF SPPC multimixer 21 1 10 $aid_query = tep_db_query("select distinct pa.products_attributes_id from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . (int)$products[$i]['id'] . "' and pa.options_id = '" . (int)$option . "' and pa.options_values_id = '" . (int)$value . "' and pag.customers_group_id = '" . $customer_group_id . "'"); while ($aid_result = tep_db_fetch_array($aid_query)) { $Attr_List .= $aid_result['products_attributes_id']. ","; } // EOF SPPC multimixer 21 1 10 2.2) After $attributes_values = tep_db_fetch_array($attributes); I placed // BOF SPPC multimixer 21 1 10 if (tep_not_null($Attr_List) && $customer_group_id > 0) { // only if not retail and if attribute ID exist $select_list = "(" . substr($Attr_List, 0, -1 ) . ")"; $pag_query = tep_db_query("select pag.products_attributes_id, pag.options_values_price, pag.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES_GROUPS . " pag, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pag.products_attributes_id IN " . $select_list . " AND customers_group_id = '" . $customer_group_id . "' and pa.options_values_id = '". (int)$value ."' and pa.products_attributes_id = pag.products_attributes_id and pag.products_id = '" . (int)$products[$i]['id'] . "'"); while ($pag_array = tep_db_fetch_array($pag_query)) { $attributes_values['options_values_price'] = $pag_array['options_values_price']; $attributes_values['price_prefix'] = $pag_array['price_prefix']; } // end while ($pag_array = tep_db_fetch_array($pag_query)) { } // end if (tep_not_null($ProdAtr_ID) && $customer_group_id > 0) // EOF SPPC multimixer 21 1 10 ------------------------------------------------- I think that this solution is much better, not only because it avoids this annoying query repeat, it also doesn't replace any original code and it has a better functionality when replacing the various prices. Regarding the correct merging of the 2 other involved fles (includes/classes/shopping_cart.php and product_info.php) read my previous post Have a nice day :) Quote My community profile | Template system for osCommerce - New: Responsive | Feedback channel Link to comment Share on other sites More sharing options...
multimixer Posted January 23, 2010 Share Posted January 23, 2010 (edited) Hi people I wanted to have the ability to choose the filtetype (.jpg or .png etc) of the image used as an option via the admin panel. I don't like it to alter the php file each time you want to change something, if you have more that one stores, this can lead to mistakes when replacing files. So, I did following 1) I run this query in my PHPMyAdmin INSERT INTO configuration VALUES ('', 'Option Type Image - image extension', 'OPTIONS_TYPE_EXTENSION', '.jpg', 'What extensions should the option type image have', (SELECT configuration_group_id FROM configuration_group WHERE configuration_group_title = 'Option Types'), '13', now(), now(), NULL, NULL); (if you run already any other sql's connected to optiontypes - appart the contribution one - then find the last sort order number you have in your table and change number 13 accordingly. If not, just run this sql) 2) In file modules/option_types.php I changed this line $Real_Image_Name = OPTIONS_TYPE_IMAGEPREFIX . $Image_Name . ((OPTIONS_TYPE_IMAGELANG == 'Yes') ? '_'.$languages_id : '') . '.jpg'; to this $Real_Image_Name = OPTIONS_TYPE_IMAGEPREFIX . $Image_Name . ((OPTIONS_TYPE_IMAGELANG == 'Yes') ? '_'.$languages_id : '') . OPTIONS_TYPE_EXTENSION; // multimixer 22 1 10 '.jpg' replaced by OPTIONS_TYPE_EXTENSION Now you just go to admin ->configuration->option types and type in the image filetype you want. It's .jpg by default. Don't forget the 'dot' infront of the filetype Edited January 23, 2010 by multimixer Quote My community profile | Template system for osCommerce - New: Responsive | Feedback channel Link to comment Share on other sites More sharing options...
Zappo Posted January 24, 2010 Author Share Posted January 24, 2010 (edited) I'm wondering that whenever i add a product with a specific attribute , it would be posseble to disable the quantity field inside the shopping_cart.php page. something like: (code) Should normaly do the trick no? however it disable all quantity field for all product. FYI: in my specific case it is for when a product has used the text attribute. You'll have to adjust the "if" statement. I believe the Text attribute (and upload & Textarea) actually have "0" as options_values_id... Edited January 24, 2010 by Zappo Quote Like Eek said... It never hurts to help!---------------------------------------- Link to comment Share on other sites More sharing options...
Zappo Posted January 24, 2010 Author Share Posted January 24, 2010 (edited) Try echo'ing the $products array (with some different products/options), and see what comes up. We'll have to find a specific item we can filter with... Ow, use print_r($products) and the <pre></pre> tags to nicely format the data... Edited January 24, 2010 by Zappo Quote Like Eek said... It never hurts to help!---------------------------------------- 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.