protokop Posted November 26, 2004 Posted November 26, 2004 (edited) I got a version of OSC with minor changes. It had the Improve Product Attributes/Item Editor already installed, with a minor mod to the publicly released verions (check boxes instead of a list). Now I really need that for my store, and I also need something to add items to multiple categories. I got the Multiple Categories per product quick entry contribution, and added it to the already modded categories.php They both appear to work (almost). My problem is that now with my attributes, only the selected check boxes before a unchecked box is actually saved. This is a problem as I have two categories of atributes, both with numerous entries. I have noticed that it will save a checked box if there is one unchecked box between the checked boxes, but if there is two or more, then only the first is saved. I need it to be able to cope with a large amount of unchecked boxes between checked ones. I think i have narrowed the problem down to this piece of code.... ? ? ? ? ?// Improve Product Attributes/Item Editor begin if ( isset($pID) && $pID != '' ) { tep_db_query("DELETE FROM products_attributes WHERE products_id = " . $pID); for ($i = 0, $n = sizeof($attributes); $i < $n; $i++) { ? $values = split("_", $attributes[$i]); /* Revision by RE ? ? ?Since all array elements are passed from the hidden fields we need a way to add only the populated ones. ? ?---> IF AFTER THE SPLIT $values[0] (options_id) IS NOT SET THEN DO NOT INSERT THE ARRAY INTO THE products_attributes TABLE */ ? if($values[0] !== ""){ // Added by SP beg ? if($values[2] == "" && $values[3] == "") { // ? ? tep_db_query("INSERT INTO products_attributes (products_id, options_id, options_values_id, options_values_price, price_prefix) VALUES (" . $pID . ", '" . $values[0] . "', '" . $values[1] . "','". $att_price[$x]. "','". $plus[$x]. "')"); ? ? tep_db_query("INSERT INTO products_attributes (products_id, options_id, options_values_id, options_values_price, price_prefix) VALUES (" . $pID . ", '" . $values[0] . "', '" . $values[1] . "','". $att_price[$i]. "','". $plus[$i]. "')"); ? } else { ? ? $values[2] = "\"" . $values[2] . "\""; ? ? $values[3] = "\"" . $values[3] . "\""; ? ? tep_db_query("INSERT INTO products_attributes (products_id, options_id, options_values_id, options_values_price, price_prefix) VALUES (" . $pID . ", '" . $values[0] . "', '" . $values[1] . "','". $att_price[$i]. "','". $plus[$i]. "')"); // ? ? tep_db_query("INSERT INTO products_attributes (products_id, options_id, options_values_id, options_values_price, price_prefix) VALUES (" . $pID . ", '" . $values[0] . "', '" . $values[1] . "','". $att_price[$x]. "','". $plus[$x]. "')"); ? } // Added by SP end // by SP tep_db_query("INSERT INTO products_attributes (products_id, options_id, options_values_id) VALUES (" . $pID . ", " . $values[0] . ", " . $values[1] . ")"); }} // Revision by RE // --> ADD CLOSE BRACKET FOR ABOVE IF STATEMENT THAT FILTERS THE POPULATED ARRAYS ?} // Improve Product Attributes/Item Editor end I would at least apprieciate some help even if it is advice on the variable names and what exactly is happenin here, as this is my first mod, and first time dealing with php . If you are willing to help me then you can get my categories.php from here... categories.php file here Any help in any form will be greatly appreciated. :thumbsup: Edited November 27, 2004 by protokop Quote
Guest Posted November 27, 2004 Posted November 27, 2004 what version of osC did u get that came with that contribution? Quote
protokop Posted November 27, 2004 Author Posted November 27, 2004 i've been told its all the latest version, if you can tell me how I can check i will and let you know Quote
Guest Posted November 27, 2004 Posted November 27, 2004 reason I asked, is if you download from the osCommerce.com site, no contributions are installed. Quote
protokop Posted November 27, 2004 Author Posted November 27, 2004 it was a pre setup shopping cart and as the attributes function was required, it was installed by the people who I got it from Quote
protokop Posted November 27, 2004 Author Posted November 27, 2004 ok, my understanding of php is rapidly increasing the code i put in the post earlier appear ok now, so u'll have to download the php file and take a look. its either a problem with adding the check box info to a temporary array or to the database Quote
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.
Note: Your post will require moderator approval before it will be visible.