Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Multiple categories and Improve Product Attributes


protokop

Recommended Posts

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 by protokop
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...