
Originally Posted by
kellan4459
I've looked through the code for the stock_by_attribute add-on and it looks like the verification is done at checkout. Is there any modifications that would prevent an attribute from showing in the product listing. For example if I want to allow time slots for an event but only allow qty 1 for each time slot. I don't want the customer to have to go through checkout multiple times trying to find an open time slot. I want them to be able to only see available time slots unless someone has purchased that time slot in the time it took them to complete their transaction then checkout would suffice for verifying quantity. I see a couple of queries in the attributes.php under modules that should be ok for checking quantity but I would like to here from someone with more time working with this area of the zencart to give me some feedback on preventing attributes from showing up if qty is zero or if this feature exists and I'm just missing something.
Thanks
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
Bookmarks