ows Posted April 11, 2007 Share Posted April 11, 2007 Hi everyone, I have an issue with this great contribution. I have a TEXT field calls "Other colour". When user write on this text field, i.e. "Pink", and Add to basket, this attribute is not shown on the shopping_cart.php page. Instead it shows: Enevelope - And should display: Envelope - Other colour On checkout_confirmation page it shows: Envelope - : Pink And (I think) should display: Envelope - Other colour: Pink Why is not printing the name of this attribute? Which I don't understand is that this doesn't happen when an attribute is declared as a SELECT (dropdown list). Does anyone know how can I fix this? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
ows Posted April 12, 2007 Share Posted April 12, 2007 Hi everyone,I have an issue with this great contribution. I have a TEXT field calls "Other colour". When user write on this text field, i.e. "Pink", and Add to basket, this attribute is not shown on the shopping_cart.php page. Instead it shows: Enevelope - And should display: Envelope - Other colour On checkout_confirmation page it shows: Envelope - : Pink And (I think) should display: Envelope - Other colour: Pink Why is not printing the name of this attribute? Which I don't understand is that this doesn't happen when an attribute is declared as a SELECT (dropdown list). Does anyone know how can I fix this? Thanks in advance! About this, sorry to post it when the solution was already on the forum. If you have the same problem, perhaps it is as describe the ReadMe.html file: Q. The Option name isn't being displayed in the shopping cart, order confirmation, or confirmation email? A. This almost always indicates a problem with your data. Make sure that define('PRODUCTS_OPTIONS_VALUE_TEXT_ID', 0); is set correctly in your configure.php. Also make sure that your product attribute is associated with the correct Option and Option Value. A common mistake is to associate a text Option with an Option Value other than TEXT. That fixed my problem. Thanks! Quote Link to comment Share on other sites More sharing options...
qiang Posted April 24, 2007 Share Posted April 24, 2007 Solution for Custom Text added by customer not showing in Admin Screen. I'm posting this here so that those who follow may find a quick solution. The problem is with PayPal. A detailed explanation is here: http://www.oscommerce.com/forums/index.php?showtopic=247976 Special Thanks to birchy82 & 241 They did the all the hard work. Hi, I have the same problem, but the payment methods in my store are paypal (NOT "paypal ipn") and normal bank transfer. In either case I always have the problem: Custom Text added by customer not showing in Admin Screen. Only "TEXT" is showed. Could you help me to figure out? Thanks a lot! Kevin Quote Link to comment Share on other sites More sharing options...
Macisle Posted May 16, 2007 Share Posted May 16, 2007 Hi, all. I am trying to get Option Type Feature 1.7.2 working (I used the most recent manual install instruction file) on a heavily modded store that also uses QTPro 3.1. After finishing the install procedure (including the insert_text_option_value.sql insert not found in the manual text instructions), I am getting a parse error on admin/products_attributes.php. The error is Parse error: syntax error, unexpected T_CASE in .../admin/products_attributes.php on line 47. That's right where the code says case 'add_product_option_values': I have spent some time playing with syntax to try and make QTPro (adds the special value in the code below) and OTF work together, but it's just guessing as I am not a programmer. The code below this paragraph is how things stand. Any help would be greatly appreciated. My goal is to integrate a linked non-OSC html-based shop into my OSC shop so that the OSC shop can cover everything. However, the html store sells a small number of specialty products that require a lot of user text input (10 measurements and various other text information and radio options) on the order form (currently a php order form that sends the order via an email). Thank you very much! Macisle require('includes/application_top.php'); $languages = tep_get_languages(); $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : ''); if (tep_not_null($action)) { $page_info = ''; if (isset($HTTP_GET_VARS['option_page'])) $page_info .= 'option_page=' . $HTTP_GET_VARS['option_page'] . '&'; if (isset($HTTP_GET_VARS['value_page'])) $page_info .= 'value_page=' . $HTTP_GET_VARS['value_page'] . '&'; if (isset($HTTP_GET_VARS['attribute_page'])) $page_info .= 'attribute_page=' . $HTTP_GET_VARS['attribute_page'] . '&'; if (tep_not_null($page_info)) { $page_info = substr($page_info, 0, -1); } switch ($action) { case 'add_product_options': $products_options_id = tep_db_prepare_input($HTTP_POST_VARS['products_options_id']); $option_name_array = $HTTP_POST_VARS['option_name']; $option_type = $HTTP_POST_VARS['option_type']; // Cont 160 insert - clr 030714 update to add option type to products_option $option_length = $HTTP_POST_VARS['option_length']; // Cont 160 insert - clr 030714 update to add option length to products_option $special=$HTTP_POST_VARS['special']?1:0; // QTPro 3.1 cont_888 added 113004. for ($i=0, $n=sizeof($languages); $i<$n; $i ++) { $option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]); $option_comment = $HTTP_POST_VARS['option_comment']; // Cont 160 insert -clr 030714 update to add option comment to products_option // tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, products_options_name, language_id, products_options_type, products_options_length, special, products_options_comment) values ('" . (int)$products_options_id . "', '" . tep_db_input($option_name) . "', '" . (int)$languages[$i]['id'] . "', '" . $option_type . "', '" . $option_length . "', '" . $special . "', '" . $option_comment[$languages[$i]['id']] . "')"); // QTPro 3.1 cont_888 plus cont 160 mixed entry. if($option_type != 0 && $option_type != 2){ tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " (products_options_id, products_options_values_id) values ('" . (int)$products_options_id . "', '0')"); // } tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info)); break; case 'add_product_option_values': $value_name_array = $HTTP_POST_VARS['value_name']; $value_id = tep_db_prepare_input($HTTP_POST_VARS['value_id']); $option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']); for ($i=0, $n=sizeof($languages); $i<$n; $i ++) { $value_name = tep_db_prepare_input($value_name_array[$languages[$i]['id']]); tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$value_id . "', '" . (int)$languages[$i]['id'] . "', '" . tep_db_input($value_name) . "')"); } tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " (products_options_id, products_options_values_id) values ('" . (int)$option_id . "', '" . (int)$value_id . "')"); tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info)); break; case 'add_product_attributes': $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); $options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']); $values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']); $value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']); $price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']); tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . (int)$products_id . "', '" . (int)$options_id . "', '" . (int)$values_id . "', '" . tep_db_input($value_price) . "', '" . tep_db_input($price_prefix) . "')"); if (DOWNLOAD_ENABLED == 'true') { $products_attributes_id = tep_db_insert_id(); $products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']); $products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']); $products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']); if (tep_not_null($products_attributes_filename)) { tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " values (" . (int)$products_attributes_id . ", '" . tep_db_input($products_attributes_filename) . "', '" . tep_db_input($products_attributes_maxdays) . "', '" . tep_db_input($products_attributes_maxcount) . "')"); } } tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info)); break; case 'update_option_name': $option_name_array = $HTTP_POST_VARS['option_name']; $option_type = $HTTP_POST_VARS['option_type']; // Cont 160 - clr 030714 update to add option type to products_option $option_length = $HTTP_POST_VARS['option_length']; // Cont 160 -clr 030714 update to add option length to products_option $option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']); for ($i=0, $n=sizeof($languages); $i<$n; $i ++) { $option_name = tep_db_prepare_input($option_name_array[$languages[$i]['id']]); $special=$HTTP_POST_VARS['special']?1:0; // QTPro 3.1 cont_888 added 113004. $option_comment = $HTTP_POST_VARS['option_comment']; // Cont 160 - clr 030714 update to add option comment to products_option tep_db_query("update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . tep_db_input($option_name) . "', products_options_type = '" . $option_type . "', products_options_length = '" . $option_length . "', special = '" . $special . "', products_options_comment = '" . $option_comment[$languages[$i]['id']] . "' where products_options_id = '" . (int)$option_id . "' and language_id = '" . (int)$languages[$i]['id'] . "'"); // QTPro 3.1 cont_888 mixed with cont 160. } tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info)); break; case 'update_value': $value_name_array = $HTTP_POST_VARS['value_name']; $value_id = tep_db_prepare_input($HTTP_POST_VARS['value_id']); $option_id = tep_db_prepare_input($HTTP_POST_VARS['option_id']); for ($i=0, $n=sizeof($languages); $i<$n; $i ++) { $value_name = tep_db_prepare_input($value_name_array[$languages[$i]['id']]); tep_db_query("update " . TABLE_PRODUCTS_OPTIONS_VALUES . " set products_options_values_name = '" . tep_db_input($value_name) . "' where products_options_values_id = '" . tep_db_input($value_id) . "' and language_id = '" . (int)$languages[$i]['id'] . "'"); } tep_db_query("update " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " set products_options_id = '" . (int)$option_id . "' where products_options_values_id = '" . (int)$value_id . "'"); tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info)); break; case 'update_product_attribute': $products_id = tep_db_prepare_input($HTTP_POST_VARS['products_id']); $options_id = tep_db_prepare_input($HTTP_POST_VARS['options_id']); $values_id = tep_db_prepare_input($HTTP_POST_VARS['values_id']); $value_price = tep_db_prepare_input($HTTP_POST_VARS['value_price']); $price_prefix = tep_db_prepare_input($HTTP_POST_VARS['price_prefix']); $attribute_id = tep_db_prepare_input($HTTP_POST_VARS['attribute_id']); tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set products_id = '" . (int)$products_id . "', options_id = '" . (int)$options_id . "', options_values_id = '" . (int)$values_id . "', options_values_price = '" . tep_db_input($value_price) . "', price_prefix = '" . tep_db_input($price_prefix) . "' where products_attributes_id = '" . (int)$attribute_id . "'"); if (DOWNLOAD_ENABLED == 'true') { $products_attributes_filename = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_filename']); $products_attributes_maxdays = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxdays']); $products_attributes_maxcount = tep_db_prepare_input($HTTP_POST_VARS['products_attributes_maxcount']); if (tep_not_null($products_attributes_filename)) { tep_db_query("replace into " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " set products_attributes_id = '" . (int)$attribute_id . "', products_attributes_filename = '" . tep_db_input($products_attributes_filename) . "', products_attributes_maxdays = '" . tep_db_input($products_attributes_maxdays) . "', products_attributes_maxcount = '" . tep_db_input($products_attributes_maxcount) . "'"); } } tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info)); break; case 'delete_option': $option_id = tep_db_prepare_input($HTTP_GET_VARS['option_id']); tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$option_id . "'"); tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info)); break; case 'delete_value': $value_id = tep_db_prepare_input($HTTP_GET_VARS['value_id']); tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$value_id . "'"); tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$value_id . "'"); tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " where products_options_values_id = '" . (int)$value_id . "'"); tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info)); break; case 'delete_attribute': $attribute_id = tep_db_prepare_input($HTTP_GET_VARS['attribute_id']); tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_attributes_id = '" . (int)$attribute_id . "'"); // added for DOWNLOAD_ENABLED. Always try to remove attributes, even if downloads are no longer enabled tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " where products_attributes_id = '" . (int)$attribute_id . "'"); tep_redirect(tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, $page_info)); break; } } // Begin cont 160 insert //CLR 030312 add function to draw pulldown list of option types // Draw a pulldown for Option Types function draw_optiontype_pulldown($name, $default = '') { $values = array(); $values[] = array('id' => 0, 'text' => 'Select'); $values[] = array('id' => 1, 'text' => 'Text'); $values[] = array('id' => 2, 'text' => 'Radio'); $values[] = array('id' => 3, 'text' => 'Checkbox'); $values[] = array('id' => 4, 'text' => 'Textarea'); return tep_draw_pull_down_menu($name, $values, $default); } //CLR 030312 add function to translate type_id to name // Translate option_type_values to english string function translate_type_to_name($opt_type) { if ($opt_type == 0) return 'Select'; if ($opt_type == 1) return 'Text'; if ($opt_type == 2) return 'Radio'; if ($opt_type == 3) return 'Checkbox'; if ($opt_type == 4) return 'Textarea'; return 'Error ' . $opt_type; } // End cont 160 insert ?> (I have not included all the code in the file - just what I think is relevant for my current question.) Quote Link to comment Share on other sites More sharing options...
tonybeam Posted May 20, 2007 Share Posted May 20, 2007 hello, i installed this plug-in last week and thought it was working fine at first. but, when i try to scroll through the pages of product attributes it keeps reloading page one. the URL will say: products_attributes.php?option_page=2 ...but it will still only show page one. the same goes for: products_attributes.php?option_order_by=products_options_id&value_page=2 and products_attributes.php?attribute_page=2 i currently have 13 pages of attributes and can only see the first page! anyone know what i should try? thanks! I'm having the same issue . . . I've seen others with this issue and they say it was due to the register_globals patch, but never explained how they fixed it. Any feedback is appreciated. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 29, 2007 Share Posted May 29, 2007 i've encountered this major problem Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'nobody@localhost' (Using password: NO) in /home/seantatz/public_html/cart/includes/functions/database.php on line 19 Unable to connect to database server! after i've installed this contribution. anyone wanna help me with this? i'm sure i didn't touch database.php nor did i change any passwords Quote Link to comment Share on other sites More sharing options...
psynaptic Posted May 29, 2007 Share Posted May 29, 2007 i've encountered this major problem Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'nobody@localhost' (Using password: NO) in /home/seantatz/public_html/cart/includes/functions/database.php on line 19 Unable to connect to database server! after i've installed this contribution. anyone wanna help me with this? i'm sure i didn't touch database.php nor did i change any passwords Check your settings in configure.php Quote My Profile | Contribs I like most: 'On The Fly' Auto Thumbnailer, Active Countries, Header Tags Controller, Ultimate SEO URLs, UK Based osC, UK Postcode Validation, Open Featured Sets, UK Postcode Based Carrier Shipping Link to comment Share on other sites More sharing options...
jillbalkus Posted May 31, 2007 Share Posted May 31, 2007 Hello! I have installed this contribution (v1.7.2) and am getting the following error: Parse error: parse error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in .../catalog/includes/classes/shopping_cart.php on line 867 Here's my code. Any help would be greatly appreciated! <?php /* $Id: shopping_cart.php,v 1.35 2003/06/25 21:14:33 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ class shoppingCart { var $contents, $total, $weight, $cartID, $content_type; function shoppingCart() { $this->reset(); } function restore_contents() { global $customer_id; if (!tep_session_is_registered('customer_id')) return false; // insert current cart contents in database if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; $product_query = tep_db_query("select products_id from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (!tep_db_num_rows($product_query)) { tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { //clr 031714 udate query to include attribute value. This is needed for text attributes. $attr_value = $this->contents[$products_id]['attributes_values'][$option]; tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); } } } else { tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $qty . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } } } // reset per-session cart contents, but not the database contents $this->reset(false); $products_query = tep_db_query("select products_id, customers_basket_quantity from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); while ($products = tep_db_fetch_array($products_query)) { $this->contents[$products['products_id']] = array('qty' => $products['customers_basket_quantity']); // attributes //CLR 020606 update query to pull attribute value_text. This is needed for text attributes. $attributes_query = tep_db_query("select products_options_id, products_options_value_id, products_options_value_text from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products['products_id']) . "'"); while ($attributes = tep_db_fetch_array($attributes_query)) { //CLR 020606 if text attribute, then set additional information if ($attributes['products_options_value_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) { $this->contents[$products['products_id']]['attributes_values'][$attributes['products_options_id']] = $attributes['products_options_value_text']; $this->contents[$products['products_id']]['attributes'][$attributes['products_options_id']] = $attributes['products_options_value_id']; } } $this->cleanup(); } function reset($reset_database = false) { global $customer_id; $this->contents = array(); $this->total = 0; $this->weight = 0; $this->content_type = false; if (tep_session_is_registered('customer_id') && ($reset_database == true)) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "'"); } unset($this->cartID); if (tep_session_is_registered('cartID')) tep_session_unregister('cartID'); } function add_cart($products_id, $qty = '1', $attributes = '', $notify = true) { global $new_products_id_in_cart, $customer_id; $products_id = tep_get_uprid($products_id, $attributes); if ($notify == true) { $new_products_id_in_cart = $products_id; tep_session_register('new_products_id_in_cart'); } if ($this->in_cart($products_id)) { $this->update_quantity($products_id, $qty, $attributes); } else { $this->contents[] = array($products_id); $this->contents[$products_id] = array('qty' => $qty); // insert into database if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET . " (customers_id, products_id, customers_basket_quantity, customers_basket_date_added) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . $qty . "', '" . date('Ymd') . "')"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { //CLR 020606 check if input was from text box. If so, store additional attribute information //CLR 020708 check if text input is blank, if so do not add to attribute lists //CLR 030228 add htmlspecialchars processing. This handles quotes and other special chars in the user input. $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { if (trim($value) == NULL) { $blank_value = TRUE; } else { $option = substr($option, strlen(TEXT_PREFIX)); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { $this->contents[$products_id]['attributes'][$option] = $value; // insert into database //CLR 020606 update db insert to include attribute value_text. This is needed for text attributes. //CLR 030228 add tep_db_input() processing if (tep_session_is_registered('customer_id')) tep_db_query("insert into " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " (customers_id, products_id, products_options_id, products_options_value_id, products_options_value_text) values ('" . (int)$customer_id . "', '" . tep_db_input($products_id) . "', '" . (int)$option . "', '" . (int)$value . "', '" . tep_db_input($attr_value) . "')"); } } } } $this->cleanup(); // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function update_quantity($products_id, $quantity = '', $attributes = '') { global $customer_id; if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true.. $this->contents[$products_id] = array('qty' => $quantity); // update database if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . $quantity . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { //CLR 020606 check if input was from text box. If so, store additional attribute information //CLR 030108 check if text input is blank, if so do not update attribute lists //CLR 030228 add htmlspecialchars processing. This handles quotes and other special chars in the user input. $attr_value = NULL; $blank_value = FALSE; if (strstr($option, TEXT_PREFIX)) { if (trim($value) == NULL) { $blank_value = TRUE; } else { $option = substr($option, strlen(TEXT_PREFIX)); $attr_value = htmlspecialchars(stripslashes($value), ENT_QUOTES); $value = PRODUCTS_OPTIONS_VALUE_TEXT_ID; $this->contents[$products_id]['attributes_values'][$option] = $attr_value; } } if (!$blank_value) { $this->contents[$products_id]['attributes'][$option] = $value; // update database //CLR 020606 update db insert to include attribute value_text. This is needed for text attributes. //CLR 030228 add tep_db_input() processing if (tep_session_is_registered('customer_id')) tep_db_query("update " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " set products_options_value_id = '" . (int)$value . "', products_options_value_text = '" . tep_db_input($attr_value) . "' where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "' and products_options_id = '" . (int)$option . "'"); } } } } function cleanup() { global $customer_id; //CLR 030228 add call tep_get_uprid to correctly format product ids containing quotes $products_id = tep_get_uprid($products_id, $attributes); reset($this->contents); while (list($key,) = each($this->contents)) { if ($this->contents[$key]['qty'] < 1) { unset($this->contents[$key]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($key) . "'"); } } } } function count_contents() { // get total number of items in cart $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $total_items += $this->get_quantity($products_id); } } return $total_items; } function get_quantity($products_id) { if (isset($this->contents[$products_id])) { return $this->contents[$products_id]['qty']; } else { return 0; } } function in_cart($products_id) { if (isset($this->contents[$products_id])) { return true; } else { return false; } } function remove($products_id) { global $customer_id; unset($this->contents[$products_id]); // remove from database if (tep_session_is_registered('customer_id')) { tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where customers_id = '" . (int)$customer_id . "' and products_id = '" . tep_db_input($products_id) . "'"); } // assign a temporary unique ID to the order contents to prevent hack attempts during the checkout procedure $this->cartID = $this->generate_cart_id(); } function remove_all() { $this->reset(); } function get_product_id_list() { $product_id_list = ''; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $product_id_list .= ', ' . $products_id; } } return substr($product_id_list, 2); } function calculate() { $this->total = 0; $this->weight = 0; if (!is_array($this->contents)) return 0; reset($this->contents); while (list($products_id, ) = each($this->contents)) { $qty = $this->contents[$products_id]['qty']; // products price $product_query = tep_db_query("select products_id, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'"); if ($product = tep_db_fetch_array($product_query)) { $prid = $product['products_id']; $products_tax = tep_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $products_weight = $product['products_weight']; $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows ($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } $this->total += tep_add_tax($products_price, $products_tax) * $qty; $this->weight += ($qty * $products_weight); } // attributes price if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } else { $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); } } } } } function attributes_price($products_id) { $attributes_price = 0; if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list($option, $value) = each($this->contents[$products_id]['attributes'])) { $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'"); $attribute_price = tep_db_fetch_array($attribute_price_query); if ($attribute_price['price_prefix'] == '+') { $attributes_price += $attribute_price['options_values_price']; } else { $attributes_price -= $attribute_price['options_values_price']; } } } return $attributes_price; } function get_products() { global $languages_id; 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']; $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'"); if (tep_db_num_rows($specials_query)) { $specials = tep_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => ($products_price + $this->attributes_price($products_id)), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''), 'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : '')); } } return $products_array; } function show_total() { $this->calculate(); return $this->total; } function show_weight() { $this->calculate(); return $this->weight; } function generate_cart_id($length = 5) { return tep_create_random_value($length, 'digits'); } function get_content_type() { $this->content_type = false; if ( (DOWNLOAD_ENABLED == 'true') && ($this->count_contents() > 0) ) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { if (isset($this->contents[$products_id]['attributes'])) { reset($this->contents[$products_id]['attributes']); while (list(, $value) = each($this->contents[$products_id]['attributes'])) { $virtual_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad where pa.products_id = '" . (int)$products_id . "' and pa.options_values_id = '" . (int)$value . "' and pa.products_attributes_id = pad.products_attributes_id"); $virtual_check = tep_db_fetch_array($virtual_check_query); if ($virtual_check['total'] > 0) { switch ($this->content_type) { case 'physical': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'virtual'; break; } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { switch ($this->content_type) { case 'virtual': $this->content_type = 'mixed'; return $this->content_type; break; default: $this->content_type = 'physical'; break; } } } } else { $this->content_type = 'physical'; } return $this->content_type; } function unserialize($broken) { for(reset($broken);$kv=each($broken);) { $key=$kv['key']; if (gettype($this->$key)!="user function") $this->$key=$kv['value']; } } } ?> Quote Link to comment Share on other sites More sharing options...
Guest Posted May 31, 2007 Share Posted May 31, 2007 i'm encountering a huge problem here. i have installed everything nicely but somehow my options type can't appear the way i want them to. no matter what option type i put, the results is still the same old dropdown menu defaulted by oscommerce :( i can't have radio/checkboxes which defeat the purpose of me installing this feature someone please help me??? Quote Link to comment Share on other sites More sharing options...
Jaide Posted June 2, 2007 Share Posted June 2, 2007 LOVE this contrib. Everything is excellent except for one tiny thing that is bugging me: in the order confirmation page, it is all on one line, how do I get it to break up with <br> 's like the shopping cart page does? Quote Link to comment Share on other sites More sharing options...
stuartevans Posted June 4, 2007 Share Posted June 4, 2007 Sorry to sound really THICK, I am just starting out with osCommerce and loving everything so far. I am finding my way around quite quickly. However on this contribution, which is just what I need, how do I do step 1 - in laymens terms where do I add the fields? where are the tables? The rest i think i generally understand - just stumped by the first bit Many Many Thanks Quote Link to comment Share on other sites More sharing options...
stuartevans Posted June 4, 2007 Share Posted June 4, 2007 Sorry to sound really THICK, I am just starting out with osCommerce and loving everything so far. I am finding my way around quite quickly. However on this contribution, which is just what I need, how do I do step 1 - in laymens terms where do I add the fields? where are the tables? The rest i think i generally understand - just stumped by the first bit Many Many Thanks OK DONE IT NOW THANKS IN PHPMYADMIN Quote Link to comment Share on other sites More sharing options...
Guest Posted June 4, 2007 Share Posted June 4, 2007 i'm encountering a huge problem here. i have installed everything nicely but somehow my options type can't appear the way i want them to. no matter what option type i put, the results is still the same old dropdown menu defaulted by oscommerce :( i can't have radio/checkboxes which defeat the purpose of me installing this feature someone please help me??? no one can help me? i've checked with winmerge many times but i don't see any differences except some lines have an extra spacing behind the last character but i doubt it makes any differences? Quote Link to comment Share on other sites More sharing options...
terrielee Posted June 5, 2007 Share Posted June 5, 2007 no one can help me? i've checked with winmerge many times but i don't see any differences except some lines have an extra spacing behind the last character but i doubt it makes any differences? Unless I have done it all wrong the radio buttons do not show up on the "lets see what we have here " page. It allows you to pick options on an item you have alredy chosen. ie on the product description. If this is wrong I would love to hear it because I will need to fix my error. Quote Link to comment Share on other sites More sharing options...
beachkitty85 Posted June 5, 2007 Share Posted June 5, 2007 This contribution is wonderful and I absolutely love it! With that being said, I need some help. I have a quanity box in my product_info page that no longer works after installing this contribution in combination with the file upload add on. I posted in that forum with no response so I thought I'd try my luck here. Could someone please give me a hint as to where to look. Also, is there a way to have a product option type that works as a quantity field? Quote Link to comment Share on other sites More sharing options...
beachkitty85 Posted June 5, 2007 Share Posted June 5, 2007 This contribution is wonderful and I absolutely love it! With that being said, I need some help. I have a quanity box in my product_info page that no longer works after installing this contribution in combination with the file upload add on. I posted in that forum with no response so I thought I'd try my luck here. Could someone please give me a hint as to where to look. Also, is there a way to have a product option type that works as a quantity field? I figured out the problem. In application_top.php, I changed lines 399-434 from // customer adds a product from the products page case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) { // iii 030813 added: File uploading: save uploaded files with unique file names $real_ids = $HTTP_POST_VARS['id']; 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++) { if (tep_not_null($_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]]) and ($_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]] != 'none')) { $products_options_file = new upload('id'); $products_options_file->set_destination(DIR_FS_UPLOADS); 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) values('" . tep_session_id() . "', '" . $customer_id . "', '" . tep_db_input($products_options_file->filename) . "')"); } else { tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name) values('" . tep_session_id() . "', '" . tep_db_input($products_options_file->filename) . "')"); } $insert_id = tep_db_insert_id(); $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 previous value $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]] = $HTTP_POST_VARS[TEXT_PREFIX . UPLOAD_PREFIX . $i]; } } } $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $real_ids))+1, $real_ids); // iii 030813 end of changes. } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; to // customer adds a product from the products page case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) { $qty = preg_replace('/[^0-9]/i', '', $HTTP_POST_VARS['quantity']); // iii 030813 added: File uploading: save uploaded files with unique file names $real_ids = $HTTP_POST_VARS['id']; 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++) { if (tep_not_null($_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]]) and ($_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]] != 'none')) { $products_options_file = new upload('id'); $products_options_file->set_destination(DIR_FS_UPLOADS); 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) values('" . tep_session_id() . "', '" . $customer_id . "', '" . tep_db_input($products_options_file->filename) . "')"); } else { tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name) values('" . tep_session_id() . "', '" . tep_db_input($products_options_file->filename) . "')"); } $insert_id = tep_db_insert_id(); $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 previous value $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]] = $HTTP_POST_VARS[TEXT_PREFIX . UPLOAD_PREFIX . $i]; } } } $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+ ($qty == '' || $qty < 1 ? '1' : $qty), $HTTP_POST_VARS['id']); // iii 030813 end of changes. } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; Quote Link to comment Share on other sites More sharing options...
inalilbubble Posted June 5, 2007 Share Posted June 5, 2007 I am having an issue with this contrib. It seems after 3 times uninstalling, reinstalling, manual install and file comparison I finally have a good install with no errors. However, any item in my store that has this contrib active will not add to cart. Any ideas? My shop needs to go live within the next week and this is a major issue. Your help is greatly appreciated. Quote Link to comment Share on other sites More sharing options...
inalilbubble Posted June 7, 2007 Share Posted June 7, 2007 anyone? Pleassssssssssse, live date is coming up very quickly and this is a very necessary contrib as my items are customized. Thank you!! Quote Link to comment Share on other sites More sharing options...
Guest Posted June 7, 2007 Share Posted June 7, 2007 hi, Unless I have done it all wrong the radio buttons do not show up on the "lets see what we have here " page. It allows you to pick options on an item you have alredy chosen. ie on the product description. If this is wrong I would love to hear it because I will need to fix my error. can you please explain to me what it means by "allows you to pick options on an item you have alredy chosen"? do i have to look into product_info.php? Quote Link to comment Share on other sites More sharing options...
beachkitty85 Posted June 7, 2007 Share Posted June 7, 2007 (edited) In my post #616, my code was wrong. I noticed that the files where no longer being uploaded. So, to get the quantity in product_info.php to work with Option Types 1.6 and File Uplaod .7, change lines 399-434, (the add_product case), to: // customer adds a product from the products page case 'add_product' : if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) { $qty = preg_replace('/[^0-9]/i', '', $HTTP_POST_VARS['quantity']); // iii 030813 added: File uploading: save uploaded files with unique file names $real_ids = $HTTP_POST_VARS['id']; 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++) { if (tep_not_null($_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]]) and ($_FILES['id']['tmp_name'][TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]] != 'none')) { $products_options_file = new upload('id'); $products_options_file->set_destination(DIR_FS_UPLOADS); 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) values('" . tep_session_id() . "', '" . $customer_id . "', '" . tep_db_input($products_options_file->filename) . "')"); } else { tep_db_query("insert into " . TABLE_FILES_UPLOADED . " (sesskey, files_uploaded_name) values('" . tep_session_id() . "', '" . tep_db_input($products_options_file->filename) . "')"); } $insert_id = tep_db_insert_id(); $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 previous value $real_ids[TEXT_PREFIX . $HTTP_POST_VARS[uPLOAD_PREFIX . $i]] = $HTTP_POST_VARS[TEXT_PREFIX . UPLOAD_PREFIX . $i]; } } } $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $real_ids))+($qty == '' || $qty < 1 ? '1' : $qty), $real_ids); // iii 030813 end of changes. } tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters))); break; Edited June 7, 2007 by beachkitty85 Quote Link to comment Share on other sites More sharing options...
inalilbubble Posted June 7, 2007 Share Posted June 7, 2007 Is there anyone out there that can help me? Quote Link to comment Share on other sites More sharing options...
terrielee Posted June 11, 2007 Share Posted June 11, 2007 hi, Unless I have done it all wrong the radio buttons do not show up on the "lets see what we have here " page. It allows you to pick options on an item you have alredy chosen. ie on the product description. If this is wrong I would love to hear it because I will need to fix my error. can you please explain to me what it means by "allows you to pick options on an item you have alredy chosen"? do i have to look into product_info.php? Sorry for the late reply. Yes the radio buttons (if that is what you have selected) show up on your product_info page but not on index.php. But I could have installed it wrong. Are you just looking for the radio buttons without all the other stuff if so try this (I haven't tried it yet) http://www.oscommerce.com/forums/index.php?sho...174168&st=0 Quote Link to comment Share on other sites More sharing options...
terrielee Posted June 11, 2007 Share Posted June 11, 2007 Is there anyone out there that can help me? Did you get your help yet? Quote Link to comment Share on other sites More sharing options...
IlColosso Posted June 13, 2007 Share Posted June 13, 2007 Hi there. I'm having troubles with this contribution. Everytime I edit a product, after I update it, the option type feature gets deleted on that product. So I have to go to products attributes, and add it once again. Also, is there any way I can quickly add this option type attributes to all my listings? I have near 1000 products and need to add 2 options, so repeating the process 2000 times it's kinda frustrating. Any tip? Thanks Quote Link to comment Share on other sites More sharing options...
aegrnberg Posted June 16, 2007 Share Posted June 16, 2007 First of all, just wanted to say thank you for this awesome contribution! Has anyone been able to get this to work with Order Re-Order? http://www.oscommerce.com/community/contributions,3407 On general.php, this is what I've got so far... while ($attribute = tep_db_fetch_array($attributes_query)) { //$attributes[$attribute['products_options_id']] = $attribute['products_options_values_id']; //clr 030714 determine if attribute is a text attribute and assign to $attr_value temporarily if ($attribute['products_options_values_id'] == PRODUCTS_OPTIONS_VALUE_TEXT_ID) { $attr_value = $attributes[$attribute['orders_products_attributes_id']]; //need to fix this line to show text attributes } else { $attr_value = $attribute['products_options_values_id']; } $attributes[$attribute['products_options_id']] = $attr_value; //end option type feature $attributes_count++; } //end while if ($attributes_count < 1) { $result .= 'Item: ' . $ordered_product['products_id'] . ' [' . $ordered_product['products_model'] . '] > ' . $ordered_product['products_name'] . ': Attributes changed<br>'; } This line is obviously not working, but I don't know how to fix it... can anybody help me? Thanks in advance...! $attr_value = $attributes[$attribute['orders_products_attributes_id']]; //need to fix this line to show text attributes Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.