I made a single SQL statement change that does the behavior that I was looking for in my original post. After reading some posts by Grayson I think I was able to do this properly. The version of zencart I have has since replaced main_template_vars_attributes.php with just attributes.php. What I wanted to do was prevent the option from showing if the individual product-option qty was 0. I made the following modification using a LEFT JOIN and then doing a check whether the quantity is greater than zero or IS NULL within the same sql statement. If > 0 then the individual product-option has qty available. If it IS NULL then there is not an entry for this product-option and it should be using the Main Item Qty.
Code:
$sql= "SELECT pov.products_options_values_id,
pov.products_options_values_name,
pa.*,
pwas.*
FROM " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_ATTRIBUTES . " pa LEFT JOIN " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas ON pwas.stock_attributes = pa.products_attributes_id
WHERE pa.products_id = '" . (int)$_GET['products_id'] . "'
and pa.options_id = '" . (int)$products_options_names->fields['products_options_id'] . "'
and (pwas.quantity > 0 or pwas.quantity IS NULL)
and pa.options_values_id = pov.products_options_values_id
and pov.language_id = '" . (int)$_SESSION['languages_id'] . "' " .
$order_by;
Do any of the senior zenners see any potential problems with this? Are there other areas that could potentially be broken by this modification that I may have missed?
Thanks