Jan Zonjee Posted June 12, 2008 Share Posted June 12, 2008 I had installed QBP 1.3.4 but I have problems to put it together with the product_sort contrib. Many things overlap. The storefront is fine so far. In the admin I become following error: 1109 - Unknown table 'pd' in field list select pd.products_name, pd.products_description, pd.products_head_title_tag, pd.products_head_desc_tag, pd.products_head_keywords_tag, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, products_qty_blocks, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id, p.products_sort_order, ptdc.discount_categories_id from products p left join products_to_discount_categories ptdc on p.products_id = ptdc.products_id where p.products_id = '0' Indeed, the table products_description is not in the list of tables that have to be used in this query. Probably something like on p.products_id = ptdc.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); [TEP STOP] I have installed the price_break.sql but I'm not sure about this in the readme: alter table products add column products_price1 decimal(15,4) not null default 0.0; alter table products add column products_price2 decimal(15,4) not null default 0.0; alter table products add column products_price3 decimal(15,4) not null default 0.0; Must I also insert this above? No, those alter table statements are already executed when you used price_break.sql. You can't do it twice. You can try but it won't work :) Quote Link to comment Share on other sites More sharing options...
jragonzero Posted June 12, 2008 Share Posted June 12, 2008 hello First off I'd like to say that this thread has solved every single one of my errors I've gotten today while installing this contribution! Thanks!! It looks like everything is working well, except I found this weird thing. When I add items to cart and then go to check out, it asks me to register or log in. When I log in, the next screen should be the nexx step of the check out, however it brings me back to the homepage of the store instead. Everything is still in my cart and I'm still logged in. This didn't happen before today, which is installing this contribution. How do I avoid this detour?! Did something change when I installed QPBPP? THANKS! Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted June 12, 2008 Share Posted June 12, 2008 It looks like everything is working well, except I found this weird thing. When I add items to cart and then go to check out, it asks me to register or log in. When I log in, the next screen should be the nexx step of the check out, however it brings me back to the homepage of the store instead. Everything is still in my cart and I'm still logged in. This didn't happen before today, which is installing this contribution. How do I avoid this detour?! Did something change when I installed QPBPP? I don't see how QPBPP should have done that. The code responsible for that is found in login.php and first checks the email address and password and then looks for the information in the session from which page you navigated there: // restore cart contents $cart->restore_contents(); if (sizeof($navigation->snapshot) > 0) { $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']); $navigation->clear_snapshot(); tep_redirect($origin_href); } else { tep_redirect(tep_href_link(FILENAME_DEFAULT)); } You could echo $_SESSION in the footer to see if you can see something there. The snapshot['page'] should be checkout_shipping.php echo '<pre>'; print_r($_SESSION); Quote Link to comment Share on other sites More sharing options...
Tom14 Posted June 13, 2008 Share Posted June 13, 2008 Hi, Jan. Thanks, but my english is not the best. :blush: I had changed some code in the categories, but the same error. This is the section: // EOF qpbpp // BOF Product Sort $products_sort_order = $HTTP_POST_VARS['products_sort_order']; } else { // BOF qpbpp $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_head_title_tag, pd.products_head_desc_tag, pd.products_head_keywords_tag, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_qty_blocks, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id, ptdc.discount_categories_id, p.products_sort_order from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc on p.products_id = ptdc.products_id left join " . TABLE_DISCOUNT_CATEGORIES . " dc using(discount_categories_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); // EOF qpbpp // EOF Product Sort $product = tep_db_fetch_array($product_query); // HTC EOC and // BOF Product Sort // BOF qpbpp //$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id, p.products_sort_order from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name"); $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_qty_blocks, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p2c.categories_id, ptdc.discount_categories_id, dc.discount_categories_name, p.products_sort_order from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc on p.products_id = ptdc.products_id left join " . TABLE_DISCOUNT_CATEGORIES . " dc using(discount_categories_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and pd.products_name like '%" . tep_db_input($search) . "%' order by pd.products_name"); // EOF qpbpp } else { // BOF qpbpp //$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.products_sort_order from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name"); $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_quantity, p.products_image, p.products_price, p.products_qty_blocks, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, ptdc.discount_categories_id, dc.discount_categories_name, p.products_sort_order from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc on p.products_id = ptdc.products_id left join " . TABLE_DISCOUNT_CATEGORIES . " dc using(discount_categories_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$current_category_id . "' order by pd.products_name"); // EOF qpbpp // EOF Product Sort Indeed, the table products_description is not in the list of tables that have to be used in this query. Probably something like on p.products_id = ptdc.products_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); [TEP STOP] Do you mean it gives a chance to work? Quote Link to comment Share on other sites More sharing options...
Sunny_Smarty Posted June 13, 2008 Share Posted June 13, 2008 Hallo Jan, I installed the qpbpp contrib and it works very well. Only one problem occurs, if I want to edit my products in the admin area. When I set up a new product, I am able to set the price breaks and the min qty. The data are correctly stored in the database-table and shown in the customers area. But when I try to edit my product description, price or image, these data aren't shown in the admin qpbpp-table. (The table is emty and waits on new input) When I try to update my changes to the store, the price breaks are gone. (deleted from the table! :huh:) Okay, it is possible to reenter the price-breaks again and again, but this surely is not the way qpbpp should work, isn't it? Do you have an idea how to fix this problem? Many thanks in advance Sunny Quote Link to comment Share on other sites More sharing options...
Sunny_Smarty Posted June 13, 2008 Share Posted June 13, 2008 Hi again, it seems that the effect describe above has anything to to with the reading from the database table and the line (#724 in my categories.php script): if(is_array($price_breaks_array) && array_key_exists($count, $price_breaks_array)) { echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price' . $count, $price_breaks_array[$count]['products_price'], 'size="10"'); echo tep_draw_separator('pixel_trans.gif', '24', '15') . TEXT_PRODUCTS_QTY; echo tep_draw_separator('pixel_trans.gif', '24', '15') . tep_draw_input_field('products_qty' . $count, $price_breaks_array[$count]['products_qty'], 'size="10"'); echo tep_draw_separator('pixel_trans.gif', '24', '15') . tep_draw_checkbox_field('products_delete' . $count, 'y', false) . TEXT_PRODUCTS_DELETE; } else { echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_price' . $count, '', 'size="10"'); echo tep_draw_separator('pixel_trans.gif', '24', '15') . TEXT_PRODUCTS_QTY; echo tep_draw_separator('pixel_trans.gif', '24', '15') . tep_draw_input_field('products_qty' . $count, '', 'size="10"'); } thereafter the table is formed, in which you set up the price breaks (which is emty at all) When I disable the "if"-clause I get an admin-view as in the preview image that came with the contrib, but without any data in the fields. But the preview (price breaks) of the edited article is okay. Have you any hint for me to correct this ? Thanks Quote Link to comment Share on other sites More sharing options...
jragonzero Posted June 13, 2008 Share Posted June 13, 2008 I don't see how QPBPP should have done that. The code responsible for that is found in login.php and first checks the email address and password and then looks for the information in the session from which page you navigated there: // restore cart contents $cart->restore_contents(); if (sizeof($navigation->snapshot) > 0) { $origin_href = tep_href_link($navigation->snapshot['page'], tep_array_to_string($navigation->snapshot['get'], array(tep_session_name())), $navigation->snapshot['mode']); $navigation->clear_snapshot(); tep_redirect($origin_href); } else { tep_redirect(tep_href_link(FILENAME_DEFAULT)); } You could echo $_SESSION in the footer to see if you can see something there. The snapshot['page'] should be checkout_shipping.php echo '<pre>'; print_r($_SESSION); hey Jan, Thanks for the reply. I still haven't figured this part out yet, but more importantly it works. So that is good. Just had another quick question. I have one of the products using the QPBPP, I'm wondering how to get the price box aligned to the left. Right now it's aligned to the right. Please see screenshot. This seems like an easy question, I figured it'd be in product_info.php but I can't seem to move that box. I can move everything else on that page though... THANKS! Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted June 13, 2008 Share Posted June 13, 2008 This seems like an easy question, I figured it'd be in product_info.php but I can't seem to move that box. I can move everything else on that page though... In a regular page the box ($products_price) is in a table cell that has an align="right" ...: <table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading" valign="top"><?php echo $products_name; ?></td> <td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted June 13, 2008 Share Posted June 13, 2008 Have you any hint for me to correct this ? Seems that the $price_breaks_array is empty, so the most logical explanation would be that the query to get those is either not there or misplaced. Should be somewhere close to the (HTML) start of the page: $pInfo->objectInfo($product); // BOF qpbpp $price_breaks_array = array(); $price_breaks_query = tep_db_query("select products_price, products_qty from " . TABLE_PRODUCTS_PRICE_BREAK . " where products_id = '" . tep_db_input($pInfo->products_id) . "' order by products_qty"); while ($price_break = tep_db_fetch_array($price_breaks_query)) { $price_breaks_array[] = $price_break; } // EOF qpbpp Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted June 13, 2008 Share Posted June 13, 2008 Do you mean it gives a chance to work? I miss this one about 55-60% down the page: // BOF qpbpp //$product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'"); $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_qty_blocks, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id, ptdc.discount_categories_id, dc.discount_categories_name from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc on p.products_id = ptdc.products_id left join " . TABLE_DISCOUNT_CATEGORIES . " dc using(discount_categories_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'"); // EOF qpbpp $product = tep_db_fetch_array($product_query); $pInfo = new objectInfo($product); $products_image_name = $pInfo->products_image; } $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product'; Quote Link to comment Share on other sites More sharing options...
Tom14 Posted June 14, 2008 Share Posted June 14, 2008 (edited) I miss this one about 55-60% down the page: // BOF qpbpp //$product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'"); $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_qty_blocks, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id, ptdc.discount_categories_id, dc.discount_categories_name from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc on p.products_id = ptdc.products_id left join " . TABLE_DISCOUNT_CATEGORIES . " dc using(discount_categories_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "'"); // EOF qpbpp $product = tep_db_fetch_array($product_query); $pInfo = new objectInfo($product); $products_image_name = $pInfo->products_image; } $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product'; This is the one. The first part I have wrote above. I DELETE the code with the // Then I insert the product_sort_order and the other language command in the end // EOF qpbpp // BOF Product Sort $products_sort_order = $HTTP_POST_VARS['products_sort_order']; } else { // BOF qpbpp $product_query = tep_db_query("select p.products_id, pd.language_id, pd.products_name, pd.products_description, pd.products_head_title_tag, pd.products_head_desc_tag, pd.products_head_keywords_tag, pd.products_url, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_qty_blocks, p.products_weight, p.products_date_added, p.products_last_modified, p.products_date_available, p.products_status, p.manufacturers_id, ptdc.discount_categories_id, p.products_sort_order from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_DISCOUNT_CATEGORIES . " ptdc on p.products_id = ptdc.products_id left join " . TABLE_DISCOUNT_CATEGORIES . " dc using(discount_categories_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); // EOF qpbpp // EOF Product Sort $product = tep_db_fetch_array($product_query); // HTC EOC $pInfo = new objectInfo($product); $products_image_name = $pInfo->products_image; } $form_action = (isset($HTTP_GET_VARS['pID'])) ? 'update_product' : 'insert_product'; When I try to use admin/categories from your contrib I get following error: Fatal error: Call to undefined function: tep_hide_session_id() in /var/www/vhosts/xxx.de/httpdocs/admin/categories.php on line 919 Edited June 14, 2008 by Tom14 Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted June 14, 2008 Share Posted June 14, 2008 When I try to use admin/categories from your contrib I get following error: Fatal error: Call to undefined function: tep_hide_session_id() in /var/www/vhosts/xxx.de/httpdocs/admin/categories.php on line 919 That is because you are working with an older version of osC. In the later versions this function which has always been there on the catalog side (includes/functions/general.php) was also added on the admin side (same file). Quote Link to comment Share on other sites More sharing options...
Sunny_Smarty Posted June 14, 2008 Share Posted June 14, 2008 Hallo Jan, many thanks for your comment. Now it really works very well (I hope so, cause I did not test everything 'till now). You were right, the fault was in the area you suggested, but it was two lines above, which I had marked as a comment. So the elseif-clause which I assume is the normal route through the php-script was missing. I'm happy that it works now... With best greating to the netherlands (who will win the EM final, if they continue to play football like orange devils) Martin Quote Link to comment Share on other sites More sharing options...
Tom14 Posted June 14, 2008 Share Posted June 14, 2008 That is because you are working with an older version of osC. In the later versions this function which has always been there on the catalog side (includes/functions/general.php) was also added on the admin side (same file). So I made the upgrade from MS 2.2 to RC 1 (Add the Session ID to GET Based Forms) With your admin/categories from the contrib seems now to work But with my categories is the same 1109 error :angry: Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted June 14, 2008 Share Posted June 14, 2008 But with my categories is the same 1109 error :angry: Who is messing up that code then? Look here: " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'"); - You are missing a = here: p.products_id '" . (int)$HTTP_GET_VARS['pID'] . "' - You reversed the where clause (in the code p.products_id = pd.products_id comes first, don't know if that makes a difference though) and then - you add pd.language_id = '" . (int)$languages_id . "' whereas the code leaves that out to get the product description in all available languages. If there is someone you should be angry at, it is you :) Quote Link to comment Share on other sites More sharing options...
jragonzero Posted June 23, 2008 Share Posted June 23, 2008 Hello Jan Z, I have yet another problem, and would very much appreciate some help! the QPBPP contribution works perfectly! However I also integrated another contribution into the store that edits some of the same code. Namely the "update_quantity" function. The other contribution is product attributes found here: http://www.oscommerce.com/community/contributions,160 (I don't know if you service other contributions, but if you do, THANKS!) As you can see, the author made a new post for a bug fix. The feature I need from that contribution is the text box attribute, where customers can enter a custom length for their product Now with the previous installment, the custom length showed up but whenever you hit "update", all the custom lengths gets deleted (product stays in cart though). So with the new fix, the author alters the "update_quantity" function. I noticed the QPBPP contribution also alters this function, so I used the hotfix for the update error and then reapplied the QPBPP edits to that function. This is the code before the hotfix: function update_quantity($products_id, $quantity = '', $attributes = '', $discount_categories_id = NULL) { // EOF qpbpp 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); // BOF qpbpp $this->contents[$products_id] = array('qty' => (int)$quantity, 'discount_categories_id' => $discount_categories_id); // EOF qpbpp // 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 . "'"); } } } } Here's the code after the hotfix and QPBPP edit: function update_quantity($products_id, $quantity = '', $attributes = '', $discount_categories_id = NULL) { // EOF qpbpp global $customer_id; if (empty($quantity)) return true; // nothing needs to be updated if theres no quantity, so we return true.. // BOF qpbpp $this->contents[$products_id_string] = array('qty' => (int)$quantity, 'discount_categories_id' => $discount_categories_id); // EOF qpbpp // 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)) { // BOM - Options Catagories $attr_value = NULL; if ( !is_array($value) ) { $this->contents[$products_id]['attributes'][$option] = $value; $attr_value = $value; 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 . "'"); } elseif ( isset($attributes[$option]['t']) && !empty($attributes[$option]['t']) ) { $this->contents[$products_id]['attributes'][$option] = $value; $attr_value = htmlspecialchars(stripslashes($attributes[$option]['t']), ENT_QUOTES); 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 . "'"); } elseif ( isset($attributes[$option]['c']) ) { $this->contents[$products_id]['attributes'][$option] = $value; foreach ($value as $v) { $attr_value = $v; 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 . "'"); } } // EOM - Options Catagories } } } So the hotfix fixes the original problem with the updating. However, the product with the price break level no longer register the discount, and the discount is not applied to the final price for that product. Furthermore, when you click "update" it adds a new blank entry into the cart at the quantity of the product with the price break. So for example, I add an item with 10 for quanitity. The discount doesn't not apply and when i hit the update button, I get a new product entry, with no product name, and a 10 for quantity. Please HELP!! Thanks for reading Quote Link to comment Share on other sites More sharing options...
jragonzero Posted June 23, 2008 Share Posted June 23, 2008 (edited) Hello Jan Z, I've been testing the store, and everything actually.. seem to check out so far! I think this is too good to be true but I can't find any errors yet. To the above post I made, I used the hotfix but did NOT apply the QPBPP edits to that function and placed orders and everything checks out. Price breaks register, and updates do not erase the custom lengths (text box inputs). I suspect there must be something wrong by not including those 2 edits from your file. This is the current code: 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]['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)) { // BOM - Options Catagories $attr_value = NULL; if ( !is_array($value) ) { $this->contents[$products_id]['attributes'][$option] = $value; $attr_value = $value; 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 . "'"); } elseif ( isset($attributes[$option]['t']) && !empty($attributes[$option]['t']) ) { $this->contents[$products_id]['attributes'][$option] = $value; $attr_value = htmlspecialchars(stripslashes($attributes[$option]['t']), ENT_QUOTES); 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 . "'"); } elseif ( isset($attributes[$option]['c']) ) { $this->contents[$products_id]['attributes'][$option] = $value; foreach ($value as $v) { $attr_value = $v; 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 . "'"); } } // EOM - Options Catagories } } } I'm still testing the store, but will there be any errors by not including: // BOF qpboo function update_quantity($products_id, $quantity = '', $attributes = '', $discount_categories_id = NULL) { // EOF qpbpp and // BOF qpbpp $this->contents[$products_id_string] = array('qty' => (int)$quantity, 'discount_categories_id' => $discount_categories_id); // EOF qpbpp Thanks again Edited June 23, 2008 by jragonzero Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted June 23, 2008 Share Posted June 23, 2008 However, the product with the price break level no longer register the discount, and the discount is not applied to the final price for that product. Since you use $products_id_string but did not include these two lines: $products_id_string = tep_get_uprid($products_id, $attributes); $products_id = tep_get_prid($products_id_string); I can imagine things go wrong. Actually, I cannot understand why people "updating" that contribution are unable to use the code that is already in that function for a couple of years. They are still meddling on with the old code... .total mess. I used this 1.5 years ago (obviously without QPBPP added) 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); $attributes_pass_check = true; if (is_array($attributes)) { reset($attributes); while (list($option, $value) = each($attributes)) { // Option Type Feature 1.7.2: let text attributes pass if (strstr($option, TEXT_PREFIX)) { continue; } if (!is_numeric($option) || !is_numeric($value)) { $attributes_pass_check = false; break; } } } 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' => $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 Option Type Feature, reversing of products_id and $products_id_string as in the original // contribution (version 1.7.2 at least) is not added here //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_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_string) . "' and products_options_id = '" . (int)$option . "'"); } // end if (!$blank_value) EOF Option Type Feature } } } } Quote Link to comment Share on other sites More sharing options...
jragonzero Posted June 24, 2008 Share Posted June 24, 2008 Hi Jan Z, Thank you for your reply. As you may be able to tell, I dont know squat about php or oscommerce. The most I can do is copy and paste code from people's contribution instructions. As I've mentioned in my 2nd post, everything seems to be working fine with the hotfix but NO QPBPP revision to it. The 2 line edits that include the discount_category_id is not in that function at all! How can it work still?! Would you suggest I use your code from 1.5 years ago and then add // BOF qpboo function update_quantity($products_id, $quantity = '', $attributes = '', $discount_categories_id = NULL) { // EOF qpbpp and // BOF qpbpp $this->contents[$products_id_string] = array('qty' => (int)$quantity, 'discount_categories_id' => $discount_categories_id); // EOF qpbpp Thanks again Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted June 24, 2008 Share Posted June 24, 2008 Would you suggest I use your code from 1.5 years ago and then add Never mind then. Just use the code after the "hotfix" in this post of you and use // BOF qpbpp $this->contents[$products_id] = array('qty' => (int)$quantity, 'discount_categories_id' => $discount_categories_id); // EOF qpbpp (so $products_id instead of $products_id_string as you had before too by the way. Quote Link to comment Share on other sites More sharing options...
alarsdes Posted June 24, 2008 Share Posted June 24, 2008 I am trying to install the QPb Contribution. Wenn duplicating a product I get this message 1136 - Column count doesn't match value count at row 1 insert into products (products_quantity, products_model, products_image, products_price, products_date_added, products_date_available, products_weight, products_status,products_carrot, products_tax_class_id, manufacturers_id, tnt_f_tr, tnt_f_sb, tnt_f_cs, products_qty_blocks) values ('100', 'Fotopapier 135 grm', 'LP141.gif', '6.3570', now(), null, '0.00', '0', '0', '0', '1', '20', '3', '0', '0', '1') [TEP STOP] tep_db_query("insert into " . TABLE_PRODUCTS . " (products_quantity, products_model, products_image, products_price, products_date_added, products_date_available, products_weight, products_status,products_carrot, products_tax_class_id, manufacturers_id, tnt_f_tr, tnt_f_sb, tnt_f_cs, products_qty_blocks) values ('" . tep_db_input($product['products_quantity']) . "', '" . tep_db_input($product['products_model']) . "', '" . tep_db_input($product['products_image']) . "', '" . tep_db_input($product['products_price']) . "'" . ", now(), " . (empty($product['products_date_available']) ? "null" : "'" . tep_db_input($product['products_date_available']) . "'") . ", '" . tep_db_input($product['products_weight']) . "', '0', '" . (int)$product['products_carrot'] . "', '0', '" . (int)$product['products_tax_class_id'] . "', '" . (int)$product['manufacturers_id'] . "', '" . tep_db_input($product['tnt_f_tr']) . "', '" . tep_db_input($product['tnt_f_sb']). "', '" . tep_db_input($product['tnt_f_cs']) . "', '" . tep_db_input($product['products_qty_blocks']) . "')"); I think this is the problem. But I can\t seem to find out what is wrong Please let me know what's wrong BVD Ton Quote Link to comment Share on other sites More sharing options...
jragonzero Posted June 24, 2008 Share Posted June 24, 2008 Hey Jan Z, Thanks again for replying. Alright, I've extensively tested this part. And I found an error... it actually doesn't have to do anything with the price break discounts or anything. so I'm not sure if you're willing to troubleshoot it. But thanks in advance for reading =) the custom text box input works through almost every combinations of updating and whatnot. The error is, when you add to cart, with a custom text input, and you sign in or register.. and then you log out, and log back in, the custom inputs are GONE! This doesn't happen until you log out and log back in. If you don't do that, everything goes right. Again this is with the "working" code I mentioned earlier, with the hotfix and no QPBPP revision. So I tried a combination of codes from the one I use to have, your 1.5 yr old code, both with and without the QPBPP edits, both with and without "_string" after "$products_id" and they all have various errors from custom input text disappearing, to duplicating products, to not updating the quantities. I'm stuck now, customers will add things to car, log in. And then log out just to come back an hour or 30min later to complete the order. At which point they will find out that all the custom lengths they've entered are all reset to blank. what to do? =\ Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted June 24, 2008 Share Posted June 24, 2008 So I tried a combination of codes from the one I use to have, your 1.5 yr old code, both with and without the QPBPP edits, both with and without "_string" after "$products_id" and they all have various errors from custom input text disappearing, to duplicating products, to not updating the quantities. I didn't mention I have tried to add this to a test site that uses SPPC (Separate Pricing Per Customer) which also makes a number of complicated changes in attributes which can be hidden for user groups etc. I then noticed the complete rubbish that people have made of the Option Type Feature contribution. I also made changes in the add_cart function to not save empty text attributes to the database (pure nonsense). That might explain why my 1.5 yr old code is not working in your shop because the accompanying changes in add_cart are not there. Since SPPC also modifies the shopping_cart class extensively it would take more than copy and paste to extract the better working OTF code from that.... Actually I stopped working on it when the last page had to be updated to SPPC: product_info.php which is also rather large in OTF. Quote Link to comment Share on other sites More sharing options...
petercascio Posted June 28, 2008 Share Posted June 28, 2008 OK -- so this is probably a stoopid question: does the latest QPB work with oscommerce-2.2ms2-060817 or should I use an older version... As I wrote, probably a stoopid question but I thought I'd better ask it before I leap in and install it. Peter :blink: Quote Link to comment Share on other sites More sharing options...
Jan Zonjee Posted June 28, 2008 Share Posted June 28, 2008 OK -- so this is probably a stoopid question: does the latest QPB work with oscommerce-2.2ms2-060817 or should I use an older version... As I wrote, probably a stoopid question but I thought I'd better ask it before I leap in and install it. Perhaps not completely but that shouldn't be a reason not to use it. There was a change in the way a price is calculated somewhere along the updates, but I don't remember in which version this change was made. If that is so, you might get an error about a missing function in the class currencies I believe. Only a few lines to add, so no show-stopper (and I'm not even sure you will have that error). 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.