Well I've discovered that SQL code only works for my first item.
I think the idea is correct, just the manner in which the attributes by item are being returned is opaque to me, so I need to rework the SQL so I understand it (and can join on stock).
Well I've discovered that SQL code only works for my first item.
I think the idea is correct, just the manner in which the attributes by item are being returned is opaque to me, so I need to rework the SQL so I understand it (and can join on stock).
If you're only looking to affect the drop-down box, you will need to find this line of code in attributes.php:
Before you modify it, I recommend you place it in an override folder, i.e., /includes/modules/[YOU TEMPLATE]/attributes.php, and edit that file.Code:$options_menu[] = zen_draw_pull_down_menu('id[' . $products_options_names->fields['products_options_id'] . ']', $products_options_array, $selected_attribute, 'id="' . 'attrib-' . $products_options_names->fields['products_options_id'] . '"') . "\n";
Notice that it uses a function called zen_draw_pull_down_menu(). That can be found in html_output.php in the functions folder. You'll need to either create a new function and modify it in html_output, or copy that function down to attributes.php and modify it. Basically, what I did was check to see for read-only or quantity, and stated that selection was [out of stock] in the drop-down box. There is CSS you need to add if you want to grey it out. You can see it in action at:
http://www.randylion.com/index.php?m...roducts_id=142
You could remove that selection by modifying the function. If you wanted to do this for radio buttons, that is elsewhere in attributes.php.
Hope that points you in the right direction...
Owner, Randylion
http://www.randylion.com
Yes my intention is not to get people off on the wrong track! I can't figure out how products_with_attributes_stock.stock_attributes can be related to products_attributes.options_values_id so I created a new column in products_with_attributes_stock called products_attributes_lookup_id and hand populated it.
Again, I'm not saying this is a GOOD solution and I don't really understand a lot of the zen_cart coding choices but this is what got my single attribute drop down with stock working for the time being.
Code:$sql = 'SELECT pov.products_options_values_id, pov.products_options_values_name, pa.* FROM products_attributes pa JOIN products_options_values pov ON pa.options_values_id = pov.products_options_values_id JOIN products_with_attributes_stock ps ON (pa.options_values_id = ps.products_attributes_lookup_id AND pa.products_id = ps.products_id) WHERE pa.products_id = ' . (int)$_GET['products_id'] .' AND pa.options_id = ' . (int)$products_options_names->fields['products_options_id'] . ' AND pov.language_id = ' . (int)$_SESSION['languages_id'] . ' ' . $order_by;