Totally Zenned
- Join Date:
- Jan 2005
- Location:
- USA, St. Louis
- Posts:
- 3,651
- Plugin Contributions:
- 5
Stocks by attributes
kellan4459:
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.
$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
I'm trying to get a method where the drop down menu shows how many of each available items there are, but AT THE SAME doesn't show any zero items at all. I can only seem to get one or the other to work.
Does anyone have it to where ZERO options don't show up, but the drop down menu tells you how many for each that ARE available?
If someone has this working, would you mind attaching your attributes.php file?
Thanks!
Thanks!